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 2c55b71b6..01fbd3538 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,6 +24,7 @@ import org.apache.archiva.admin.model.beans.ArchivaLdapConfiguration; import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; +import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.IndeterminateConfigurationException; import org.apache.archiva.configuration.RedbackRuntimeConfiguration; @@ -32,6 +33,8 @@ import org.apache.archiva.redback.configuration.UserConfiguration; import org.apache.archiva.redback.configuration.UserConfigurationException; import org.apache.archiva.redback.configuration.UserConfigurationKeys; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; @@ -45,10 +48,14 @@ import java.util.List; */ @Service( "userConfiguration#archiva" ) public class DefaultArchivaRuntimeConfigurationAdmin - extends AbstractRepositoryAdmin implements ArchivaRuntimeConfigurationAdmin, UserConfiguration { + protected Logger log = LoggerFactory.getLogger( getClass() ); + + @Inject + private ArchivaConfiguration archivaConfiguration; + @Inject @Named( value = "userConfiguration#redback" ) UserConfiguration userConfiguration; @@ -110,18 +117,18 @@ public class DefaultArchivaRuntimeConfigurationAdmin public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration() { - return build( getArchivaConfiguration().getConfiguration().getRedbackRuntimeConfiguration() ); + return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() ); } public void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) throws RepositoryAdminException { RedbackRuntimeConfiguration runtimeConfiguration = build( archivaRuntimeConfiguration ); - Configuration configuration = getArchivaConfiguration().getConfiguration(); + Configuration configuration = archivaConfiguration.getConfiguration(); configuration.setRedbackRuntimeConfiguration( runtimeConfiguration ); try { - getArchivaConfiguration().save( configuration ); + archivaConfiguration.save( configuration ); } catch ( RegistryException e ) { @@ -135,7 +142,15 @@ public class DefaultArchivaRuntimeConfigurationAdmin private ArchivaRuntimeConfiguration build( RedbackRuntimeConfiguration runtimeConfiguration ) { - return new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class ); + ArchivaRuntimeConfiguration archivaRuntimeConfiguration = new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class ); + + if (archivaRuntimeConfiguration.getArchivaLdapConfiguration() == null) + { + // prevent NPE + archivaRuntimeConfiguration.setArchivaLdapConfiguration( new ArchivaLdapConfiguration() ); + } + + return archivaRuntimeConfiguration; } private RedbackRuntimeConfiguration build( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml index 16b37542d..4e9025ba2 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-merge-index-download.xml @@ -52,5 +52,5 @@ - + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml index d9119bd4c..00cea6f2a 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml @@ -65,5 +65,5 @@ - + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml index 4478e93dc..05e2de5d4 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-test-common.xml @@ -21,13 +21,11 @@ + http://www.springframework.org/schema/context/spring-context-3.0.xsd" + default-lazy-init="true"> - + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml index fbc19b6f1..884383bc5 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml @@ -49,5 +49,5 @@ - +