Author: olamy
Date: Mon Apr 29 12:21:03 2013
New Revision: 1476986

URL: http://svn.apache.org/r1476986
Log:
use a bulk update mode with passing a list of update

Modified:
    
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java
    
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java

Modified: 
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java?rev=1476986&r1=1476985&r2=1476986&view=diff
==============================================================================
--- 
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java
 (original)
+++ 
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java
 Mon Apr 29 12:21:03 2013
@@ -21,6 +21,7 @@ package org.apache.archiva.redback.rest.
 import org.apache.archiva.redback.authorization.RedbackAuthorization;
 import 
org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
 import org.apache.archiva.redback.rest.api.model.LdapGroupMapping;
+import org.apache.archiva.redback.rest.api.model.LdapGroupMappingUpdateRequest;
 import org.apache.archiva.redback.rest.api.model.StringList;
 
 import javax.ws.rs.Consumes;
@@ -39,44 +40,44 @@ import java.util.List;
  * @author Olivier Lamy
  * @since 2.1
  */
-@Path( "/ldapGroupMappingService/" )
+@Path("/ldapGroupMappingService/")
 public interface LdapGroupMappingService
 {
-    @Path( "ldapGroups" )
+    @Path("ldapGroups")
     @GET
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @RedbackAuthorization( permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
     StringList getLdapGroups()
         throws RedbackServiceException;
 
 
     @GET
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @RedbackAuthorization( permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
     List<LdapGroupMapping> getLdapGroupMappings()
         throws RedbackServiceException;
 
 
     @PUT
-    @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @RedbackAuthorization( permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
+    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
     Boolean addLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
         throws RedbackServiceException;
 
     @DELETE
-    @Path( "{group}" )
-    @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @RedbackAuthorization( permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
-    Boolean removeLdapGroupMapping( @PathParam( "group" ) String group )
+    @Path("{group}")
+    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
+    Boolean removeLdapGroupMapping( @PathParam("group") String group )
         throws RedbackServiceException;
 
     @POST
-    @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    @RedbackAuthorization( permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
-    Boolean updateLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
+    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @RedbackAuthorization(permissions = 
RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
+    Boolean updateLdapGroupMapping( LdapGroupMappingUpdateRequest 
ldapGroupMappingUpdateRequest )
         throws RedbackServiceException;
 
 }

Modified: 
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java?rev=1476986&r1=1476985&r2=1476986&view=diff
==============================================================================
--- 
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java
 (original)
+++ 
archiva/redback/redback-core/trunk/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java
 Mon Apr 29 12:21:03 2013
@@ -25,6 +25,7 @@ import org.apache.archiva.redback.common
 import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper;
 import org.apache.archiva.redback.common.ldap.role.LdapRoleMapperConfiguration;
 import org.apache.archiva.redback.rest.api.model.LdapGroupMapping;
+import org.apache.archiva.redback.rest.api.model.LdapGroupMappingUpdateRequest;
 import org.apache.archiva.redback.rest.api.model.StringList;
 import org.apache.archiva.redback.rest.api.services.LdapGroupMappingService;
 import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
@@ -56,7 +57,7 @@ public class DefaultLdapGroupMappingServ
     private LdapRoleMapper ldapRoleMapper;
 
     @Inject
-    @Named( value = "ldapRoleMapperConfiguration#default" )
+    @Named(value = "ldapRoleMapperConfiguration#default")
     private LdapRoleMapperConfiguration ldapRoleMapperConfiguration;
 
     @Inject
@@ -146,13 +147,16 @@ public class DefaultLdapGroupMappingServ
         return Boolean.TRUE;
     }
 
-    public Boolean updateLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
+    public Boolean updateLdapGroupMapping( LdapGroupMappingUpdateRequest 
ldapGroupMappingUpdateRequest )
         throws RedbackServiceException
     {
         try
         {
-            ldapRoleMapperConfiguration.updateLdapMapping( 
ldapGroupMapping.getGroup(),
-                                                           new ArrayList( 
ldapGroupMapping.getRoleNames() ) );
+            for ( LdapGroupMapping ldapGroupMapping : 
ldapGroupMappingUpdateRequest.getLdapGroupMapping() )
+            {
+                ldapRoleMapperConfiguration.updateLdapMapping( 
ldapGroupMapping.getGroup(),
+                                                               new ArrayList( 
ldapGroupMapping.getRoleNames() ) );
+            }
         }
         catch ( MappingException e )
         {


Reply via email to