use of org.apache.commons.configuration2.PropertiesConfiguration in project xwiki-platform by xwiki.
the class AllTests method setupRepositories.
private void setupRepositories(XWikiExecutor executor) throws Exception {
LOGGER.info("Adding repository to xwiki.properties");
if (executor.getExecutionDirectory() != null) {
PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
// Put self and Maven as extensions repository
properties.setProperty("extension.repositories", "maven-test:maven:" + repositoryUtil.getMavenRepository().toURI());
executor.saveXWikiProperties();
}
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project xwiki-platform by xwiki.
the class AllTests method preStart.
@XWikiExecutorSuite.PreStart
public void preStart(List<XWikiExecutor> executors) throws Exception {
XWikiExecutor executor = executors.get(0);
repositoryUtil = new RepositoryUtils();
LOGGER.info("Adding maven repository to xwiki.properties");
PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
// Put self as extensions repository
properties.setProperty("extension.repositories", "maven-test:maven:" + repositoryUtil.getMavenRepository().toURI());
// Disable core extension resolve because Jetty is not ready when it starts
properties.setProperty("extension.core.resolve", false);
executor.saveXWikiProperties();
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project xwiki-platform by xwiki.
the class SingleXWikiExecutor method start.
/**
* {@inheritDoc}
*
* Starts the server on the first call, subsequent calls only increase the internal counter by one.
*/
@Override
public synchronized void start() throws Exception {
if (counter == 0) {
if (!VERIFY_RUNNING_XWIKI_AT_START.equals("true") || isXWikiStarted(getURL(), 15).timedOut) {
// Disable extensions manager external repositories
PropertiesConfiguration properties = loadXWikiPropertiesConfiguration();
if (!properties.containsKey("extension.repositories")) {
properties.setProperty("extension.repositories", "");
}
saveXWikiProperties();
}
super.start();
}
counter++;
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project winery by eclipse.
the class AbstractFileBasedRepository method getConfiguration.
@Override
public Configuration getConfiguration(RepositoryFileReference ref) {
Path path = this.ref2AbsolutePath(ref);
PropertiesConfiguration configuration = new PropertiesConfiguration();
if (Files.exists(path)) {
try (Reader r = Files.newBufferedReader(path, Charset.defaultCharset())) {
configuration.read(r);
} catch (ConfigurationException | IOException e) {
LOGGER.error("Could not read config file", e);
throw new IllegalStateException("Could not read config file", e);
}
}
configuration.addEventListener(ConfigurationEvent.ANY, new AutoSaveListener(path, configuration));
return configuration;
}
use of org.apache.commons.configuration2.PropertiesConfiguration in project janusgraph by JanusGraph.
the class ConfigurationLint method validate.
public static Status validate(String filename) throws IOException {
try (final FileInputStream fis = new FileInputStream(filename)) {
new Properties().load(fis);
}
final PropertiesConfiguration apc;
try {
apc = ConfigurationUtil.loadPropertiesConfig(filename);
} catch (ConfigurationException e) {
throw new IOException(e);
}
// new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
// , BasicConfiguration.Restriction.NONE);
Iterator<String> iterator = apc.getKeys();
int totalKeys = 0;
int keysVerified = 0;
while (iterator.hasNext()) {
totalKeys++;
String key = iterator.next();
String value = apc.getString(key);
try {
ConfigElement.PathIdentifier pid = ConfigElement.parse(GraphDatabaseConfiguration.ROOT_NS, key);
// ConfigElement shouldn't return null; failure here probably relates to janusgraph-core, not the file
Preconditions.checkNotNull(pid);
Preconditions.checkNotNull(pid.element);
if (!pid.element.isOption()) {
log.warn("Config key {} is a namespace (only options can be keys)", key);
continue;
}
final ConfigOption<?> opt;
try {
opt = (ConfigOption<?>) pid.element;
} catch (RuntimeException re) {
// This shouldn't happen given the preceding check, but catch it anyway
log.warn("Config key {} maps to the element {}, but it could not be cast to an option", key, pid.element, re);
continue;
}
try {
Object o = new CommonsConfiguration(apc).get(key, opt.getDatatype());
opt.verify(o);
keysVerified++;
} catch (RuntimeException re) {
log.warn("Config key {} is recognized, but its value {} could not be validated", key, value);
log.debug("Validation exception on {}={} follows", key, value, re);
}
} catch (RuntimeException re) {
log.warn("Unknown config key {}", key);
}
}
return new Status(totalKeys, totalKeys - keysVerified);
}
Aggregations