1 package de.dlr.shepard.endpoints; 2 3 import java.io.InputStream; 4 5 import org.glassfish.jersey.media.multipart.FormDataContentDisposition; 6 7 import de.dlr.shepard.mongoDB.ShepardFile; 8 import de.dlr.shepard.neo4Core.io.FileContainerIO; 9 import de.dlr.shepard.neo4Core.io.PermissionsIO; 10 import de.dlr.shepard.neo4Core.io.RolesIO; 11 import de.dlr.shepard.neo4Core.orderBy.ContainerAttributes; 12 import de.dlr.shepard.util.Constants; 13 import io.swagger.v3.oas.annotations.Operation; 14 import io.swagger.v3.oas.annotations.Parameter; 15 import io.swagger.v3.oas.annotations.media.ArraySchema; 16 import io.swagger.v3.oas.annotations.media.Content; 17 import io.swagger.v3.oas.annotations.media.Schema; 18 import io.swagger.v3.oas.annotations.parameters.RequestBody; 19 import io.swagger.v3.oas.annotations.responses.ApiResponse; 20 import io.swagger.v3.oas.annotations.tags.Tag; 21 import jakarta.validation.Valid; 22 import jakarta.ws.rs.core.MediaType; 23 import jakarta.ws.rs.core.Response; 24 25 public interface FileRest { 26 27 @Tag(name = Constants.FILE) 28 @Operation(description = "Get all file containers") 29 @ApiResponse(description = "ok", responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = FileContainerIO.class)))) 30 @ApiResponse(description = "not found", responseCode = "404") 31 Response getAllFileContainers(String name, Integer page, Integer size, ContainerAttributes orderAttribute, 32 Boolean orderDesc); 33 34 @Tag(name = Constants.FILE) 35 @Operation(description = "Get file container") 36 @ApiResponse(description = "ok", responseCode = "200", content = @Content(schema = @Schema(implementation = FileContainerIO.class))) 37 @ApiResponse(description = "not found", responseCode = "404") 38 Response getFileContainer(long fileContainerId); 39 40 @Tag(name = Constants.FILE) 41 @Operation(description = "Create a new file container") 42 @ApiResponse(description = "created", responseCode = "201", content = @Content(schema = @Schema(implementation = FileContainerIO.class))) 43 @ApiResponse(description = "not found", responseCode = "404") 44 Response createFileContainer( 45 @RequestBody(required = true, content = @Content(schema = @Schema(implementation = FileContainerIO.class))) @Valid FileContainerIO fileContainer); 46 47 @Tag(name = Constants.FILE) 48 @Operation(description = "Delete file container") 49 @ApiResponse(description = "deleted", responseCode = "204") 50 @ApiResponse(description = "not found", responseCode = "404") 51 Response deleteFileContainer(long fileContainerId); 52 53 @Tag(name = Constants.FILE) 54 @Operation(description = "Get files") 55 @ApiResponse(description = "ok", responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ShepardFile.class)))) 56 @ApiResponse(description = "not found", responseCode = "404") 57 Response getAllFiles(long fileContainerId); 58 59 @Tag(name = Constants.FILE) 60 @Operation(description = "Get file") 61 @ApiResponse(description = "ok", responseCode = "200", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM, schema = @Schema(type = "string", format = "binary"))) 62 @ApiResponse(description = "not found", responseCode = "404") 63 Response getFile(long fileContainerId, String oid); 64 65 @Tag(name = Constants.FILE) 66 @Operation(description = "Delete file") 67 @ApiResponse(description = "ok", responseCode = "204") 68 @ApiResponse(description = "not found", responseCode = "404") 69 Response deleteFile(long fileContainerId, String oid); 70 71 @Tag(name = Constants.FILE) 72 @Operation(description = "Upload a new file") 73 @ApiResponse(description = "created", responseCode = "201", content = @Content(schema = @Schema(implementation = ShepardFile.class))) 74 @ApiResponse(description = "not found", responseCode = "404") 75 Response createFile(long fileContainerId, 76 @Parameter(required = true, schema = @Schema(type = "string", format = "binary", description = "File which you want to upload")) InputStream fileInputStream, 77 @Parameter(hidden = true) FormDataContentDisposition fileMetaData); 78 79 @Tag(name = Constants.FILE) 80 @Operation(description = "Get permissions") 81 @ApiResponse(description = "ok", responseCode = "200", content = @Content(schema = @Schema(implementation = PermissionsIO.class))) 82 @ApiResponse(description = "not found", responseCode = "404") 83 Response getFilePermissions(long fileContainerId); 84 85 @Tag(name = Constants.FILE) 86 @Operation(description = "Edit permissions") 87 @ApiResponse(description = "ok", responseCode = "200", content = @Content(schema = @Schema(implementation = PermissionsIO.class))) 88 @ApiResponse(description = "not found", responseCode = "404") 89 Response editFilePermissions(long fileContainerId, 90 @RequestBody(required = true, content = @Content(schema = @Schema(implementation = PermissionsIO.class))) @Valid PermissionsIO permissions); 91 92 @Tag(name = Constants.FILE) 93 @Operation(description = "Get roles") 94 @ApiResponse(description = "ok", responseCode = "200", content = @Content(schema = @Schema(implementation = RolesIO.class))) 95 @ApiResponse(description = "not found", responseCode = "404") 96 Response getFileRoles(long fileId); 97 }