use a better naming convention as it concerned redback part

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1423659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-18 21:18:56 +00:00
parent d15b737723
commit 9736ffc636
9 changed files with 104 additions and 106 deletions

View File

@ -30,7 +30,7 @@ import java.util.Map;
* @since 1.4-M4 * @since 1.4-M4
*/ */
@XmlRootElement(name = "redbackRuntimeConfiguration") @XmlRootElement(name = "redbackRuntimeConfiguration")
public class ArchivaRuntimeConfiguration public class RedbackRuntimeConfiguration
implements Serializable implements Serializable
{ {
@ -53,7 +53,7 @@ public class ArchivaRuntimeConfiguration
*/ */
private List<PropertyEntry> configurationPropertiesEntries; private List<PropertyEntry> configurationPropertiesEntries;
public ArchivaRuntimeConfiguration() public RedbackRuntimeConfiguration()
{ {
// no op // no op
} }
@ -128,7 +128,7 @@ public class ArchivaRuntimeConfiguration
@Override @Override
public String toString() public String toString()
{ {
return "ArchivaRuntimeConfiguration{" + return "RedbackRuntimeConfiguration{" +
"userManagerImpls=" + userManagerImpls + "userManagerImpls=" + userManagerImpls +
", ldapConfiguration=" + ldapConfiguration + ", ldapConfiguration=" + ldapConfiguration +
", migratedFromRedbackConfiguration=" + migratedFromRedbackConfiguration + ", migratedFromRedbackConfiguration=" + migratedFromRedbackConfiguration +

View File

@ -19,7 +19,7 @@ package org.apache.archiva.admin.model.runtime;
*/ */
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
/** /**
* @author Olivier Lamy * @author Olivier Lamy
@ -27,10 +27,10 @@ import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
*/ */
public interface ArchivaRuntimeConfigurationAdmin public interface ArchivaRuntimeConfigurationAdmin
{ {
ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration() RedbackRuntimeConfiguration getArchivaRuntimeConfiguration()
throws RepositoryAdminException; throws RepositoryAdminException;
void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) void updateArchivaRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
throws RepositoryAdminException; throws RepositoryAdminException;
} }

View File

@ -21,12 +21,11 @@ package org.apache.archiva.admin.repository.runtime;
import net.sf.beanlib.provider.replicator.BeanReplicator; import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException; import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.RedbackRuntimeConfiguration;
import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.redback.configuration.UserConfiguration; import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationException; import org.apache.archiva.redback.configuration.UserConfigurationException;
@ -65,24 +64,24 @@ public class DefaultArchivaRuntimeConfigurationAdmin
{ {
try try
{ {
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration redbackRuntimeConfiguration = getArchivaRuntimeConfiguration();
// migrate or not data from redback // migrate or not data from redback
if ( !archivaRuntimeConfiguration.isMigratedFromRedbackConfiguration() ) if ( !redbackRuntimeConfiguration.isMigratedFromRedbackConfiguration() )
{ {
// so migrate if available // so migrate if available
String userManagerImpl = userConfiguration.getString( UserConfigurationKeys.USER_MANAGER_IMPL ); String userManagerImpl = userConfiguration.getString( UserConfigurationKeys.USER_MANAGER_IMPL );
if ( StringUtils.isNotEmpty( userManagerImpl ) ) if ( StringUtils.isNotEmpty( userManagerImpl ) )
{ {
archivaRuntimeConfiguration.getUserManagerImpls().add( userManagerImpl ); redbackRuntimeConfiguration.getUserManagerImpls().add( userManagerImpl );
} }
// now ldap // now ldap
LdapConfiguration ldapConfiguration = archivaRuntimeConfiguration.getLdapConfiguration(); LdapConfiguration ldapConfiguration = redbackRuntimeConfiguration.getLdapConfiguration();
if ( ldapConfiguration == null ) if ( ldapConfiguration == null )
{ {
ldapConfiguration = new LdapConfiguration(); ldapConfiguration = new LdapConfiguration();
archivaRuntimeConfiguration.setLdapConfiguration( ldapConfiguration ); redbackRuntimeConfiguration.setLdapConfiguration( ldapConfiguration );
} }
ldapConfiguration.setHostName( ldapConfiguration.setHostName(
@ -100,19 +99,19 @@ public class DefaultArchivaRuntimeConfigurationAdmin
ldapConfiguration.setAuthenticationMethod( ldapConfiguration.setAuthenticationMethod(
userConfiguration.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, null ) ); userConfiguration.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, null ) );
archivaRuntimeConfiguration.setMigratedFromRedbackConfiguration( true ); redbackRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );
updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration ); updateArchivaRuntimeConfiguration( redbackRuntimeConfiguration );
} }
// we must ensure userManagerImpls list is not empty if so put at least jdo one ! // we must ensure userManagerImpls list is not empty if so put at least jdo one !
if ( archivaRuntimeConfiguration.getUserManagerImpls().isEmpty() ) if ( redbackRuntimeConfiguration.getUserManagerImpls().isEmpty() )
{ {
log.info( log.info(
"archivaRuntimeConfiguration with empty userManagerImpls so force at least jdo implementation !" ); "redbackRuntimeConfiguration with empty userManagerImpls so force at least jdo implementation !" );
archivaRuntimeConfiguration.getUserManagerImpls().add( "jdo" ); redbackRuntimeConfiguration.getUserManagerImpls().add( "jdo" );
updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration ); updateArchivaRuntimeConfiguration( redbackRuntimeConfiguration );
} }
} }
@ -122,15 +121,16 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
} }
public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration() public RedbackRuntimeConfiguration getArchivaRuntimeConfiguration()
{ {
return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() ); return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() );
} }
public void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) public void updateArchivaRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
throws RepositoryAdminException throws RepositoryAdminException
{ {
RedbackRuntimeConfiguration runtimeConfiguration = build( archivaRuntimeConfiguration ); org.apache.archiva.configuration.RedbackRuntimeConfiguration
runtimeConfiguration = build( redbackRuntimeConfiguration );
Configuration configuration = archivaConfiguration.getConfiguration(); Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setRedbackRuntimeConfiguration( runtimeConfiguration ); configuration.setRedbackRuntimeConfiguration( runtimeConfiguration );
try try
@ -147,31 +147,31 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
} }
private ArchivaRuntimeConfiguration build( RedbackRuntimeConfiguration runtimeConfiguration ) private RedbackRuntimeConfiguration build( org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration )
{ {
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = RedbackRuntimeConfiguration redbackRuntimeConfiguration =
new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class ); new BeanReplicator().replicateBean( runtimeConfiguration, RedbackRuntimeConfiguration.class );
if ( runtimeConfiguration.getLdapConfiguration() != null ) if ( runtimeConfiguration.getLdapConfiguration() != null )
{ {
archivaRuntimeConfiguration.setLdapConfiguration( redbackRuntimeConfiguration.setLdapConfiguration(
new BeanReplicator().replicateBean( runtimeConfiguration.getLdapConfiguration(), new BeanReplicator().replicateBean( runtimeConfiguration.getLdapConfiguration(),
LdapConfiguration.class ) ); LdapConfiguration.class ) );
} }
if ( archivaRuntimeConfiguration.getLdapConfiguration() == null ) if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
{ {
// prevent NPE // prevent NPE
archivaRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() ); redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
} }
return archivaRuntimeConfiguration; return redbackRuntimeConfiguration;
} }
private RedbackRuntimeConfiguration build( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) private org.apache.archiva.configuration.RedbackRuntimeConfiguration build( RedbackRuntimeConfiguration archivaRuntimeConfiguration )
{ {
RedbackRuntimeConfiguration redbackRuntimeConfiguration = org.apache.archiva.configuration.RedbackRuntimeConfiguration redbackRuntimeConfiguration =
new BeanReplicator().replicateBean( archivaRuntimeConfiguration, RedbackRuntimeConfiguration.class ); new BeanReplicator().replicateBean( archivaRuntimeConfiguration, org.apache.archiva.configuration.RedbackRuntimeConfiguration.class );
redbackRuntimeConfiguration.setLdapConfiguration( redbackRuntimeConfiguration.setLdapConfiguration(
new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getLdapConfiguration(), new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getLdapConfiguration(),
@ -191,7 +191,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
return getArchivaRuntimeConfiguration().getUserManagerImpls().get( 0 ); return getArchivaRuntimeConfiguration().getUserManagerImpls().get( 0 );
} }
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
if ( conf.getConfigurationProperties().containsKey( key ) ) if ( conf.getConfigurationProperties().containsKey( key ) )
{ {
@ -211,7 +211,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -237,7 +237,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
return getArchivaRuntimeConfiguration().getLdapConfiguration().getAuthenticationMethod(); return getArchivaRuntimeConfiguration().getLdapConfiguration().getAuthenticationMethod();
} }
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
if ( conf.getConfigurationProperties().containsKey( key ) ) if ( conf.getConfigurationProperties().containsKey( key ) )
{ {
@ -258,7 +258,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -267,7 +267,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
public int getInt( String key ) public int getInt( String key )
{ {
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
if ( conf.getConfigurationProperties().containsKey( key ) ) if ( conf.getConfigurationProperties().containsKey( key ) )
{ {
@ -283,7 +283,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -297,7 +297,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
return getArchivaRuntimeConfiguration().getLdapConfiguration().getPort(); return getArchivaRuntimeConfiguration().getLdapConfiguration().getPort();
} }
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
if ( conf.getConfigurationProperties().containsKey( key ) ) if ( conf.getConfigurationProperties().containsKey( key ) )
{ {
@ -313,7 +313,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -322,7 +322,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
public boolean getBoolean( String key ) public boolean getBoolean( String key )
{ {
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
if ( conf.getConfigurationProperties().containsKey( key ) ) if ( conf.getConfigurationProperties().containsKey( key ) )
{ {
@ -338,7 +338,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -352,7 +352,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
return getArchivaRuntimeConfiguration().getLdapConfiguration().isSsl(); return getArchivaRuntimeConfiguration().getLdapConfiguration().isSsl();
} }
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
if ( conf.getConfigurationProperties().containsKey( key ) ) if ( conf.getConfigurationProperties().containsKey( key ) )
{ {
@ -368,7 +368,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }
@ -379,7 +379,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
{ {
List<String> value = userConfiguration.getList( key ); List<String> value = userConfiguration.getList( key );
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration(); RedbackRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
// TODO concat values // TODO concat values
conf.getConfigurationProperties().put( key, "" ); conf.getConfigurationProperties().put( key, "" );
try try
@ -388,7 +388,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
} }
catch ( RepositoryAdminException e ) catch ( RepositoryAdminException e )
{ {
log.error( "fail to save ArchivaRuntimeConfiguration: {}", e.getMessage(), e ); log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
throw new RuntimeException( e.getMessage(), e ); throw new RuntimeException( e.getMessage(), e );
} }

View File

@ -18,7 +18,7 @@ package org.apache.archiva.rest.api.services;
* under the License. * under the License.
*/ */
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration;
import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.redback.authorization.RedbackAuthorization;
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
@ -44,15 +44,15 @@ public interface ArchivaRuntimeConfigurationService
@GET @GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin() RedbackRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path("archivaRuntimeConfiguration") @Path("redbackRuntimeConfiguration")
@PUT @PUT
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) Boolean updateArchivaRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path("userManagerImplementationInformation") @Path("userManagerImplementationInformation")

View File

@ -19,7 +19,7 @@ package org.apache.archiva.rest.services;
*/ */
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.redback.authentication.AuthenticationException; import org.apache.archiva.redback.authentication.AuthenticationException;
@ -71,7 +71,7 @@ public class DefaultArchivaRuntimeConfigurationService
@Named(value = "ldapConnectionFactory#configurable") @Named(value = "ldapConnectionFactory#configurable")
private LdapConnectionFactory ldapConnectionFactory; private LdapConnectionFactory ldapConnectionFactory;
public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin() public RedbackRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
try try
@ -84,25 +84,25 @@ public class DefaultArchivaRuntimeConfigurationService
} }
} }
public Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) public Boolean updateArchivaRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
throws ArchivaRestServiceException throws ArchivaRestServiceException
{ {
try try
{ {
// has user manager impl changed ? // has user manager impl changed ?
boolean userManagerChanged = archivaRuntimeConfiguration.getUserManagerImpls().size() boolean userManagerChanged = redbackRuntimeConfiguration.getUserManagerImpls().size()
!= archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls().size(); != archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls().size();
userManagerChanged = userManagerChanged =
userManagerChanged || ( archivaRuntimeConfiguration.getUserManagerImpls().toString().hashCode() userManagerChanged || ( redbackRuntimeConfiguration.getUserManagerImpls().toString().hashCode()
!= archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls().toString().hashCode() ); != archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls().toString().hashCode() );
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration ); archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( redbackRuntimeConfiguration );
if ( userManagerChanged ) if ( userManagerChanged )
{ {
log.info( "user managerImpls changed to {} so reload it", log.info( "user managerImpls changed to {} so reload it",
archivaRuntimeConfiguration.getUserManagerImpls() ); redbackRuntimeConfiguration.getUserManagerImpls() );
userManager.initialize(); userManager.initialize();
} }

View File

@ -18,7 +18,7 @@ package org.apache.archiva.rest.services;
* under the License. * under the License.
*/ */
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService; import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
import org.fest.assertions.api.Assertions; import org.fest.assertions.api.Assertions;
@ -37,25 +37,25 @@ public class ArchivaRuntimeConfigurationServiceTest
public void nonnullConfiguration() public void nonnullConfiguration()
throws Exception throws Exception
{ {
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = RedbackRuntimeConfiguration redbackRuntimeConfiguration =
getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin(); getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpls().get( 0 ) ); assertEquals( "jdo", redbackRuntimeConfiguration.getUserManagerImpls().get( 0 ) );
} }
@Test @Test
public void update() public void update()
throws Exception throws Exception
{ {
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = RedbackRuntimeConfiguration redbackRuntimeConfiguration =
getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin(); getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpls().get( 0 ) ); assertEquals( "jdo", redbackRuntimeConfiguration.getUserManagerImpls().get( 0 ) );
archivaRuntimeConfiguration.setUserManagerImpls( Arrays.asList( "foo" ) ); redbackRuntimeConfiguration.setUserManagerImpls( Arrays.asList( "foo" ) );
getArchivaRuntimeConfigurationService().updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration ); getArchivaRuntimeConfigurationService().updateArchivaRuntimeConfiguration( redbackRuntimeConfiguration );
archivaRuntimeConfiguration = getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin(); redbackRuntimeConfiguration = getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
assertEquals( "foo", archivaRuntimeConfiguration.getUserManagerImpls().get( 0 ) ); assertEquals( "foo", redbackRuntimeConfiguration.getUserManagerImpls().get( 0 ) );
} }

View File

@ -19,12 +19,10 @@ package org.apache.archiva.web.runtime.ldap;
*/ */
import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.admin.model.beans.LdapConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.redback.common.ldap.connection.ConfigurableLdapConnectionFactory; import org.apache.archiva.redback.common.ldap.connection.ConfigurableLdapConnectionFactory;
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;

View File

@ -1151,10 +1151,10 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
} }
ArchivaRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries){ RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries){
var self=this; var self=this;
this.modified=ko.observable(false); this.modified=ko.observable(false);
this.modified.subscribe(function(newValue){$.log("ArchivaRuntimeConfiguration modified")}); this.modified.subscribe(function(newValue){$.log("RedbackRuntimeConfiguration modified")});
this.userManagerImpls=ko.observableArray(userManagerImpls); this.userManagerImpls=ko.observableArray(userManagerImpls);
this.userManagerImpls.subscribe(function(newValue){self.modified(true)}); this.userManagerImpls.subscribe(function(newValue){self.modified(true)});
@ -1171,22 +1171,22 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
}); });
} }
mapArchivaRuntimeConfiguration=function(data){ mapRedbackRuntimeConfiguration=function(data){
var archivaRuntimeConfiguration = var redbackRuntimeConfiguration =
new ArchivaRuntimeConfiguration(data.userManagerImpls,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration); new RedbackRuntimeConfiguration(data.userManagerImpls,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration);
var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){ var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
return new Entry(item.key, item.value,function(newValue){ return new Entry(item.key, item.value,function(newValue){
archivaRuntimeConfiguration.modified(true); redbackRuntimeConfiguration.modified(true);
}); });
}); });
if (!$.isArray(configurationPropertiesEntries)){ if (!$.isArray(configurationPropertiesEntries)){
configurationPropertiesEntries=[]; configurationPropertiesEntries=[];
} }
archivaRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries); redbackRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries);
archivaRuntimeConfiguration.modified(false); redbackRuntimeConfiguration.modified(false);
return archivaRuntimeConfiguration; return redbackRuntimeConfiguration;
} }
@ -1246,9 +1246,9 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
return null; return null;
} }
ArchivaRuntimeConfigurationViewModel=function(archivaRuntimeConfiguration,userManagerImplementationInformations){ RedbackRuntimeConfigurationViewModel=function(redbackRuntimeConfiguration,userManagerImplementationInformations){
var self=this; var self=this;
this.archivaRuntimeConfiguration=ko.observable(archivaRuntimeConfiguration); this.redbackRuntimeConfiguration=ko.observable(redbackRuntimeConfiguration);
this.userManagerImplementationInformations=ko.observable(userManagerImplementationInformations); this.userManagerImplementationInformations=ko.observable(userManagerImplementationInformations);
this.usedUserManagerImpls=ko.observableArray([]); this.usedUserManagerImpls=ko.observableArray([]);
@ -1300,7 +1300,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
{ {
type: "POST", type: "POST",
contentType: 'application/json', contentType: 'application/json',
data:ko.toJSON(self.archivaRuntimeConfiguration().ldapConfiguration), data:ko.toJSON(self.redbackRuntimeConfiguration().ldapConfiguration),
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
var message=$.i18n.prop('redback.runtime.ldap.verified'); var message=$.i18n.prop('redback.runtime.ldap.verified');
@ -1318,8 +1318,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
); );
} }
for(var i= 0;i<archivaRuntimeConfiguration.userManagerImpls().length;i++){ for(var i= 0;i<redbackRuntimeConfiguration.userManagerImpls().length;i++){
var id=archivaRuntimeConfiguration.userManagerImpls()[i]; var id=redbackRuntimeConfiguration.userManagerImpls()[i];
$.log("id:"+id); $.log("id:"+id);
var userManagerImplementationInformation=findUserManagerImplementationInformation(id); var userManagerImplementationInformation=findUserManagerImplementationInformation(id);
@ -1348,7 +1348,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
userManagerImplMoved=function(arg){ userManagerImplMoved=function(arg){
$.log("userManagerImplMoved"); $.log("userManagerImplMoved");
self.archivaRuntimeConfiguration().modified(true); self.redbackRuntimeConfiguration().modified(true);
} }
saveArchivaRuntimeConfiguration=function(){ saveArchivaRuntimeConfiguration=function(){
@ -1358,20 +1358,20 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
clearUserMessages(); clearUserMessages();
var userMessages=$("#user-messages"); var userMessages=$("#user-messages");
userMessages.html(mediumSpinnerImg()); userMessages.html(mediumSpinnerImg());
self.archivaRuntimeConfiguration().userManagerImpls=ko.observableArray([]); self.redbackRuntimeConfiguration().userManagerImpls=ko.observableArray([]);
$.log("length:"+self.usedUserManagerImpls().length); $.log("length:"+self.usedUserManagerImpls().length);
for(var i=0;i<self.usedUserManagerImpls().length;i++){ for(var i=0;i<self.usedUserManagerImpls().length;i++){
var beanId=self.usedUserManagerImpls()[i].beanId; var beanId=self.usedUserManagerImpls()[i].beanId;
$.log("beanId:"+beanId); $.log("beanId:"+beanId);
self.archivaRuntimeConfiguration().userManagerImpls.push(beanId); self.redbackRuntimeConfiguration().userManagerImpls.push(beanId);
} }
$.log("length:"+self.archivaRuntimeConfiguration().userManagerImpls().length); $.log("length:"+self.redbackRuntimeConfiguration().userManagerImpls().length);
$.log("json:"+ko.toJSON(self.archivaRuntimeConfiguration)); $.log("json:"+ko.toJSON(self.redbackRuntimeConfiguration));
$.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/archivaRuntimeConfiguration", $.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/archivaRuntimeConfiguration",
{ {
type: "PUT", type: "PUT",
contentType: 'application/json', contentType: 'application/json',
data:ko.toJSON(self.archivaRuntimeConfiguration), data:ko.toJSON(self.redbackRuntimeConfiguration),
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
var message=$.i18n.prop('archiva-runtime-configuration.updated'); var message=$.i18n.prop('archiva-runtime-configuration.updated');
@ -1384,8 +1384,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
complete:function(data){ complete:function(data){
removeMediumSpinnerImg(userMessages); removeMediumSpinnerImg(userMessages);
saveButton.button('reset'); saveButton.button('reset');
self.archivaRuntimeConfiguration().modified(false); self.redbackRuntimeConfiguration().modified(false);
self.archivaRuntimeConfiguration().ldapConfiguration().modified(false); self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
} }
} }
); );
@ -1427,11 +1427,11 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
type: "GET", type: "GET",
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
var archivaRuntimeConfiguration = mapArchivaRuntimeConfiguration(data); var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
var archivaRuntimeConfigurationViewModel = var redbackRuntimeConfigurationViewModel =
new ArchivaRuntimeConfigurationViewModel(archivaRuntimeConfiguration,userManagerImplementationInformations); new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
mainContent.html( $( "#runtime-configuration-main" ).tmpl() ); mainContent.html( $( "#runtime-configuration-main" ).tmpl() );
ko.applyBindings(archivaRuntimeConfigurationViewModel,$("#runtime-configuration-content" ).get(0)); ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#runtime-configuration-content" ).get(0));
activatePopoverDoc(); activatePopoverDoc();
} }
}); });

View File

@ -932,7 +932,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="text" id="ldap-host" name="ldap-host" class="input-xlarge" <input type="text" id="ldap-host" name="ldap-host" class="input-xlarge"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().hostName"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().hostName"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -941,7 +941,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="text" id="ldap-port" name="ldap-port" class="input-large" <input type="text" id="ldap-port" name="ldap-port" class="input-large"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().port"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().port"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -950,7 +950,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="text" id="ldap-baseDn" name="ldap-baseDn" class="input-xxlarge" <input type="text" id="ldap-baseDn" name="ldap-baseDn" class="input-xxlarge"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().baseDn"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().baseDn"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -959,7 +959,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="text" id="ldap-bindDn" name="ldap-bindDn" class="input-xxlarge" <input type="text" id="ldap-bindDn" name="ldap-bindDn" class="input-xxlarge"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().bindDn"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().bindDn"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -968,7 +968,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="checkbox" id="ldap-ssl" name="ldap-ssl" <input type="checkbox" id="ldap-ssl" name="ldap-ssl"
data-bind="checked: archivaRuntimeConfiguration().ldapConfiguration().ssl"/> data-bind="checked: redbackRuntimeConfiguration().ldapConfiguration().ssl"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -977,7 +977,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="password" id="ldap-password" name="ldap-password" class="input-xlarge" <input type="password" id="ldap-password" name="ldap-password" class="input-xlarge"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().password"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().password"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -986,7 +986,7 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="text" id="ldap-context-factory" name="ldap-context-factory" class="input-xlarge" <input type="text" id="ldap-context-factory" name="ldap-context-factory" class="input-xlarge"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().contextFactory"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().contextFactory"/>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -995,15 +995,15 @@
</label> </label>
<div class="controls"> <div class="controls">
<input type="text" id="ldap-authenticationMethod" name="ldap-authenticationMethod" class="input-xlarge" <input type="text" id="ldap-authenticationMethod" name="ldap-authenticationMethod" class="input-xlarge"
data-bind="value: archivaRuntimeConfiguration().ldapConfiguration().authenticationMethod"/> data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().authenticationMethod"/>
</div> </div>
</div> </div>
<!-- TODO extraPropertiesEntries --> <!-- TODO extraPropertiesEntries -->
</form> </form>
<button data-bind="click: checkChangedLdapConfiguration,css:{ 'btn-warning': archivaRuntimeConfiguration().ldapConfiguration().modified() }, <button data-bind="click: checkChangedLdapConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().ldapConfiguration().modified() },
enabled: archivaRuntimeConfiguration().ldapConfiguration().modified()" enabled: redbackRuntimeConfiguration().ldapConfiguration().modified()"
id="ldap-configuration-check-modification"class="btn">${$.i18n.prop('redback.runtime.ldap.checkModification')}</button> id="ldap-configuration-check-modification"class="btn">${$.i18n.prop('redback.runtime.ldap.checkModification')}</button>
<button data-bind="click: checkLdapServerConfiguration" <button data-bind="click: checkLdapServerConfiguration"
@ -1023,7 +1023,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{each(i, property) archivaRuntimeConfiguration().configurationPropertiesEntries}} {{each(i, property) redbackRuntimeConfiguration().configurationPropertiesEntries}}
<tr> <tr>
<td> <td>
{{var key = property.key}} {{var key = property.key}}
@ -1044,7 +1044,7 @@
</div> </div>
<div> <div>
<button data-bind="click: saveArchivaRuntimeConfiguration,css:{ 'btn-warning': archivaRuntimeConfiguration().modified() | archivaRuntimeConfiguration().ldapConfiguration().modified() }" <button data-bind="click: saveArchivaRuntimeConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().modified() | redbackRuntimeConfiguration().ldapConfiguration().modified() }"
id="archiva-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button> id="archiva-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button>
</div> </div>