aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-12-29 23:59:23 +0000
committerOlivier Lamy <olamy@apache.org>2012-12-29 23:59:23 +0000
commiteb31b496e9c379891aa3b238e910fa555a9b1f52 (patch)
tree75deb5f258b32dd0bd638f8941e36cd8870d344f
parent91e2a266aeb1b4a9ff5c8f577f792fbf2424f826 (diff)
downloadarchiva-eb31b496e9c379891aa3b238e910fa555a9b1f52.tar.gz
archiva-eb31b496e9c379891aa3b238e910fa555a9b1f52.zip
modification of ArchivaRuntimeConfiguration was not saved
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1426863 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java62
1 files changed, 51 insertions, 11 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
index 41896477f..a5ea1fbe1 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
@@ -24,7 +24,10 @@ import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.beans.CacheConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.redback.components.cache.Cache;
+import org.apache.archiva.redback.components.registry.RegistryException;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@@ -35,7 +38,7 @@ import javax.inject.Named;
* @author Olivier Lamy
* @since 1.4-M4
*/
-@Service( "archivaRuntimeConfigurationAdmin#default" )
+@Service("archivaRuntimeConfigurationAdmin#default")
public class DefaultArchivaRuntimeConfigurationAdmin
implements ArchivaRuntimeConfigurationAdmin
{
@@ -45,7 +48,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
@Inject
@Named( value = "cache#url-failures-cache" )
- private Cache usersCache;
+ private Cache urlFailureCache;
@PostConstruct
public void initialize()
@@ -65,39 +68,39 @@ public class DefaultArchivaRuntimeConfigurationAdmin
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToIdleSeconds() < 0 )
{
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setTimeToIdleSeconds(
- usersCache.getTimeToIdleSeconds() );
+ urlFailureCache.getTimeToIdleSeconds() );
save = true;
}
- usersCache.setTimeToIdleSeconds(
+ urlFailureCache.setTimeToIdleSeconds(
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToIdleSeconds() );
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToLiveSeconds() < 0 )
{
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setTimeToLiveSeconds(
- usersCache.getTimeToLiveSeconds() );
+ urlFailureCache.getTimeToLiveSeconds() );
save = true;
}
- usersCache.setTimeToLiveSeconds(
+ urlFailureCache.setTimeToLiveSeconds(
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getTimeToLiveSeconds() );
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsInMemory() < 0 )
{
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setMaxElementsInMemory(
- usersCache.getMaxElementsInMemory() );
+ urlFailureCache.getMaxElementsInMemory() );
save = true;
}
- usersCache.setMaxElementsInMemory(
+ urlFailureCache.setMaxElementsInMemory(
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsInMemory() );
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsOnDisk() < 0 )
{
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().setMaxElementsOnDisk(
- usersCache.getMaxElementsOnDisk() );
+ urlFailureCache.getMaxElementsOnDisk() );
save = true;
}
- usersCache.setMaxElementsOnDisk(
+ urlFailureCache.setMaxElementsOnDisk(
archivaRuntimeConfiguration.getUrlFailureCacheConfiguration().getMaxElementsOnDisk() );
if ( save )
@@ -116,7 +119,20 @@ public class DefaultArchivaRuntimeConfigurationAdmin
public void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws RepositoryAdminException
{
- //To change body of implemented methods use File | Settings | File Templates.
+ 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 );
+ }
}
protected ArchivaRuntimeConfiguration build(
@@ -141,6 +157,30 @@ public class DefaultArchivaRuntimeConfigurationAdmin
return res;
}
+
+ protected org.apache.archiva.configuration.ArchivaRuntimeConfiguration build(
+ ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
+ {
+ if ( archivaRuntimeConfiguration == null )
+ {
+ return new org.apache.archiva.configuration.ArchivaRuntimeConfiguration();
+ }
+
+ org.apache.archiva.configuration.ArchivaRuntimeConfiguration res =
+ new BeanReplicator().replicateBean( archivaRuntimeConfiguration,
+ org.apache.archiva.configuration.ArchivaRuntimeConfiguration.class );
+
+ if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration() != null )
+ {
+
+ res.setUrlFailureCacheConfiguration(
+ new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration(),
+ org.apache.archiva.configuration.CacheConfiguration.class ) );
+
+ }
+
+ return res;
+ }
}