Class ImageController


  • @RestController
    @RequestMapping("/images")
    @ExposesResourceFor(Image.class)
    public class ImageController
    extends Object
    The ImageController class is the @RestController that maps the endpoints of "/images" for the communication between the server-side and client-side for Image
    • Method Detail

      • getProductImages

        @GetMapping(value="/{productId:\\d+}",
                    produces="application/json")
        public List<Image> getProductImages​(@PathVariable
                                            long productId)
        The Get method which returns a list of Image objects for a Product.
        Parameters:
        productId - The ID of the Product the user wants images for.
        Returns:
        A List of Image objects for the specified Product.
      • post

        @PostMapping(consumes={"application/json","text/plain"},
                     produces={"application/json","text/plain"})
        public Image post​(@RequestBody
                          Image image)
        The Post method for creating a new image.
        Parameters:
        image - The Image to be created.
        Returns:
        The Image object that was created.
      • getImage

        @GetMapping(value="/{imageId:\\d+}",
                    produces="application/json")
        public Image getImage​(@PathVariable
                              long imageId)
        The Get method for retrieving an Image object by its ID.
        Parameters:
        imageId - The ID of the Image object to be retrieved.
        Returns:
        The matching Image object.
      • deleteImage

        @DeleteMapping(value="/{imageId:\\d+}",
                       consumes="application/json")
        public org.springframework.http.ResponseEntity<Long> deleteImage​(@PathVariable
                                                                         long imageId,
                                                                         Image image,
                                                                         Profile profile)
        The Delete method that returns a response entity indicating success or failure.
        Parameters:
        imageId - The ID of the Image to be deleted.
        image - The Image object.
        profile - The Profile of the user requesting the delete.
        Returns:
        A ResponseEntity indicating the status of the delete attempt.
      • getDescription

        @GetMapping(value="/{imageId:\\d+}/description",
                    produces="application/json")
        public String getDescription​(@PathVariable
                                     long imageId)
        The Get method which returns the description of an image.
        Parameters:
        imageId - The ID of the Image object for which the description is required.
        Returns:
        The String description of the specified Image.
      • updateDescription

        @PutMapping(value="/{imageId:\\d+}/description",
                    consumes={"application/json","text/plain"},
                    produces={"application/json","text/plain"})
        public String updateDescription​(@RequestBody
                                        String description,
                                        @PathVariable
                                        long imageId)
        The Put method which allows updating the description of an image.
        Parameters:
        description - The new description contents.
        imageId - The Image object to be updated.
        Returns:
        The description contents of the Image after being updated.