diff --git a/backend/src/main/java/pdl/backend/ImageController.java b/backend/src/main/java/pdl/backend/ImageController.java index cceae7a..406ca3d 100644 --- a/backend/src/main/java/pdl/backend/ImageController.java +++ b/backend/src/main/java/pdl/backend/ImageController.java @@ -66,6 +66,12 @@ public class ImageController { return new ResponseEntity<>(objectNode, httpHeaders, status); } + /** + * Supprime une image + * + * @param id le matricule de l'image à supprimer + * @return Un code ResponseEntity + */ @DeleteMapping(value = "/images/{id}") public ResponseEntity deleteImage(@PathVariable("id") long id) { var img = imageDao.retrieve(id); @@ -75,12 +81,19 @@ public class ImageController { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } + /** + * Poste une image + * + * @param file l'image à ajouter + * @param redirectAttributes + * @return Une ResponseEntity + */ @PostMapping(value = "/images", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity addImage(@RequestParam("file") MultipartFile file, RedirectAttributes redirectAttributes) { String contentType = file.getContentType(); if (contentType == null || (!contentType.equals(MediaType.IMAGE_JPEG_VALUE) && !contentType.equals(MediaType.IMAGE_PNG_VALUE))) - return JSONError("Content type " + contentType + "isn't supported", HttpStatus.UNSUPPORTED_MEDIA_TYPE); + return JSONError("Content type " + contentType + "is not supported", HttpStatus.UNSUPPORTED_MEDIA_TYPE); try { Image newImg = new Image(file.getOriginalFilename(), file.getBytes()); imageDao.create(newImg); @@ -91,11 +104,21 @@ public class ImageController { } } + /** + * Supprime toutes les images postées + * + * @return Une ResponseEntity + */ @DeleteMapping(value = "/images") public ResponseEntity deleteImagesList() { return JSONError("Method DELETE not allowed for /images", HttpStatus.METHOD_NOT_ALLOWED); } + /** + * Récupère toutes les images + * + * @return un ArrayNode contenant toutes les images à récupérer + */ @GetMapping(value = "/images", produces = "application/json") @ResponseBody public ArrayNode getImageList() { @@ -112,6 +135,14 @@ public class ImageController { return nodes; } + /** + * récupère une image et la modifie si un algorithme est renseigné + * + * @param id le matricule de l'image à récupérer + * @param parameters une String qui contient le reste des paramètres : + * l'algorithme à utiliser ainsi que ses paramètres + * @return Une ResponseEntity + */ @GetMapping(value = "/images/{id}", produces = { MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE, "application/json" }) public ResponseEntity getImage(@PathVariable("id") long id, @@ -234,4 +265,4 @@ public class ImageController { imageData); return ResponseEntity.ok().contentType(image.getMediaType()).body(new InputStreamResource(inputStream)); } -} \ No newline at end of file +}