use of org.apache.archiva.components.registry.Registry in project archiva by apache.
the class DefaultArchivaConfiguration method save.
/**
* Saves the configuration and adds the given tag to the event.
* @param configuration the configuration to save
* @param eventTag the tag to add to the configuration saved event
* @throws IndeterminateConfigurationException if the
* @throws RegistryException
*/
@Override
public synchronized void save(Configuration configuration, String eventTag) throws IndeterminateConfigurationException, RegistryException {
Registry section = registry.getSection(KEY + ".user");
Registry baseSection = registry.getSection(KEY + ".base");
if (section == null) {
section = baseSection;
if (section == null) {
section = createDefaultConfigurationFile(eventTag);
}
} else if (baseSection != null) {
Collection<String> keys = baseSection.getKeys();
boolean foundList = false;
for (Iterator<String> i = keys.iterator(); i.hasNext() && !foundList; ) {
String key = i.next();
// that configuration
if (//
key.startsWith("repositories") || //
key.startsWith("proxyConnectors") || //
key.startsWith("networkProxies") || //
key.startsWith("repositoryScanning") || //
key.startsWith("remoteRepositories") || //
key.startsWith("managedRepositories") || //
key.startsWith("repositoryGroups")) {
foundList = true;
}
}
if (foundList) {
this.configuration = null;
throw new IndeterminateConfigurationException("Configuration can not be saved when it is loaded from two sources");
}
}
// escape all cron expressions to handle ','
escapeCronExpressions(configuration);
// [MRM-661] Due to a bug in the modello registry writer, we need to take these out by hand. They'll be put back by the writer.
if (section != null) {
if (configuration.getManagedRepositories().isEmpty()) {
section.removeSubset("managedRepositories");
}
if (configuration.getRemoteRepositories().isEmpty()) {
section.removeSubset("remoteRepositories");
}
if (configuration.getProxyConnectors().isEmpty()) {
section.removeSubset("proxyConnectors");
}
if (configuration.getNetworkProxies().isEmpty()) {
section.removeSubset("networkProxies");
}
if (configuration.getLegacyArtifactPaths().isEmpty()) {
section.removeSubset("legacyArtifactPaths");
}
if (configuration.getRepositoryGroups().isEmpty()) {
section.removeSubset("repositoryGroups");
}
if (configuration.getRepositoryScanning() != null) {
if (configuration.getRepositoryScanning().getKnownContentConsumers().isEmpty()) {
section.removeSubset("repositoryScanning.knownContentConsumers");
}
if (configuration.getRepositoryScanning().getInvalidContentConsumers().isEmpty()) {
section.removeSubset("repositoryScanning.invalidContentConsumers");
}
}
if (configuration.getArchivaRuntimeConfiguration() != null) {
section.removeSubset("archivaRuntimeConfiguration.defaultCheckPaths");
}
new ConfigurationRegistryWriter().write(configuration, section);
section.save();
}
this.configuration = unescapeExpressions(configuration);
isConfigurationDefaulted = false;
triggerEvent(ConfigurationEvent.SAVED, eventTag);
}
use of org.apache.archiva.components.registry.Registry in project archiva by apache.
the class BasicManagedRepositoryValidator method interpolateVars.
public String interpolateVars(String directory) {
Registry registry = configurationHandler.getArchivaConfiguration().getRegistry();
String value = StringUtils.replace(directory, "${appserver.base}", registry.getString("appserver.base", "${appserver.base}"));
value = StringUtils.replace(value, "${appserver.home}", registry.getString("appserver.home", "${appserver.home}"));
return value;
}
use of org.apache.archiva.components.registry.Registry in project archiva by apache.
the class BasicRemoteRepositoryValidator method interpolateVars.
public String interpolateVars(String directory) {
Registry registry = configurationHandler.getArchivaConfiguration().getRegistry();
String value = StringUtils.replace(directory, "${appserver.base}", registry.getString("appserver.base", "${appserver.base}"));
value = StringUtils.replace(value, "${appserver.home}", registry.getString("appserver.home", "${appserver.home}"));
return value;
}
Aggregations