Class RESTProjectUsersController
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.web.controller.api.projects.RESTProjectUsersController
-
@Controller public class RESTProjectUsersController extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
METADATA_ROLE_KEY
static java.lang.String
REL_PROJECT_USERS
Rel to get to the list of users associated with a project.static java.lang.String
USER_ID_KEY
key used in map when adding user to project.static java.lang.String
USER_ROLE_KEY
Key used in map for role when adding user to project
-
Constructor Summary
Constructors Modifier Constructor Description protected
RESTProjectUsersController()
RESTProjectUsersController(UserService userService, ProjectService projectService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseResource<LabelledRelationshipResource<Project,User>>
addUserToProject(java.lang.Long projectId, java.util.Map<java.lang.String,java.lang.String> representation, javax.servlet.http.HttpServletResponse response)
ResponseResource<ResourceCollection<User>>
getUsersForProject(java.lang.Long projectId)
Get all users associated with a project.ResponseResource<RootResource>
removeUserFromProject(java.lang.Long projectId, java.lang.String userId)
-
-
-
Field Detail
-
USER_ID_KEY
public static final java.lang.String USER_ID_KEY
key used in map when adding user to project.- See Also:
- Constant Field Values
-
USER_ROLE_KEY
public static final java.lang.String USER_ROLE_KEY
Key used in map for role when adding user to project- See Also:
- Constant Field Values
-
METADATA_ROLE_KEY
public static final java.lang.String METADATA_ROLE_KEY
- See Also:
- Constant Field Values
-
REL_PROJECT_USERS
public static final java.lang.String REL_PROJECT_USERS
Rel to get to the list of users associated with a project.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RESTProjectUsersController
protected RESTProjectUsersController()
-
RESTProjectUsersController
@Autowired public RESTProjectUsersController(UserService userService, ProjectService projectService)
-
-
Method Detail
-
getUsersForProject
@RequestMapping(value="/api/projects/{projectId}/users", method=GET) public ResponseResource<ResourceCollection<User>> getUsersForProject(@PathVariable java.lang.Long projectId) throws ProjectWithoutOwnerException
Get all users associated with a project.- Parameters:
projectId
- the project id to get users for.- Returns:
- a model with a collection of user resources.
- Throws:
ProjectWithoutOwnerException
- If removing a user will leave the project without an owner. Should NEVER be thrown in this method, but needs to be listed.
-
addUserToProject
@RequestMapping(value="/api/projects/{projectId}/users", method=POST) public ResponseResource<LabelledRelationshipResource<Project,User>> addUserToProject(@PathVariable java.lang.Long projectId, @RequestBody java.util.Map<java.lang.String,java.lang.String> representation, javax.servlet.http.HttpServletResponse response) throws ProjectWithoutOwnerException
- Parameters:
projectId
- the project ID to add the user to.representation
- the JSON key-value pair that contains the identifier for the project and the identifier for the user.response
- a reference to the servlet response.- Returns:
- a response indicating that the collection was modified.
- Throws:
ProjectWithoutOwnerException
- this cannot actually be thrown, it's an artifact of using spring HATEOASlinkTo
andmethodOn
.
-
removeUserFromProject
@RequestMapping(value="/api/projects/{projectId}/users/{userId}", method=DELETE) public ResponseResource<RootResource> removeUserFromProject(@PathVariable java.lang.Long projectId, @PathVariable java.lang.String userId) throws ProjectWithoutOwnerException
- Parameters:
projectId
- theProject
identifier to remove theUser
from.userId
- theUser
identifier to remove from theProject
.- Returns:
- a response including links back to the
Project
and theUser
collection for theProject
. - Throws:
ProjectWithoutOwnerException
- if removing this user will leave the project without an owner
-
-