public static DeltaServerConfig read(String file) { JsonObject obj = JSON.read(file); return create(obj); }
/** * Look for {@link DataSource DataSources} in a disk area given by {@code location}. * <p> * Scan the given area for directories (must have a config file), check they are enabled, * and deal with {@code log_type}. */ public static List<DataSourceDescription> scanForLogs(Path location, PatchStore ps) { // PatchStore's that rely on the scan of local directories and checking the "log_type" field. Pair<List<Path>, List<Path>> pair = scanDirectory(location); List<Path> dataSourcePaths = pair.getLeft(); List<Path> disabledDataSources = pair.getRight(); //dataSourcePaths.forEach(p->LOG.info("Data source paths: "+p)); disabledDataSources.forEach(p->LOG.info("Data source: "+p+" : Disabled")); List<DataSourceDescription> descriptions = ListUtils.toList (dataSourcePaths.stream() .map(p->{ // Extract name from disk name. String dsName = p.getFileName().toString(); // read config file. JsonObject sourceObj = JSON.read(p.resolve(FileNames.DS_CONFIG).toString()); DataSourceDescription dsd = DataSourceDescription.fromJson(sourceObj); if ( ! Objects.equals(dsName, dsd.getName()) ) throw new DeltaConfigException("Names do not match: directory="+dsName+", dsd="+dsd); return dsd; }) .filter(Objects::nonNull) ); return descriptions; }
/** Parse a configuration file. */ public Builder parse(String configFile) { Path path = Paths.get(configFile); if ( ! Files.exists(path) ) throw new DeltaConfigException("File not found: "+configFile); // -- version JsonObject obj = JSON.read(configFile); int version = JSONX.getInt(obj, F_VERSION, -99); if ( version == -99 ) { LOG.warn("No version number for the configuration file : assuming 'current'"); version = DeltaConst.SYSTEM_VERSION; } if ( version != SYSTEM_VERSION ) throw new DeltaConfigException("Version number for LocalServer must be "+DeltaConst.SYSTEM_VERSION+"."); this.configFile = configFile; // -- log provider logProvider = DPS.PatchStoreFileProvider; String logTypeName = JSONX.getStrOrNull(obj, F_LOG_TYPE); if ( logTypeName != null ) { String providerName = PatchStoreMgr.canonical(logTypeName); if ( providerName == null ) providerName = DeltaConst.LOG_FILE; logProvider = providerName; } setProperty(DeltaConst.pDeltaFile, path.getParent().toString()); return this; }
private void parseConf(BackupConfig cfg, String cfgFile) { try { JsonObject obj = JSON.read(cfgFile); cfg.port = obj.get(jPort).getAsNumber().value().intValue(); JsonArray a = obj.get(jLogs).getAsArray(); a.forEach(elt-> { BackupArea area = parseLogObject(cfg, elt); cfg.logs.add(area); }); } catch (Exception ex) { throw new CmdException("Failed to process configuration file: "+ex.getMessage()); } }
static StoreParams read(Location location) { String fn = location.getPath(TDB_CONFIG_FILE) ; JsonObject obj = JSON.read(fn) ; return StoreParamsCodec.decode(obj) ; } }
static StoreParams read(Location location) { String fn = location.getPath(Names.TDB_CONFIG_FILE) ; JsonObject obj = JSON.read(fn) ; return StoreParamsCodec.decode(obj) ; } }
static StoreParams read(Location location) { String fn = location.getPath(Names.TDB_CONFIG_FILE) ; JsonObject obj = JSON.read(fn) ; return StoreParamsCodec.decode(obj) ; } }
static StoreParams read(Location location) { String fn = location.getPath(TDB_CONFIG_FILE) ; JsonObject obj = JSON.read(fn) ; return StoreParamsCodec.decode(obj) ; } }
String httpsSetup = getValue(argHttps); JsonObject httpsConf = JSON.read(httpsSetup); Path path = Paths.get(httpsSetup).toAbsolutePath(); String keystore = httpsConf.get("keystore").getAsString().value();
String httpsSetup = getValue(argHttps); JsonObject httpsConf = JSON.read(httpsSetup); Path path = Paths.get(httpsSetup).toAbsolutePath(); String keystore = httpsConf.get("keystore").getAsString().value();