use a bulk update mode with passing a list of update
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1476986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
88610b6e15
commit
3d0d471254
|
@ -21,6 +21,7 @@ package org.apache.archiva.redback.rest.api.services;
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
|||
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 DefaultLdapGroupMappingService
|
|||
private LdapRoleMapper ldapRoleMapper;
|
||||
|
||||
@Inject
|
||||
@Named( value = "ldapRoleMapperConfiguration#default" )
|
||||
@Named(value = "ldapRoleMapperConfiguration#default")
|
||||
private LdapRoleMapperConfiguration ldapRoleMapperConfiguration;
|
||||
|
||||
@Inject
|
||||
|
@ -146,13 +147,16 @@ public class DefaultLdapGroupMappingService
|
|||
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 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue