Class UserRestController

  • All Implemented Interfaces:
    UserRestOpenApi

    @RestController
    @RequestMapping("/v2.1.1/user-manager/")
    public class UserRestController
    extends Object
    implements UserRestOpenApi
    User Manager Rest Controller.
    Author:
    Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
    • Constructor Detail

      • UserRestController

        public UserRestController()
    • Method Detail

      • getUsers

        @RequestMapping(method=GET,
                        value="getUsers/{sessionId}",
                        produces="application/json")
        public List<UserProfile> getUsers​(@PathVariable("sessionId")
                                          String sessionId)
        Retrieves the list of all users.
        Specified by:
        getUsers in interface UserRestOpenApi
        Parameters:
        sessionId - The session token id.
        Returns:
        The list of users.
      • getGroups

        @RequestMapping(method=GET,
                        value="getGroups/{sessionId}",
                        produces="application/json")
        public List<GroupProfile> getGroups​(@PathVariable("sessionId")
                                            String sessionId)
        Retrieves the list of all groups.
        Specified by:
        getGroups in interface UserRestOpenApi
        Parameters:
        sessionId - The session token id.
        Returns:
        An array of GroupProfile.
      • getUserInSession

        @RequestMapping(method=GET,
                        value="getUserInSession/{sessionId}",
                        produces="application/json")
        public UserProfile getUserInSession​(@PathVariable("sessionId")
                                            String sessionId)
        Retrieves a user from the session ring given a session id.
        Specified by:
        getUserInSession in interface UserRestOpenApi
        Parameters:
        sessionId - The session token id.
        Returns:
        The user associated to a given session.
      • getUsersInGroup

        @RequestMapping(method=GET,
                        value="getUsersInGroup/{groupId}/{sessionId}",
                        produces="application/json")
        public List<UserProfile> getUsersInGroup​(@PathVariable("groupId")
                                                 long groupId,
                                                 @PathVariable("sessionId")
                                                 String sessionId)
        Gets all the users in a group.
        Specified by:
        getUsersInGroup in interface UserRestOpenApi
        Parameters:
        groupId - The id of the group.
        sessionId - The session token id.
        Returns:
        The list of users in that group.
      • getGroupsForUser

        @RequestMapping(method=GET,
                        value="getGroupsForUser/{userId}/{sessionId}",
                        produces="application/json")
        public List<GroupProfileLight> getGroupsForUser​(@PathVariable("userId")
                                                        long userId,
                                                        @PathVariable("sessionId")
                                                        String sessionId)
        Retrieves the list of groups a user belongs to.
        Specified by:
        getGroupsForUser in interface UserRestOpenApi
        Parameters:
        userId - The id of the user.
        sessionId - The session token id.
        Returns:
        The list of groups for this user.
      • setUserProperties

        @RequestMapping(method=PUT,
                        value="setUserProperties/{id}/{userName}/{password}/{firstName}/{lastName}/{enabled}/{type}/{email}/{sessionId}",
                        produces="application/json")
        public void setUserProperties​(@PathVariable("id")
                                      long id,
                                      @PathVariable("userName")
                                      String userName,
                                      @PathVariable("password")
                                      String password,
                                      @PathVariable("firstName")
                                      String firstName,
                                      @PathVariable("lastName")
                                      String lastName,
                                      @PathVariable("enabled")
                                      int enabled,
                                      @PathVariable("type")
                                      int type,
                                      @PathVariable("email")
                                      String email,
                                      @PathVariable("sessionId")
                                      String sessionId)
        Set the properties of a given user using the id to search for it.
        Specified by:
        setUserProperties in interface UserRestOpenApi
        Parameters:
        id - User id.
        userName - New user's name. Use null to leave it unchanged.
        password - New user's password. Use null to leave it unchanged.
        firstName - New user's first name. Use null to leave it unchanged.
        lastName - New user's last name. Use null to leave it unchanged.
        enabled - 0 for false, 1 for true, -1 to leave it unchanged.
        type - User type. See UserProfile.USER_TYPE* for possible values. Use -1 to leave it unchanged.
        email - New user's email. Use null to leave it unchanged.
        sessionId - The session token id.
      • setPrivilegeToUser

        @RequestMapping(method=PUT,
                        value="setPrivilegeToUser/{userId}/{featureToken}/{accessLevel}/{sessionId}",
                        produces="application/json")
        public void setPrivilegeToUser​(@PathVariable("userId")
                                       long userId,
                                       @PathVariable("featureToken")
                                       String featureToken,
                                       @PathVariable("accessLevel")
                                       int accessLevel,
                                       @PathVariable("sessionId")
                                       String sessionId)
        Sets a privilege to a user. If the feature token provided already has been assigned to the user, the access level will be changed, otherwise, a privilege will be created.
        Specified by:
        setPrivilegeToUser in interface UserRestOpenApi
        Parameters:
        userId - The user Id.
        featureToken - The feature token. See class Privilege for details. Note that this token must match to the one expected by the client application. That's the only way the correct features will be enabled.
        accessLevel - The feature token. See class Privilege.ACCESS_LEVEL* for details.
        sessionId - The session token id.
      • setPrivilegeToGroup

        @RequestMapping(method=PUT,
                        value="setPrivilegeToGroup/{groupId}/{featureToken}/{accessLevel}/{sessionId}",
                        produces="application/json")
        public void setPrivilegeToGroup​(@PathVariable("groupId")
                                        long groupId,
                                        @PathVariable("featureToken")
                                        String featureToken,
                                        @PathVariable("accessLevel")
                                        int accessLevel,
                                        @PathVariable("sessionId")
                                        String sessionId)
        Sets a privilege to a group. If the feature token provided already has been assigned to the group, the access level will be changed, otherwise, a privilege will be created.
        Specified by:
        setPrivilegeToGroup in interface UserRestOpenApi
        Parameters:
        groupId - The group Id.
        featureToken - The feature token. See class Privilege for details. Note that this token must match to the one expected by the client application. That's the only way the correct features will be enabled.
        accessLevel - The feature token. See class Privilege.ACCESS_LEVEL* for details.
        sessionId - The session token id.
      • setGroupProperties

        @RequestMapping(method=PUT,
                        value="setGroupProperties/{id}/{name}/{description}/{sessionId}",
                        produces="application/json")
        public void setGroupProperties​(@PathVariable("id")
                                       long id,
                                       @PathVariable("name")
                                       String name,
                                       @PathVariable("description")
                                       String description,
                                       @PathVariable("sessionId")
                                       String sessionId)
        Set the attributes of a group.
        Specified by:
        setGroupProperties in interface UserRestOpenApi
        Parameters:
        id - The id of the group.
        name - The name of the group. Use null to leave the old value.
        description - The description of the group. Use null to leave the old value.
        sessionId - The session token id.
      • createUser

        @RequestMapping(method=POST,
                        value="createUser/{userName}/{password}/{firstName}/{lastName}/{enabled}/{type}/{email}/{groupId}/{sessionId}",
                        produces="application/json")
        public long createUser​(@PathVariable("userName")
                               String userName,
                               @PathVariable("password")
                               String password,
                               @PathVariable("firstName")
                               String firstName,
                               @PathVariable("lastName")
                               String lastName,
                               @PathVariable("enabled")
                               boolean enabled,
                               @PathVariable("type")
                               int type,
                               @PathVariable("email")
                               String email,
                               @RequestBody
                               List<Privilege> privileges,
                               @PathVariable("groupId")
                               long groupId,
                               @PathVariable("sessionId")
                               String sessionId)
        Creates a user. System users ("hard-coded" kind of users used for internal tasks that can not be deleted nor modified byu the end users) can only be manipulated (that is, anything but created) by accessing directly to the database.
        Specified by:
        createUser in interface UserRestOpenApi
        Parameters:
        userName - New user's name. Mandatory.
        password - New user's password.
        firstName - New user's first name.
        lastName - New user's last name.
        enabled - Shall the new user be enabled by default.
        type - User type. See UserProfileLight.USER_TYPE_* for possible values.
        email - New user's email.
        privileges - New user's privileges.
        groupId - Default group this user will be associated to.
        sessionId - The session token id.
        Returns:
        The id of the newly created user.
      • createGroup

        @RequestMapping(method=POST,
                        value="createGroup/{name}/{description}/{users}/{sessionId}",
                        produces="application/json")
        public long createGroup​(@PathVariable("name")
                                String name,
                                @PathVariable("description")
                                String description,
                                @PathVariable("users")
                                Long[] users,
                                @PathVariable("sessionId")
                                String sessionId)
        Creates a group.
        Specified by:
        createGroup in interface UserRestOpenApi
        Parameters:
        name - The group name.
        description - The group description.
        users - Users who belong the group.
        sessionId - The session token id.
        Returns:
        The new group id.
      • addUserToGroup

        @RequestMapping(method=POST,
                        value="addUserToGroup/{userId}/{groupId}/{sessionId}",
                        produces="application/json")
        public void addUserToGroup​(@PathVariable("userId")
                                   long userId,
                                   @PathVariable("groupId")
                                   long groupId,
                                   @PathVariable("sessionId")
                                   String sessionId)
        Adds a user to a group.
        Specified by:
        addUserToGroup in interface UserRestOpenApi
        Parameters:
        userId - The id of the user to be added to the group.
        groupId - Id of the group which the user will be added to.
        sessionId - The session token id.
      • removeUserFromGroup

        @RequestMapping(method=DELETE,
                        value="removeUserFromGroup/{userId}/{groupId}/{sessionId}",
                        produces="application/json")
        public void removeUserFromGroup​(@PathVariable("userId")
                                        long userId,
                                        @PathVariable("groupId")
                                        long groupId,
                                        @PathVariable("sessionId")
                                        String sessionId)
        Removes a user from a group.
        Specified by:
        removeUserFromGroup in interface UserRestOpenApi
        Parameters:
        userId - The id of the user to be removed from the group.
        groupId - Id of the group which the user will be removed from.
        sessionId - The session token id.
      • removePrivilegeFromUser

        @RequestMapping(method=DELETE,
                        value="removePrivilegeFromUser/{userId}/{featureToken}/{sessionId}",
                        produces="application/json")
        public void removePrivilegeFromUser​(@PathVariable("userId")
                                            long userId,
                                            @PathVariable("featureToken")
                                            String featureToken,
                                            @PathVariable("sessionId")
                                            String sessionId)
        Removes a privilege from a user.
        Specified by:
        removePrivilegeFromUser in interface UserRestOpenApi
        Parameters:
        userId - Id of the user.
        featureToken - The feature token. See class Privilege for details.
        sessionId - The session token id.
      • removePrivilegeFromGroup

        @RequestMapping(method=DELETE,
                        value="removePrivilegeFromGroup/{groupId}/{featureToken}/{sessionId}",
                        produces="application/json")
        public void removePrivilegeFromGroup​(@PathVariable("groupId")
                                             long groupId,
                                             @PathVariable("featureToken")
                                             String featureToken,
                                             @PathVariable("sessionId")
                                             String sessionId)
        Removes a privilege from a group.
        Specified by:
        removePrivilegeFromGroup in interface UserRestOpenApi
        Parameters:
        groupId - Id of the group.
        featureToken - The feature token. See class Privilege for details.
        sessionId - The session token id.
      • deleteUsers

        @RequestMapping(method=DELETE,
                        value="deleteUsers/{ids}/{sessionId}",
                        produces="application/json")
        public void deleteUsers​(@PathVariable("ids")
                                Long[] ids,
                                @PathVariable("sessionId")
                                String sessionId)
        Removes a list of users.
        Specified by:
        deleteUsers in interface UserRestOpenApi
        Parameters:
        ids - The ids of the users to be deleted.
        sessionId - The session token id.
      • deleteGroups

        @RequestMapping(method=DELETE,
                        value="deleteGroups/{ids}/{sessionId}",
                        produces="application/json")
        public void deleteGroups​(@PathVariable("ids")
                                 Long[] ids,
                                 @PathVariable("sessionId")
                                 String sessionId)
        Removes a list of groups.
        Specified by:
        deleteGroups in interface UserRestOpenApi
        Parameters:
        ids - The id of the groups to delete.
        sessionId - The session token id.