added PhotoApi.remove() and 404 handling

This commit is contained in:
Brian Long 2024-05-09 15:51:55 -04:00
parent f9ed4561f9
commit 9c1a596a59

View File

@ -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(