Package com.inesm.KeyManager.controller
Class RolesController
java.lang.Object
com.inesm.KeyManager.controller.Controller
com.inesm.KeyManager.controller.RolesController
@RestController
@CrossOrigin("http://localhost:4200")
@RequestMapping("/roles")
public class RolesController
extends Controller
REST Controller for the roles endpoint.
-
Constructor Summary
ConstructorsConstructorDescriptionRolesController(UserManager userManager, AppInterface appInterface, SessionService session, LoggerService logger) Constructor for RolesController class. -
Method Summary
Modifier and TypeMethodDescriptioncreateRole(javax.servlet.http.HttpServletRequest request) Creates a role in the station.voiddeleteRole(javax.servlet.http.HttpServletRequest request) Deletes a role from the station.getRoles()Gets all roles inside a the station.Gets all operations offered by the station.updateRole(javax.servlet.http.HttpServletRequest request) Updates a role in the station.
-
Constructor Details
-
RolesController
@Autowired public RolesController(UserManager userManager, AppInterface appInterface, SessionService session, LoggerService logger) Constructor for RolesController class.- Parameters:
session- the session service to be useduserManager- the user manager to be usedappInterface- the class that defines the interface between java and json objectslogger- the logger service
-
-
Method Details
-
getRoles
@PostMapping(path="list", produces="application/json;charset=UTF-8") public String getRoles() throws SessionTimeoutException, PermissionDeniedExceptionGets all roles inside a the station.- Returns:
- the roles as string in a JSON array format
- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operation
-
createRole
@PostMapping(path="create", produces="application/json;charset=UTF-8") public String createRole(javax.servlet.http.HttpServletRequest request) throws SessionTimeoutException, RequestReadException, JsonBadSintaxException, PermissionDeniedException, InvalidParametersException Creates a role in the station.- Parameters:
request- the HTTP request received, containing a role object in JSON format- Returns:
- the created role object as string in JSON format
- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are provided
-
updateRole
@PostMapping(path="update", produces="application/json;charset=UTF-8") public String updateRole(javax.servlet.http.HttpServletRequest request) throws SessionTimeoutException, PermissionDeniedException, RequestReadException, JsonBadSintaxException, ObjectNotFoundException, ResourceLockedException, InvalidParametersException Updates a role in the station.- Parameters:
request- the HTTP request received, containing a role object in JSON format, with the roleID field set- Returns:
- the updated role object as string in JSON format
- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestInvalidParametersException- 400 | Invalid Parameters | If there are invalid fields for the resource are providedObjectNotFoundException- 400 | Object Not Found | If the requested resource was not found.ResourceLockedException- 400 | ResourceLocked | If the update is on the default admin role, which is not allowed to be modified
-
deleteRole
@PostMapping(path="delete", produces="application/json;charset=UTF-8") public void deleteRole(javax.servlet.http.HttpServletRequest request) throws SessionTimeoutException, PermissionDeniedException, RequestReadException, JsonBadSintaxException, RoleCurrentlyAssignedException, ObjectNotFoundException, ResourceLockedException Deletes a role from the station.- Parameters:
request- the HTTP request received, containing a role object in JSON format, with the roleID set- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operationJsonBadSintaxException- 400 | Invalid Payload | If the JSON received contained incorrect syntax or mission fieldsRequestReadException- 500 | Couldn't Read Request Body | If the application could not retrieve the request body of the HTTP requestObjectNotFoundException- 400 | Object Not Found | If the requested resource was not found.ResourceLockedException- 400 | ResourceLocked | If the update is on the default admin role, which is not allowed to be deletedRoleCurrentlyAssignedException- 400 | Role in use | If the role is currently assigned to any use, and can't be deleted.
-
listOperations
@PostMapping(path="/operations/list") public String listOperations() throws SessionTimeoutException, PermissionDeniedExceptionGets all operations offered by the station.- Returns:
- the list of all operation as a string in a JSON array format
- Throws:
SessionTimeoutException- 401 | Session Timeout | If the session timed outPermissionDeniedException- 403 | Permission Denied | If the user is not authorized to access this operation
-