Search in sources :

Example 1 with FileLockConfiguration

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);
    }
}
Also used : ArchivaRuntimeConfiguration(org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration) CacheConfiguration(org.apache.archiva.admin.model.beans.CacheConfiguration) FileLockConfiguration(org.apache.archiva.admin.model.beans.FileLockConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 2 with FileLockConfiguration

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;
}
Also used : ArchivaRestServiceException(org.apache.archiva.rest.api.services.ArchivaRestServiceException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) CacheConfiguration(org.apache.archiva.admin.model.beans.CacheConfiguration) FileLockConfiguration(org.apache.archiva.admin.model.beans.FileLockConfiguration)

Aggregations

CacheConfiguration (org.apache.archiva.admin.model.beans.CacheConfiguration)2 FileLockConfiguration (org.apache.archiva.admin.model.beans.FileLockConfiguration)2 PostConstruct (javax.annotation.PostConstruct)1 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)1 ArchivaRuntimeConfiguration (org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration)1 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)1