archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1413021 - in /archiva/trunk/archiva-modules/archiva-web: archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ archiva-rest/arch...
Date Fri, 23 Nov 2012 18:35:44 GMT
Author: olamy
Date: Fri Nov 23 18:35:43 2012
New Revision: 1413021

URL: http://svn.apache.org/viewvc?rev=1413021&view=rev
Log:
[MRM-1714] using LDAP can be configurable with the ui
add a rest service which return available userManager implementation.

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java?rev=1413021&r1=1413020&r2=1413021&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
Fri Nov 23 18:35:43 2012
@@ -20,6 +20,7 @@ package org.apache.archiva.rest.api.serv
 
 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;
@@ -28,6 +29,7 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
+import java.util.List;
 
 /**
  * @author Olivier Lamy
@@ -50,4 +52,11 @@ public interface ArchivaRuntimeConfigura
     @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;
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java?rev=1413021&r1=1413020&r2=1413021&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
Fri Nov 23 18:35:43 2012
@@ -22,13 +22,19 @@ import org.apache.archiva.admin.model.Re
 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
@@ -43,9 +49,12 @@ public class DefaultArchivaRuntimeConfig
     private ArchivaRuntimeConfigurationAdmin archivaRuntimeConfigurationAdmin;
 
     @Inject
-    @Named ( value = "userManager#archiva" )
+    @Named ( value = "userManager#configurable" )
     private UserManager userManager;
 
+    @Inject
+    private ApplicationContext applicationContext;
+
     public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
         throws ArchivaRestServiceException
     {
@@ -66,7 +75,7 @@ public class DefaultArchivaRuntimeConfig
         {
             // has user manager impl changed ?
             boolean userManagerChanged = !StringUtils.equals( archivaRuntimeConfiguration.getUserManagerImpl(),
-                                                             archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl()
);
+                                                              archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl()
);
             archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration
);
 
             if ( userManagerChanged )
@@ -84,6 +93,35 @@ public class DefaultArchivaRuntimeConfig
         }
 
     }
+
+    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;
+    }
 }
 
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java?rev=1413021&r1=1413020&r2=1413021&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
Fri Nov 23 18:35:43 2012
@@ -19,8 +19,13 @@ package org.apache.archiva.rest.services
  */
 
 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
  */
@@ -51,8 +56,18 @@ public class ArchivaRuntimeConfiguration
         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 ) );
+
+    }
+
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java?rev=1413021&r1=1413020&r2=1413021&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java
Fri Nov 23 18:35:43 2012
@@ -29,6 +29,7 @@ import javax.inject.Inject;
 
 /**
  * @author Olivier Lamy
+ * @since 1.4-M4
  */
 @Service ( "userManager#archiva" )
 public class ArchivaConfigurableUsersManager
@@ -60,4 +61,9 @@ public class ArchivaConfigurableUsersMan
             throw new RuntimeException( e.getMessage(), e );
         }
     }
+
+    public String getDescriptionKey()
+    {
+        return "archiva.redback.usermanager.configurable.archiva";
+    }
 }



Mime
View raw message