Class RESTUsersController
- java.lang.Object
-
- ca.corefacility.bioinformatics.irida.web.controller.api.RESTGenericController<User>
-
- ca.corefacility.bioinformatics.irida.web.controller.api.RESTUsersController
-
@Controller @RequestMapping("/api/users") public class RESTUsersController extends RESTGenericController<User>
Controller for managing users.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REL_USER_PROJECTS
a rel for getting a handle on the projects that a user belongs to.static java.lang.String
USER_PROJECTS_MAP_LABEL
a map label for the projects associated with a user.-
Fields inherited from class ca.corefacility.bioinformatics.irida.web.controller.api.RESTGenericController
crudService, REL_COLLECTION, REL_RELATIONSHIP, RELATED_RESOURCES_NAME, RESOURCE_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RESTUsersController()
RESTUsersController(UserService userService, ProjectService projectService)
Constructor, requires a reference to aUserService
and aProjectService
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<org.springframework.hateoas.Link>
constructCustomResourceLinks(User u)
A collection of custom links for a specificUser
.ResponseResource<User>
create(User resource, javax.servlet.http.HttpServletResponse response)
Create a new instance ofType
in the database, then respond to the client with the location of the resource.ResponseResource<RootResource>
delete(java.lang.Long identifier)
Delete the instance of the resource identified by a specific identifier.ResponseResource<User>
getCurrentUser()
Get the user account that is currently logged in.ResponseResource<User>
getResource(java.lang.Long identifier)
Retrieve and serialize an individual instance of a resource by identifier.ResponseProjectResource<ResourceCollection<Project>>
getUserProjects(java.lang.String username)
Get the collection of projects for a specific user.ResponseResource<ResourceCollection<User>>
listAllResources()
Get all resources in the application.ResponseResource<RootResource>
update(java.lang.Long identifier, java.util.Map<java.lang.String,java.lang.Object> representation)
Update some of the fields of an individual resource in the database.-
Methods inherited from class ca.corefacility.bioinformatics.irida.web.controller.api.RESTGenericController
constructCollectionResourceLinks
-
-
-
-
Field Detail
-
REL_USER_PROJECTS
public static final java.lang.String REL_USER_PROJECTS
a rel for getting a handle on the projects that a user belongs to.- See Also:
- Constant Field Values
-
USER_PROJECTS_MAP_LABEL
public static final java.lang.String USER_PROJECTS_MAP_LABEL
a map label for the projects associated with a user.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RESTUsersController
protected RESTUsersController()
-
RESTUsersController
@Autowired public RESTUsersController(UserService userService, ProjectService projectService)
Constructor, requires a reference to aUserService
and aProjectService
.- Parameters:
userService
- theUserService
that this controller uses.projectService
- theProjectService
that this controller uses.
-
-
Method Detail
-
constructCustomResourceLinks
protected java.util.Collection<org.springframework.hateoas.Link> constructCustomResourceLinks(User u)
A collection of custom links for a specificUser
.- Overrides:
constructCustomResourceLinks
in classRESTGenericController<User>
- Parameters:
u
- theUser
to create links for.- Returns:
- the links for this
User
.
-
listAllResources
public ResponseResource<ResourceCollection<User>> listAllResources()
Get all resources in the application.- Overrides:
listAllResources
in classRESTGenericController<User>
- Returns:
- a model containing all resources of the specified type in the application.
-
getResource
public ResponseResource<User> getResource(@PathVariable java.lang.Long identifier)
Retrieve and serialize an individual instance of a resource by identifier.- Overrides:
getResource
in classRESTGenericController<User>
- Parameters:
identifier
- the identifier of the resource to retrieve from the database.- Returns:
- the model and view for the individual resource.
-
create
public ResponseResource<User> create(@RequestBody User resource, javax.servlet.http.HttpServletResponse response)
Create a new instance ofType
in the database, then respond to the client with the location of the resource.- Overrides:
create
in classRESTGenericController<User>
- Parameters:
resource
- theType
that we should de-serialize to get an instance ofType
to persist.response
- a reference to the servlet response.- Returns:
- a response containing the location of the newly persisted resource.
-
delete
public ResponseResource<RootResource> delete(@PathVariable java.lang.Long identifier)
Delete the instance of the resource identified by a specific identifier.- Overrides:
delete
in classRESTGenericController<User>
- Parameters:
identifier
- the identifier that should be deleted from the database.- Returns:
- a response indicating that the resource was deleted.
-
update
public ResponseResource<RootResource> update(@PathVariable java.lang.Long identifier, @RequestBody java.util.Map<java.lang.String,java.lang.Object> representation)
Update some of the fields of an individual resource in the database. The client should only send the key-value pairs for the properties that are to be updated in the database.- Overrides:
update
in classRESTGenericController<User>
- Parameters:
identifier
- the identifier of the resource to be updated.representation
- the properties to be updated and their new values.- Returns:
- a response indicating that the resource was updated.
-
getUserProjects
@RequestMapping(value="/{username}/projects", method=GET) public ResponseProjectResource<ResourceCollection<Project>> getUserProjects(@PathVariable java.lang.String username)
Get the collection of projects for a specific user.- Parameters:
username
- the username for the desired user.- Returns:
- a model containing the collection of projects for that user.
-
getCurrentUser
@RequestMapping(value="/current", method=GET) public ResponseResource<User> getCurrentUser()
Get the user account that is currently logged in. This is here so that a user interface client to the REST API can display more details about the current user than just username. This endpoint is *not* documented in the REST API.- Returns:
- a representation of the currently logged in user.
-
-