Class RoleController


  • @RestController
    @RequestMapping("/roles")
    public class RoleController
    extends java.lang.Object
    The entry point for clients to access role data
    • Constructor Detail

      • RoleController

        public RoleController()
    • Method Detail

      • getAllRoles

        @GetMapping(value="/roles",
                    produces="application/json")
        public org.springframework.http.ResponseEntity<?> getAllRoles()
        List of all roles
        Example: http://localhost:2019/roles/roles
        Returns:
        JSON List of all the roles and their associated users
        See Also:
        RoleService.findAll()
      • getRoleById

        @GetMapping(value="/role/{roleid}",
                    produces="application/json")
        public org.springframework.http.ResponseEntity<?> getRoleById​(@PathVariable
                                                                      long roleid)
        The Role referenced by the given primary key
        Example: http://localhost:2019/roles/role/2
        Parameters:
        roleid - The primary key (long) of the role you seek
        Returns:
        JSON object of the role you seek
        See Also:
        RoleService.findRoleById(long)
      • getRoleByName

        @GetMapping(value="/role/name/{rolename}",
                    produces="application/json")
        public org.springframework.http.ResponseEntity<?> getRoleByName​(@PathVariable
                                                                        java.lang.String rolename)
        The Role with the given name
        Example: http://localhost:2019/roles/role/name/data
        Parameters:
        rolename - The name of the role you seek
        Returns:
        JSON object of the role you seek
        See Also:
        RoleService.findRoleByName(String)
      • addNewRole

        @PostMapping(value="/role",
                     consumes="application/json")
        public org.springframework.http.ResponseEntity<?> addNewRole​(@Valid @RequestBody
                                                                     @Valid Role newRole)
        Given a complete Role object, create a new Role record
        Example: http://localhost:2019/roles/role
        Parameters:
        newRole - A complete new Role object
        Returns:
        A location header with the URI to the newly created role and a status of CREATED
        See Also:
        RoleService.save(Role)
      • updateRole

        @PutMapping(value="/role/{roleid}",
                    consumes="application/json")
        public org.springframework.http.ResponseEntity<?> updateRole​(@Valid @RequestBody
                                                                     @Valid Role updateRole,
                                                                     @PathVariable
                                                                     long roleid)
        The process allows you to update a role name only!
        Example: http://localhost:2019/roles/role/1
        Parameters:
        roleid - The primary key (long) of the role you wish to update
        updateRole - The new name (String) for the role
        Returns:
        Status of OK
        See Also:
        RoleService.update(Role, long)
      • deleteRoleById

        @DeleteMapping(value="/role/{roleid}",
                       produces="application/json")
        public org.springframework.http.ResponseEntity<?> deleteRoleById​(@PathVariable
                                                                         long roleid)
        Deletes a given role
        Example: http://localhost:2019/roles/role/3
        Parameters:
        roleid - the primary key of the role you wish to delete
        Returns:
        Status of OK
        See Also:
        RoleService.delete(long)