Package org.trustdeck.controller
Class ProjectRESTController
java.lang.Object
org.trustdeck.controller.ProjectRESTController
@RestController
@EnableMethodSecurity
@RequestMapping("/api")
public class ProjectRESTController
extends Object
This class offers REST API endpoints for interacting with project entities.
- Author:
- Armin Müller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?> createProject(ProjectDTO projectDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to create a new project.org.springframework.http.ResponseEntity<?> deleteProject(String projectAbbreviation, String deleteDate, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to delete a project identified by it's abbreviation.org.springframework.http.ResponseEntity<?> getProject(String projectAbbreviation, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to retrieve a certain project identified by its abbreviation.org.springframework.http.ResponseEntity<?> getProjectStatistics(String projectAbbreviation, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to retrieve statistics about a certain project identified by it's abbreviation.org.springframework.http.ResponseEntity<?> getProjectsWithAccessTo(String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to retrieve a list of all projects where the requesting user has access to.org.springframework.http.ResponseEntity<?> updateProject(String projectAbbreviation, ProjectDTO newProjectDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to update a project identity identified by it's abbreviation.
-
Constructor Details
-
ProjectRESTController
public ProjectRESTController()
-
-
Method Details
-
createProject
@PostMapping("/projects") @PreAuthorize("hasRole(\'project-create\')") public org.springframework.http.ResponseEntity<?> createProject(@RequestBody ProjectDTO projectDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to create a new project.- Parameters:
projectDTO- (required) the project objectresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status with the existing project when a duplicate was detected
- a 201-CREATED status with the created project and a Location header on success
- a 400-BAD_REQUEST status when the name/abbreviation is missing or dates are invalid
- a 406-NOT_ACCEPTABLE status when the abbreviation contains disallowed characters
- a 422-UNPROCESSABLE_ENTITY status when creation failed
-
getProjectsWithAccessTo
@GetMapping("/projects") @PreAuthorize("hasRole(\'project-read-all\')") public org.springframework.http.ResponseEntity<?> getProjectsWithAccessTo(@RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to retrieve a list of all projects where the requesting user has access to.- Parameters:
responseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 501-NOT_IMPLEMENTED status (endpoint not implemented yet)
-
getProject
@GetMapping("/projects/{projectAbbreviation}") @PreAuthorize("@auth.hasProjectRoleRelationship(#root, #abbreviation, \'project-read\')") public org.springframework.http.ResponseEntity<?> getProject(@PathVariable(name="projectAbbreviation",required=true) String projectAbbreviation, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to retrieve a certain project identified by its abbreviation.- Parameters:
projectAbbreviation- the project's abbreviationresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status with the requested project on success
- a 400-BAD_REQUEST status when the abbreviation is missing or empty
- a 404-NOT_FOUND status when no project exists for the given abbreviation
-
getProjectStatistics
@GetMapping("projects/{projectAbbreviation}/statistics") @PreAuthorize("@auth.hasProjectRoleRelationship(#root, #projectAbbreviation, \'project-read\')") public org.springframework.http.ResponseEntity<?> getProjectStatistics(@PathVariable("projectAbbreviation") String projectAbbreviation, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to retrieve statistics about a certain project identified by it's abbreviation.- Parameters:
projectAbbreviation- the project's abbreviationresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 501-NOT_IMPLEMENTED status (endpoint not implemented yet)
-
updateProject
@PutMapping("/projects/{projectAbbreviation}") @PreAuthorize("@auth.hasProjectRoleRelationship(#root, #projectAbbreviation, \'project-update\')") public org.springframework.http.ResponseEntity<?> updateProject(@PathVariable("projectAbbreviation") String projectAbbreviation, @RequestBody ProjectDTO newProjectDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to update a project identity identified by it's abbreviation.- Parameters:
projectAbbreviation- the abbreviation of the project that is to be updatednewProjectDTO- (required) the project object containing all updated values, null-values will lead to keeping the old valuesresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status with the updated project on success
- a 404-NOT_FOUND status when the project does not exist
- a 422-UNPROCESSABLE_ENTITY status when the update failed
-
deleteProject
@DeleteMapping("/projects/{projectAbbreviation}") @PreAuthorize("@auth.hasProjectRoleRelationship(#root, #projectAbbreviation, \'project-delete\')") public org.springframework.http.ResponseEntity<?> deleteProject(@PathVariable("projectAbbreviation") String projectAbbreviation, @RequestParam(name="deleteDate",required=false) String deleteDate, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to delete a project identified by it's abbreviation. The project will not be removed from the database but rather tombstoned, meaning the end-date will be set properly so that retrieving, updating, inserting, etc. is not allowed anymore.- Parameters:
projectAbbreviation- the project's abbreviationdeleteDate- (optional) the date from which the project should be considered as deletedresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 204-NO_CONTENT status when the project was successfully deleted/tombstoned
- a 400-BAD_REQUEST status when the abbreviation is missing or empty
- a 404-NOT_FOUND status when the project does not exist
- a 422-UNPROCESSABLE_ENTITY status when the deletion failed
-