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.authorization.RedbackAuthorization;
|
||||||
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
|
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.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.model.StringList;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
|
@ -39,44 +40,44 @@ import java.util.List;
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
@Path( "/ldapGroupMappingService/" )
|
@Path("/ldapGroupMappingService/")
|
||||||
public interface LdapGroupMappingService
|
public interface LdapGroupMappingService
|
||||||
{
|
{
|
||||||
@Path( "ldapGroups" )
|
@Path("ldapGroups")
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@RedbackAuthorization( permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
|
@RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
|
||||||
StringList getLdapGroups()
|
StringList getLdapGroups()
|
||||||
throws RedbackServiceException;
|
throws RedbackServiceException;
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@RedbackAuthorization( permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
|
@RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
|
||||||
List<LdapGroupMapping> getLdapGroupMappings()
|
List<LdapGroupMapping> getLdapGroupMappings()
|
||||||
throws RedbackServiceException;
|
throws RedbackServiceException;
|
||||||
|
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@RedbackAuthorization( permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
|
@RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
|
||||||
Boolean addLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
|
Boolean addLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
|
||||||
throws RedbackServiceException;
|
throws RedbackServiceException;
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path( "{group}" )
|
@Path("{group}")
|
||||||
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@RedbackAuthorization( permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
|
@RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
|
||||||
Boolean removeLdapGroupMapping( @PathParam( "group" ) String group )
|
Boolean removeLdapGroupMapping( @PathParam("group") String group )
|
||||||
throws RedbackServiceException;
|
throws RedbackServiceException;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@RedbackAuthorization( permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION )
|
@RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION)
|
||||||
Boolean updateLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
|
Boolean updateLdapGroupMapping( LdapGroupMappingUpdateRequest ldapGroupMappingUpdateRequest )
|
||||||
throws RedbackServiceException;
|
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.LdapRoleMapper;
|
||||||
import org.apache.archiva.redback.common.ldap.role.LdapRoleMapperConfiguration;
|
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.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.model.StringList;
|
||||||
import org.apache.archiva.redback.rest.api.services.LdapGroupMappingService;
|
import org.apache.archiva.redback.rest.api.services.LdapGroupMappingService;
|
||||||
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
|
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
|
||||||
|
@ -56,7 +57,7 @@ public class DefaultLdapGroupMappingService
|
||||||
private LdapRoleMapper ldapRoleMapper;
|
private LdapRoleMapper ldapRoleMapper;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named( value = "ldapRoleMapperConfiguration#default" )
|
@Named(value = "ldapRoleMapperConfiguration#default")
|
||||||
private LdapRoleMapperConfiguration ldapRoleMapperConfiguration;
|
private LdapRoleMapperConfiguration ldapRoleMapperConfiguration;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -146,13 +147,16 @@ public class DefaultLdapGroupMappingService
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean updateLdapGroupMapping( LdapGroupMapping ldapGroupMapping )
|
public Boolean updateLdapGroupMapping( LdapGroupMappingUpdateRequest ldapGroupMappingUpdateRequest )
|
||||||
throws RedbackServiceException
|
throws RedbackServiceException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ldapRoleMapperConfiguration.updateLdapMapping( ldapGroupMapping.getGroup(),
|
for ( LdapGroupMapping ldapGroupMapping : ldapGroupMappingUpdateRequest.getLdapGroupMapping() )
|
||||||
new ArrayList( ldapGroupMapping.getRoleNames() ) );
|
{
|
||||||
|
ldapRoleMapperConfiguration.updateLdapMapping( ldapGroupMapping.getGroup(),
|
||||||
|
new ArrayList( ldapGroupMapping.getRoleNames() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( MappingException e )
|
catch ( MappingException e )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue