use of org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration in project archiva by apache.
the class DefaultArchivaRuntimeConfigurationAdmin method initialize.
@PostConstruct
public void initialize() throws RepositoryAdminException {
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = getArchivaRuntimeConfiguration();
boolean save = false;
// NPE free
if (archivaRuntimeConfiguration.getFileLockConfiguration() == null) {
archivaRuntimeConfiguration.setFileLockConfiguration(new FileLockConfiguration());
}
// NPE free
if (archivaRuntimeConfiguration.getUrlFailureCacheConfiguration() == null) {
archivaRuntimeConfiguration.setUrlFailureCacheConfiguration(new CacheConfiguration());
}
// if -1 it means non initialized to take values from the spring bean
if (archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToIdleSeconds() < 0) {
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setTimeToIdleSeconds(urlFailureCache.getTimeToIdleSeconds());
save = true;
}
urlFailureCache.setTimeToIdleSeconds(archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToIdleSeconds());
if (archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToLiveSeconds() < 0) {
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setTimeToLiveSeconds(urlFailureCache.getTimeToLiveSeconds());
save = true;
}
urlFailureCache.setTimeToLiveSeconds(archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToLiveSeconds());
if (archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsInMemory() < 0) {
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setMaxElementsInMemory(urlFailureCache.getMaxElementsInMemory());
save = true;
}
urlFailureCache.setMaxElementsInMemory(archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsInMemory());
if (archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsOnDisk() < 0) {
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setMaxElementsOnDisk(urlFailureCache.getMaxElementsOnDisk());
save = true;
}
urlFailureCache.setMaxElementsOnDisk(archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsOnDisk());
if (save) {
updateArchivaRuntimeConfiguration(archivaRuntimeConfiguration);
}
}
use of org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration in project archiva by apache.
the class DefaultArchivaRuntimeConfigurationAdmin method updateArchivaRuntimeConfiguration.
@Override
public void updateArchivaRuntimeConfiguration(ArchivaRuntimeConfiguration archivaRuntimeConfiguration) throws RepositoryAdminException {
Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setArchivaRuntimeConfiguration(build(archivaRuntimeConfiguration));
try {
archivaConfiguration.save(configuration);
} catch (RegistryException e) {
throw new RepositoryAdminException(e.getMessage(), e);
} catch (IndeterminateConfigurationException e) {
throw new RepositoryAdminException(e.getMessage(), e);
}
}
Aggregations