use of org.apache.archiva.admin.model.beans.FileLockConfiguration 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.FileLockConfiguration in project archiva by apache.
the class DefaultArchivaRuntimeConfigurationService method updateArchivaRuntimeConfiguration.
@Override
public Boolean updateArchivaRuntimeConfiguration(ArchivaRuntimeConfiguration archivaRuntimeConfiguration) throws ArchivaRestServiceException {
try {
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration(archivaRuntimeConfiguration);
CacheConfiguration cacheConfiguration = archivaRuntimeConfiguration.getUrlFailureCacheConfiguration();
if (cacheConfiguration != null) {
usersCache.setTimeToLiveSeconds(cacheConfiguration.getTimeToLiveSeconds());
usersCache.setTimeToIdleSeconds(cacheConfiguration.getTimeToIdleSeconds());
usersCache.setMaxElementsOnDisk(cacheConfiguration.getMaxElementsOnDisk());
usersCache.setMaxElementsInMemory(cacheConfiguration.getMaxElementsInMemory());
}
FileLockConfiguration fileLockConfiguration = archivaRuntimeConfiguration.getFileLockConfiguration();
if (fileLockConfiguration != null) {
fileLockManager.setTimeout(fileLockConfiguration.getLockingTimeout());
fileLockManager.setSkipLocking(fileLockConfiguration.isSkipLocking());
}
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(e.getMessage(), e);
}
return Boolean.TRUE;
}
Aggregations