Class UserController

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ROLE_PARAM  
    • Constructor Summary

      Constructors 
      Constructor Description
      UserController()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String changeCurrentUserPassword​(java.lang.String oldPassword, java.lang.String newPassword, java.security.Principal principal)
      Update User password.
      RoleDto createRole​(@Valid RoleDto roleDto, org.springframework.validation.BindingResult bindingResult)
      Create Role from given dto.
      UserDto createUser​(@Valid UserDto userDto, org.springframework.validation.BindingResult bindingResult)
      Create User.
      java.util.List<PermissionDto> getPermissions()
      Get list of permissions.
      RoleDto getRole​(java.util.UUID id)
      Get UserRole with given id.
      java.util.List<RoleDto> getRoles()
      Get list of roles.
      UserDto getUser​(java.util.UUID id)
      Get User with given id.
      UserProfileDto getUserProfile​(java.security.Principal principal)
      Get info about current logged-in User.
      java.util.List<UserDto> getUsers()
      Get list of users.
      RoleDto saveRole​(java.util.UUID id, @Valid RoleDto roleDto, org.springframework.validation.BindingResult bindingResult)
      Update UserRole from given dto.
      UserDto saveUser​(java.util.UUID id, @Valid UserDto userDto, org.springframework.validation.BindingResult bindingResult)
      Update User.
      UserProfileDto saveUserProfile​(java.util.UUID id, @Valid UserProfileDto userProfileDto, org.springframework.validation.BindingResult bindingResult)
      Update profile information about User.
      org.springframework.data.domain.Page<RoleDto> searchRoles​(java.lang.String name, org.springframework.data.domain.Pageable pageable)
      Finds roles matching all of the provided parameters.
      org.springframework.data.domain.Page<UserDto> searchUsers​(java.lang.String username, java.lang.String email, java.lang.String name, java.lang.String role, org.springframework.data.domain.Pageable pageable)
      Finds users matching all of the provided parameters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UserController

        public UserController()
    • Method Detail

      • getUsers

        @RequestMapping(value="/user",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public java.util.List<UserDto> getUsers()
        Get list of users.
        Returns:
        list of all users
      • searchUsers

        @RequestMapping(value="/user/search",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public org.springframework.data.domain.Page<UserDto> searchUsers​(@RequestParam(value="username",required=false)
                                                                         java.lang.String username,
                                                                         @RequestParam(value="email",required=false)
                                                                         java.lang.String email,
                                                                         @RequestParam(value="name",required=false)
                                                                         java.lang.String name,
                                                                         @RequestParam(value="role",required=false)
                                                                         java.lang.String role,
                                                                         org.springframework.data.domain.Pageable pageable)
        Finds users matching all of the provided parameters. If there are no parameters, return all users.
        Parameters:
        pageable - pagination parameters (page size, page number, sort order)
        name - name of a user
        email - email of a user
        role - name of role of a user
        username - username of user
        Returns:
        page with found users
      • getUser

        @RequestMapping(value="/user/{id}",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public UserDto getUser​(@PathVariable("id")
                               java.util.UUID id)
        Get User with given id.
        Parameters:
        id - id of User to find
        Returns:
        User with given id
      • createUser

        @RequestMapping(value="/user",
                        method=POST)
        @ResponseStatus(CREATED)
        @ResponseBody
        public UserDto createUser​(@RequestBody @Valid
                                  @Valid UserDto userDto,
                                  org.springframework.validation.BindingResult bindingResult)
        Create User.
        Parameters:
        userDto - DTO of User to be created
        bindingResult - spring object used for validation
        Returns:
        created User
      • saveUser

        @RequestMapping(value="/user/{id}",
                        method=PUT)
        @ResponseStatus(OK)
        @ResponseBody
        public UserDto saveUser​(@PathVariable("id")
                                java.util.UUID id,
                                @RequestBody @Valid
                                @Valid UserDto userDto,
                                org.springframework.validation.BindingResult bindingResult)
        Update User.
        Parameters:
        id - id of User to update
        userDto - DTO of User to be updated
        bindingResult - spring object used for validation
        Returns:
        updated User
      • changeCurrentUserPassword

        @RequestMapping(value="/user/passwordchange",
                        method=POST)
        @ResponseStatus(OK)
        @ResponseBody
        public java.lang.String changeCurrentUserPassword​(@RequestParam("oldPassword")
                                                          java.lang.String oldPassword,
                                                          @RequestParam("newPassword")
                                                          java.lang.String newPassword,
                                                          java.security.Principal principal)
        Update User password.
        Parameters:
        oldPassword - user previous password, should be the same as current password
        newPassword - user's new password
        principal - java security object
        Returns:
        success message
      • saveUserProfile

        @RequestMapping(value="/user/profile/{id}",
                        method=PUT)
        @ResponseStatus(OK)
        @ResponseBody
        public UserProfileDto saveUserProfile​(@PathVariable("id")
                                              java.util.UUID id,
                                              @RequestBody @Valid
                                              @Valid UserProfileDto userProfileDto,
                                              org.springframework.validation.BindingResult bindingResult)
        Update profile information about User.
        Parameters:
        id - id of User to update Profile
        userProfileDto - DTO of User Profile to be updated
        bindingResult - spring object used for validation
        Returns:
        updated User Profile
      • getUserProfile

        @RequestMapping(value="/user/profile",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public UserProfileDto getUserProfile​(java.security.Principal principal)
        Get info about current logged-in User.
        Parameters:
        principal - java security object
        Returns:
        dto of user profile
      • getRoles

        @RequestMapping(value="/role",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public java.util.List<RoleDto> getRoles()
        Get list of roles.
        Returns:
        list of all roles
      • getPermissions

        @RequestMapping(value="/permission",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public java.util.List<PermissionDto> getPermissions()
        Get list of permissions.
        Returns:
        list of all permissions
      • getRole

        @RequestMapping(value="/role/{id}",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public RoleDto getRole​(@PathVariable("id")
                               java.util.UUID id)
        Get UserRole with given id.
        Parameters:
        id - id of Role to find
        Returns:
        Role with given id
      • searchRoles

        @RequestMapping(value="/role/search",
                        method=GET)
        @ResponseStatus(OK)
        @ResponseBody
        public org.springframework.data.domain.Page<RoleDto> searchRoles​(@RequestParam(value="name",required=false)
                                                                         java.lang.String name,
                                                                         org.springframework.data.domain.Pageable pageable)
        Finds roles matching all of the provided parameters. If there are no parameters, return all roles.
        Parameters:
        name - name of the role
        pageable - pagination parameters (page size, page number, sort order)
        Returns:
        page with roles matching provided parameters
      • createRole

        @RequestMapping(value="/role",
                        method=POST)
        @ResponseStatus(OK)
        @ResponseBody
        public RoleDto createRole​(@RequestBody @Valid
                                  @Valid RoleDto roleDto,
                                  org.springframework.validation.BindingResult bindingResult)
        Create Role from given dto.
        Parameters:
        roleDto - DTO of Role to be created
        bindingResult - spring object used for validation
        Returns:
        created Role
      • saveRole

        @RequestMapping(value="/role/{id}",
                        method=PUT)
        @ResponseStatus(OK)
        @ResponseBody
        public RoleDto saveRole​(@PathVariable("id")
                                java.util.UUID id,
                                @RequestBody @Valid
                                @Valid RoleDto roleDto,
                                org.springframework.validation.BindingResult bindingResult)
        Update UserRole from given dto.
        Parameters:
        id - id of Role to update
        roleDto - DTO of Role to be updated
        bindingResult - spring object used for validation
        Returns:
        updated Role