use of org.apache.commons.configuration.ConfigurationException in project oxCore by GluuFederation.
the class FileConfiguration method loadProperties.
protected void loadProperties() {
try {
this.propertiesConfiguration = new PropertiesConfiguration(this.fileName);
this.loaded = true;
} catch (ConfigurationException ex) {
LOG.debug(String.format("Failed to load '%s' configuration file from config folder", this.fileName));
}
}
use of org.apache.commons.configuration.ConfigurationException in project winery by eclipse.
the class CsarExporter method addNamespacePrefixes.
/**
* Writes the configured mapping namespaceprefix -> namespace to the archive
* <p>
* This is kind of a quick hack. TODO: during the import, the prefixes should be extracted using JAXB and stored in
* the NamespacesResource
*/
private void addNamespacePrefixes(ArchiveOutputStream zos, IRepository repository) throws IOException {
Configuration configuration = repository.getConfiguration(new NamespacesId());
if (configuration instanceof PropertiesConfiguration) {
// Quick hack: direct serialization only works for PropertiesConfiguration
PropertiesConfiguration pconf = (PropertiesConfiguration) configuration;
ArchiveEntry archiveEntry = new ZipArchiveEntry(CsarExporter.PATH_TO_NAMESPACES_PROPERTIES);
zos.putArchiveEntry(archiveEntry);
try {
pconf.save(zos);
} catch (ConfigurationException e) {
CsarExporter.LOGGER.debug(e.getMessage(), e);
zos.write("#Could not export properties".getBytes());
zos.write(("#" + e.getMessage()).getBytes());
}
zos.closeArchiveEntry();
}
}
use of org.apache.commons.configuration.ConfigurationException in project winery by eclipse.
the class CsarImporter method importNamespacePrefixes.
/**
* Import namespace prefixes. This is kind of a quick hack. TODO: during the import, the prefixes should be
* extracted using JAXB and stored in the NamespacesResource
*
* @param rootPath the root path of the extracted CSAR
*/
private void importNamespacePrefixes(Path rootPath) {
NamespaceManager namespaceManager = RepositoryFactory.getRepository().getNamespaceManager();
Path properties = rootPath.resolve(CsarExporter.PATH_TO_NAMESPACES_PROPERTIES);
if (Files.exists(properties)) {
PropertiesConfiguration pconf;
try {
pconf = new PropertiesConfiguration(properties.toFile());
} catch (ConfigurationException e) {
CsarImporter.LOGGER.debug(e.getMessage(), e);
return;
}
Iterator<String> namespaces = pconf.getKeys();
while (namespaces.hasNext()) {
boolean addToStorage = false;
String namespace = namespaces.next();
if (namespaceManager.hasPrefix(namespace)) {
String storedPrefix = namespaceManager.getPrefix(namespace);
// QUICK HACK to check whether the prefix is a generated one
// We assume we know the internal generation routine
Matcher m = CsarImporter.GENERATED_PREFIX_PATTERN.matcher(storedPrefix);
if (m.matches()) {
// the stored prefix is a generated one
// replace it by the one stored in the exported properties
addToStorage = true;
}
} else {
addToStorage = true;
}
if (addToStorage) {
String prefix = pconf.getString(namespace);
namespaceManager.setPrefix(namespace, prefix);
}
}
}
}
use of org.apache.commons.configuration.ConfigurationException in project grakn by graknlabs.
the class QueueConfig method parseFileToMap.
private static Map<String, List<Object>> parseFileToMap(Path configPath) {
Map<String, List<Object>> map = new HashMap<>();
try {
PropertiesConfiguration props = new PropertiesConfiguration(configPath.toFile());
props.getKeys().forEachRemaining(key -> map.put(key, props.getList(key)));
} catch (ConfigurationException e) {
e.printStackTrace();
}
return map;
}
use of org.apache.commons.configuration.ConfigurationException in project gocd by gocd.
the class AgentAutoRegistrationPropertiesImpl method scrubRegistrationProperties.
@Override
public void scrubRegistrationProperties() {
if (!exist()) {
return;
}
try {
PropertiesConfiguration config = new PropertiesConfiguration();
config.setIOFactory(new FilteringOutputWriterFactory());
PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(config);
layout.setLineSeparator("\n");
layout.load(reader());
try (FileWriter out = new FileWriter(this.configFile)) {
layout.save(out);
}
loadProperties();
} catch (ConfigurationException | IOException e) {
LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e);
}
}
Aggregations