Class DefaultRoleService
- java.lang.Object
-
- org.apache.archiva.redback.rest.services.v2.BaseRedbackService
-
- org.apache.archiva.redback.rest.services.v2.DefaultRoleService
-
- All Implemented Interfaces:
RoleService
@Service("v2.roleService#rest") public class DefaultRoleService extends BaseRedbackService implements RoleService
- Since:
- 1.3
- Author:
- Olivier Lamy
-
-
Field Summary
-
Fields inherited from class org.apache.archiva.redback.rest.services.v2.BaseRedbackService
rbacManager, USER_FILTER_MAP, USER_ORDER_MAP, USER_QUERY_HELPER, userManager
-
-
Constructor Summary
Constructors Constructor Description DefaultRoleService(RoleManager roleManager, RBACManager rbacManager, UserManager userManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RoleInfo
assignRole(String roleId, String userId)
Assigns the role indicated by the roleId to the given principalRoleInfo
assignTemplatedRole(String templateId, String resource, String userId)
Assigns the templated role indicated by the templateId fails if the templated role has not been createdjavax.ws.rs.core.Response
checkRole(String roleId)
javax.ws.rs.core.Response
checkTemplateRole(String templateId, String resource)
RoleInfo
createTemplatedRole(String templateId, String resource)
RoleInfo
deleteRoleAssignment(String roleId, String userId)
Deletes the assignment of a role to a user.org.apache.archiva.components.rest.model.PagedResult<RoleInfo>
getAllRoles(String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order)
RoleInfo
getRole(String roleId)
org.apache.archiva.components.rest.model.PagedResult<UserInfo>
getRoleUsers(String roleId, String recurse, String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order)
This returns the list of assigned users to a given role.List<RoleTemplate>
getTemplates()
org.apache.archiva.components.rest.model.PagedResult<UserInfo>
getUnassignedUsers(String roleId, String recurse, String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order)
RoleInfo
moveTemplatedRole(String templateId, String oldResource, String newResource)
Moves a templated role from one resource to another resourcejavax.ws.rs.core.Response
removeTemplatedRole(String templateId, String resource)
Removes a role corresponding to the role Id that was manufactured with the given resource it also removes any user assignments for that roleRoleInfo
updateRole(String roleId, Role role)
Updates a role.-
Methods inherited from class org.apache.archiva.redback.rest.services.v2.BaseRedbackService
getAssignedRedbackUsers, getAssignedRedbackUsersRecursive, getAssignedUsersRecursive, getChildRoles, getParentRoles, getRedbackUser, getRestUser, getRoleInfo, getRoleInfoOptional, getUserInfoPagedResult, isAscending
-
-
-
-
Constructor Detail
-
DefaultRoleService
@Inject public DefaultRoleService(RoleManager roleManager, @Named("rbacManager#default") RBACManager rbacManager, @Named("userManager#default") UserManager userManager)
-
-
Method Detail
-
getAllRoles
public org.apache.archiva.components.rest.model.PagedResult<RoleInfo> getAllRoles(String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order) throws RedbackServiceException
- Specified by:
getAllRoles
in interfaceRoleService
- Throws:
RedbackServiceException
-
getRole
public RoleInfo getRole(String roleId) throws RedbackServiceException
- Specified by:
getRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
checkRole
public javax.ws.rs.core.Response checkRole(String roleId) throws RedbackServiceException
- Specified by:
checkRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
moveTemplatedRole
public RoleInfo moveTemplatedRole(String templateId, String oldResource, String newResource) throws RedbackServiceException
Description copied from interface:RoleService
Moves a templated role from one resource to another resource- Specified by:
moveTemplatedRole
in interfaceRoleService
- Parameters:
templateId
- the template identifieroldResource
- the resource of the current rolenewResource
- the resource of the new role- Throws:
RedbackServiceException
-
checkTemplateRole
public javax.ws.rs.core.Response checkTemplateRole(String templateId, String resource) throws RedbackServiceException
- Specified by:
checkTemplateRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
createTemplatedRole
public RoleInfo createTemplatedRole(String templateId, String resource) throws RedbackServiceException
- Specified by:
createTemplatedRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
removeTemplatedRole
public javax.ws.rs.core.Response removeTemplatedRole(String templateId, String resource) throws RedbackServiceException
Description copied from interface:RoleService
Removes a role corresponding to the role Id that was manufactured with the given resource it also removes any user assignments for that role- Specified by:
removeTemplatedRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
assignRole
public RoleInfo assignRole(String roleId, String userId) throws RedbackServiceException
Description copied from interface:RoleService
Assigns the role indicated by the roleId to the given principal- Specified by:
assignRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
assignTemplatedRole
public RoleInfo assignTemplatedRole(String templateId, String resource, String userId) throws RedbackServiceException
Description copied from interface:RoleService
Assigns the templated role indicated by the templateId fails if the templated role has not been created- Specified by:
assignTemplatedRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
deleteRoleAssignment
public RoleInfo deleteRoleAssignment(String roleId, String userId) throws RedbackServiceException
Description copied from interface:RoleService
Deletes the assignment of a role to a user.- Specified by:
deleteRoleAssignment
in interfaceRoleService
- Parameters:
roleId
- the role iduserId
- the user id- Throws:
RedbackServiceException
-
getRoleUsers
public org.apache.archiva.components.rest.model.PagedResult<UserInfo> getRoleUsers(String roleId, String recurse, String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order) throws RedbackServiceException
Description copied from interface:RoleService
This returns the list of assigned users to a given role. The flag "recurse" is a query parameter. If the query parameter exists and is not set to 'false', or '0', it will recurse all parent roles and return a list of users assigned to the current role and the parent roles up to the root. If the query parameter does not exist or is set to 'false' or '0', it will return only the users assigned directly to the given role.- Specified by:
getRoleUsers
in interfaceRoleService
- Parameters:
roleId
- the role identifier, for which the assigned users are returnedrecurse
- if the parameter does not exist or is set to 'false' or '0', only directly assigned users are returned. If the parameter value is set to 'parentsOnly', the users assigned to all parent roles up to the root excluding the given role are returned. Otherwise all users assigned to the given role and all parent roles up to the root are returned.searchTerm
- the substring query term to search for in the user ids and namesoffset
- the offset index in the user list for paginglimit
- the maximum number of users returnedorderBy
- the order attributes for orderingorder
- the order direction 'asc' (ascending), or 'desc' (descending)- Returns:
- the list of user objects
- Throws:
RedbackServiceException
-
getUnassignedUsers
public org.apache.archiva.components.rest.model.PagedResult<UserInfo> getUnassignedUsers(String roleId, String recurse, String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order) throws RedbackServiceException
- Specified by:
getUnassignedUsers
in interfaceRoleService
- Throws:
RedbackServiceException
-
updateRole
public RoleInfo updateRole(String roleId, Role role) throws RedbackServiceException
Description copied from interface:RoleService
Updates a role. Attributes that are empty or null will be ignored.- Specified by:
updateRole
in interfaceRoleService
- Throws:
RedbackServiceException
-
getTemplates
public List<RoleTemplate> getTemplates() throws RedbackServiceException
- Specified by:
getTemplates
in interfaceRoleService
- Throws:
RedbackServiceException
-
-