Class RESTUsersController


  • @Controller
    @RequestMapping("/api/users")
    public class RESTUsersController
    extends RESTGenericController<User>
    Controller for managing users.
    • 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()
    • Method Detail

      • constructCustomResourceLinks

        protected java.util.Collection<org.springframework.hateoas.Link> constructCustomResourceLinks​(User u)
        A collection of custom links for a specific User.
        Overrides:
        constructCustomResourceLinks in class RESTGenericController<User>
        Parameters:
        u - the User to create links for.
        Returns:
        the links for this User.
      • getResource

        public ResponseResource<User> getResource​(@PathVariable
                                                  java.lang.Long identifier)
        Retrieve and serialize an individual instance of a resource by identifier.
        Overrides:
        getResource in class RESTGenericController<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 of Type in the database, then respond to the client with the location of the resource.
        Overrides:
        create in class RESTGenericController<User>
        Parameters:
        resource - the Type that we should de-serialize to get an instance of Type 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 class RESTGenericController<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 class RESTGenericController<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.