Skip to content

Commit

Permalink
s3 based case store
Browse files Browse the repository at this point in the history
Signed-off-by: HARPER Jon <[email protected]>
  • Loading branch information
jonenst committed Jun 28, 2023
1 parent 43e3ddb commit a966d53
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 212 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/powsybl/caseserver/CaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
import java.util.List;
import java.util.UUID;

Expand Down Expand Up @@ -51,7 +50,7 @@ public class CaseController {
//For maintenance purpose
public ResponseEntity<List<CaseInfos>> getCases() {
LOGGER.debug("getCases request received");
List<CaseInfos> cases = caseService.getCases(caseService.getStorageRootDir());
List<CaseInfos> cases = caseService.getCases();
if (cases == null) {
return ResponseEntity.noContent().build();
}
Expand All @@ -62,30 +61,31 @@ public ResponseEntity<List<CaseInfos>> getCases() {
@Operation(summary = "Get a case infos")
public ResponseEntity<CaseInfos> getCaseInfos(@PathVariable("caseUuid") UUID caseUuid) {
LOGGER.debug("getCaseInfos request received");
Path file = caseService.getCaseFile(caseUuid);
if (file == null) {
if (!caseService.caseExists(caseUuid)) {
return ResponseEntity.noContent().build();
}
CaseInfos caseInfos = caseService.getCase(file);
CaseInfos caseInfos = caseService.getCase(caseUuid);
return ResponseEntity.ok().body(caseInfos);
}

@GetMapping(value = "/cases/{caseUuid}/format")
@Operation(summary = "Get case Format")
public ResponseEntity<String> getCaseFormat(@PathVariable("caseUuid") UUID caseUuid) {
LOGGER.debug("getCaseFormat request received");
Path file = caseService.getCaseFile(caseUuid);
if (file == null) {
if (!caseService.caseExists(caseUuid)) {
throw createDirectoryNotFound(caseUuid);
}
String caseFormat = caseService.getFormat(file);
String caseFormat = caseService.getFormat(caseUuid);
return ResponseEntity.ok().body(caseFormat);
}

@GetMapping(value = "/cases/{caseUuid}/name")
@Operation(summary = "Get case name")
public ResponseEntity<String> getCaseName(@PathVariable("caseUuid") UUID caseUuid) {
LOGGER.debug("getCaseName request received");
if (!caseService.caseExists(caseUuid)) {
throw createDirectoryNotFound(caseUuid);
}
String caseName = caseService.getCaseName(caseUuid);
return ResponseEntity.ok().body(caseName);
}
Expand Down Expand Up @@ -166,6 +166,9 @@ public ResponseEntity<Void> disableCaseExpiration(@PathVariable("caseUuid") UUID
@Operation(summary = "delete a case")
public ResponseEntity<Void> deleteCase(@PathVariable("caseUuid") UUID caseUuid) {
LOGGER.debug("deleteCase request received with parameter caseUuid = {}", caseUuid);
if (!caseService.caseExists(caseUuid)) {
throw createDirectoryNotFound(caseUuid);
}
caseService.deleteCase(caseUuid);
return ResponseEntity.ok().build();
}
Expand Down Expand Up @@ -200,4 +203,5 @@ public ResponseEntity<List<CaseInfos>> getMetadata(@RequestParam("ids") List<UUI
LOGGER.debug("get Case metadata");
return ResponseEntity.ok().body(caseService.getMetadata(ids));
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/powsybl/caseserver/CaseException.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Type getType() {
return type;
}

public static CaseException createDirectoryAreadyExists(Path directory) {
public static CaseException createDirectoryAreadyExists(String directory) {
Objects.requireNonNull(directory);
return new CaseException(Type.DIRECTORY_ALREADY_EXISTS, "A directory with the same name already exists: " + directory);
}
Expand Down
Loading

0 comments on commit a966d53

Please sign in to comment.