import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
+import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import java.util.List;
/**
* @author Olivier Lamy
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws ArchivaRestServiceException;
+
+ @Path ( "userManagerImplementationInformation" )
+ @GET
+ @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
+ throws ArchivaRestServiceException;
}
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.redback.users.UserManager;
+import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
import org.apache.commons.lang.StringUtils;
+import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
/**
* @author Olivier Lamy
private ArchivaRuntimeConfigurationAdmin archivaRuntimeConfigurationAdmin;
@Inject
- @Named ( value = "userManager#archiva" )
+ @Named ( value = "userManager#configurable" )
private UserManager userManager;
+ @Inject
+ private ApplicationContext applicationContext;
+
public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws ArchivaRestServiceException
{
{
// has user manager impl changed ?
boolean userManagerChanged = !StringUtils.equals( archivaRuntimeConfiguration.getUserManagerImpl(),
- archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl() );
+ archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl() );
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
if ( userManagerChanged )
}
}
+
+ public List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
+ throws ArchivaRestServiceException
+ {
+
+ Map<String, UserManager> beans = applicationContext.getBeansOfType( UserManager.class );
+
+ if ( beans.isEmpty() )
+ {
+ return Collections.emptyList();
+ }
+
+ List<UserManagerImplementationInformation> informations =
+ new ArrayList<UserManagerImplementationInformation>( beans.size() );
+
+ for ( Map.Entry<String, UserManager> entry : beans.entrySet() )
+ {
+ UserManager userManager = applicationContext.getBean( entry.getKey(), UserManager.class );
+ if ( userManager.isFinalImplementation() )
+ {
+ UserManagerImplementationInformation information = new UserManagerImplementationInformation();
+ information.setBeanId( StringUtils.substringAfter( entry.getKey(), "#" ) );
+ information.setDescriptionKey( userManager.getDescriptionKey() );
+ informations.add( information );
+ }
+ }
+
+ return informations;
+ }
}
*/
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
+import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
+import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
+import org.fest.assertions.api.Assertions;
import org.junit.Test;
+import java.util.List;
+
/**
* @author Olivier Lamy
*/
archivaRuntimeConfiguration = getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
assertEquals( "foo", archivaRuntimeConfiguration.getUserManagerImpl() );
-
}
+ @Test
+ public void usermanagersinformations()
+ throws Exception
+ {
+ ArchivaRuntimeConfigurationService service = getArchivaRuntimeConfigurationService();
+ List<UserManagerImplementationInformation> infos = service.getUserManagerImplementationInformations();
+ Assertions.assertThat( infos ).isNotNull().isNotEmpty().contains(
+ new UserManagerImplementationInformation( "jdo", null ) );
+
+ }
+
}