From 9c1a596a5933b1806f9087bdb7025481a9e287f0 Mon Sep 17 00:00:00 2001 From: "Brian M. Long" Date: Thu, 9 May 2024 15:51:55 -0400 Subject: [PATCH] added PhotoApi.remove() and 404 handling --- .../java/com/poststats/rs/api/PhotoApi.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/poststats/rs/api/PhotoApi.java b/src/main/java/com/poststats/rs/api/PhotoApi.java index f8743cb..a335eca 100644 --- a/src/main/java/com/poststats/rs/api/PhotoApi.java +++ b/src/main/java/com/poststats/rs/api/PhotoApi.java @@ -16,12 +16,14 @@ import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; import io.swagger.v3.oas.annotations.media.SchemaProperty; import io.swagger.v3.oas.annotations.parameters.RequestBody; import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.security.RolesAllowed; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Positive; import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; @@ -51,6 +53,10 @@ public interface PhotoApi { summary = "Retrieves limited meta-data about a photo.", description = "Retreives type, size, and other direct meta-data about the specified photo." ) + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Not found") + }) Photo get( @Parameter(description = "A unique identifier for a photo") @PathParam("photoId") @NotNull @Positive BigInteger photoId); @@ -60,7 +66,10 @@ public interface PhotoApi { @Produces({"image/png", "image/jpeg"}) @Cache(maxAge = 864000) @Operation(summary = "Retrieves the binary stream of a photo.") - @ApiResponse(responseCode = "200", description = "Success") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Not found") + }) Response getStream( @Parameter(description = "A unique identifier for a photo") @PathParam("photoId") @NotNull @Positive BigInteger photoId); @@ -70,11 +79,27 @@ public interface PhotoApi { @Produces({"image/png", "image/jpeg"}) @Cache(maxAge = 864000) @Operation(summary = "Retrieves the binary stream of the thumbnail of a photo.") - @ApiResponse(responseCode = "200", description = "Success") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Not found") + }) Response getThumbnailStream( @Parameter(description = "A unique identifier for a photo") @PathParam("photoId") @NotNull @Positive BigInteger photoId); + @DELETE + @Path("/{photoId}") + @Operation(summary = "Permanently deletes the photo contents, meta-data, and associations to people, courses, and events.") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Success"), + @ApiResponse(responseCode = "404", description = "Not found") + }) + @RolesAllowed("admin") + @SecurityRequirement(name = "basic") + void remove( + @Parameter(description = "A unique identifier for a photo") + @PathParam("photoId") @NotNull @Positive BigInteger photoId); + @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Operation(