Class ProjectImageRESTController

java.lang.Object
org.trustdeck.controller.ProjectImageRESTController

@RestController @EnableMethodSecurity @RequestMapping("/api") public class ProjectImageRESTController extends Object
This class offers a REST API for interacting with project images.
Author:
Armin Müller
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<?>
    createProjectImage(String projectAbbreviation, org.springframework.web.multipart.MultipartFile image, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to store a new image for a project.
    org.springframework.http.ResponseEntity<?>
    deleteProjectImage(String projectAbbreviation, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to delete an image from a project.
    org.springframework.http.ResponseEntity<?>
    getProjectImage(String projectAbbreviation, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to retrieve the image of a project.
    org.springframework.http.ResponseEntity<?>
    updateProjectImage(String projectAbbreviation, org.springframework.web.multipart.MultipartFile image, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to update a project image.

    Methods inherited from class java.lang.Object

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

    • ProjectImageRESTController

      public ProjectImageRESTController()
  • Method Details

    • createProjectImage

      @PostMapping(path="/projects/{projectAbbreviation}/image", consumes="multipart/form-data") @PreAuthorize("hasRole(\'project-image-create\')") public org.springframework.http.ResponseEntity<?> createProjectImage(@PathVariable(name="projectAbbreviation",required=true) String projectAbbreviation, @RequestPart("image") org.springframework.web.multipart.MultipartFile image, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to store a new image for a project.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the image belongs to
      image - the image that should be stored
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 201-CREATED status when the project image was successfully stored
    • a 400-BAD_REQUEST status when no image was provided, the abbreviation is missing, or the image is otherwise invalid
    • a 404-NOT_FOUND status when the project does not exist
    • a 410-GONE status when the project has already ended
    • a 413-PAYLOAD_TOO_LARGE status when the image exceeds the maximum allowed size
    • a 415-UNSUPPORTED_MEDIA_TYPE status when the file is not of a supported image type
    • a 422-UNPROCESSABLE_ENTITY status when the image could not be processed or creation failed
    • getProjectImage

      @GetMapping(path="/projects/{projectAbbreviation}/image") @PreAuthorize("hasRole(\'project-image-read\')") public org.springframework.http.ResponseEntity<?> getProjectImage(@PathVariable(name="projectAbbreviation",required=true) String projectAbbreviation, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to retrieve the image of a project.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the image belongs to
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status with the image bytes and corresponding MIME type on success
    • a 204-NO_CONTENT status when an image entry exists but contains no data
    • a 400-BAD_REQUEST status when the abbreviation is missing
    • a 404-NOT_FOUND status when the project or its image does not exist
    • a 410-GONE status when the project has already ended
    • updateProjectImage

      @PutMapping(path="/projects/{projectAbbreviation}/image", consumes="multipart/form-data") @PreAuthorize("hasRole(\'project-image-update\')") public org.springframework.http.ResponseEntity<?> updateProjectImage(@PathVariable(name="projectAbbreviation",required=true) String projectAbbreviation, @RequestPart("image") org.springframework.web.multipart.MultipartFile image, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to update a project image.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the updated image belongs to
      image - the updated image that should be stored
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status when the project image was successfully updated
    • a 400-BAD_REQUEST status when no image was provided or the abbreviation is missing
    • a 404-NOT_FOUND status when the project does not exist
    • a 410-GONE status when the project has already ended
    • a 413-PAYLOAD_TOO_LARGE status when the image exceeds the maximum allowed size
    • a 415-UNSUPPORTED_MEDIA_TYPE status when the file is not of a supported image type
    • a 422-UNPROCESSABLE_ENTITY status when the image could not be processed or the update failed
    • deleteProjectImage

      @DeleteMapping(path="/projects/{projectAbbreviation}/image") @PreAuthorize("hasRole(\'project-image-delete\')") public org.springframework.http.ResponseEntity<?> deleteProjectImage(@PathVariable(name="projectAbbreviation",required=true) String projectAbbreviation, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to delete an image from a project.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the image belongs to
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 204-NO_CONTENT status when the project image was successfully deleted
    • a 400-BAD_REQUEST status when the abbreviation is missing
    • a 404-NOT_FOUND status when the project does not exist
    • a 410-GONE status when the project has already ended
    • a 422-UNPROCESSABLE_ENTITY status when the deletion failed or was rolled back