@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 );
}