Search in sources :

Example 1 with ArchivaRuntimeConfiguration

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);
    }
}
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 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);
    }
}
Also used : FileLockConfiguration(org.apache.archiva.admin.model.beans.FileLockConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ArchivaRuntimeConfiguration(org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration) Configuration(org.apache.archiva.configuration.Configuration) CacheConfiguration(org.apache.archiva.admin.model.beans.CacheConfiguration) IndeterminateConfigurationException(org.apache.archiva.configuration.IndeterminateConfigurationException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException) RegistryException(org.apache.archiva.redback.components.registry.RegistryException)

Aggregations

ArchivaRuntimeConfiguration (org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration)2 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 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 Configuration (org.apache.archiva.configuration.Configuration)1 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)1 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)1