Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3 based case store #11

Merged
merged 155 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
4f5d98a
s3 based case store
jonenst May 31, 2023
db41032
Merge branch 'main' into case_s3
Oct 5, 2023
7c7157f
implement and handle the two mode of object and file storage system
Oct 5, 2023
e94e02c
clean code
Oct 26, 2023
ebba256
fix code review remarqs
Oct 30, 2023
833c839
fix unused import
Oct 30, 2023
4dc872d
fix code review remarqs
Oct 31, 2023
80566f7
fix some code smell issues
Nov 3, 2023
ffbb128
fix sonar smells
ghazwarhili Nov 5, 2023
a657b8a
fix using publicly writable directories is security-sensitive java:S5443
ghazwarhili Nov 5, 2023
ee1d7be
Handle Catch Exception instead of Throwable smells
ghazwarhili Nov 5, 2023
bdb2a2e
refacto s3 test without bean mock
ghazwarhili Nov 6, 2023
1d96977
unify testcontainer config
ghazwarhili Nov 6, 2023
e5cea59
fix code review remarqs
ghazwarhili Nov 8, 2023
36b2454
clean code
ghazwarhili Nov 8, 2023
5b619ba
Merge remote-tracking branch 'origin/case_s3' into case_s3
ghazwarhili Nov 15, 2023
2f5e41d
Refactor duplication endpoint
anistouri Apr 17, 2024
4e225e5
Fix TU
anistouri Apr 18, 2024
5a13fc9
Code refactoring
anistouri Apr 24, 2024
3075cda
remove whitespace
anistouri Apr 24, 2024
7f458a3
Merge pull request #28 from powsybl/refactor-duplication-elements
anistouri May 2, 2024
35106ac
Parent 19: update liquibase maven plugin
anistouri May 3, 2024
7ba466c
Merge pull request #32 from powsybl/upgrade-to-parent-19
anistouri May 3, 2024
c200713
Update to powsybl dependencies 2024.1.0 (#31)
etiennehomer May 17, 2024
933e75d
Enable Prometheus in every microservice (#33)
antoinebhs May 29, 2024
51f6bf9
resolve conflicts and merge main
ghazwarhili Jun 7, 2024
93b531c
Fix case names when exported
achour94 Jun 10, 2024
700852a
Fix case names when exported
achour94 Jun 10, 2024
92d5796
Fix case names when exported
achour94 Jun 14, 2024
40e669e
Fix case names when exported #34
achour94 Jun 14, 2024
ca90c16
update to powsybl-ws-dependencies v2.11.0 (#35)
AbdelHedhili Jun 14, 2024
95129ae
fix test
ghazwarhili Jun 20, 2024
18e2b33
fix checkstyle and unused import
ghazwarhili Jun 20, 2024
883e509
Migrate to PowSyBl 2023.2.1 (#10)
SlimaneAmar Jun 21, 2023
6dc48bc
s3 based case store
jonenst May 31, 2023
5c37e6a
Update parent 12 (#12)
Tristan-WorkGH Jul 16, 2023
2a413cf
support parentheses in case name file for creation (#14)
Walid-Sahnoun Sep 11, 2023
6b38ec4
springboot 3.1.2 (#13)
AbdelHedhili Sep 22, 2023
e536feb
implement and handle the two mode of object and file storage system
Oct 5, 2023
7fa0c59
clean code
Oct 26, 2023
4546ac1
fix code review remarqs
Oct 30, 2023
642689d
fix unused import
Oct 30, 2023
87559a2
fix code review remarqs
Oct 31, 2023
c387a19
fix some code smell issues
Nov 3, 2023
cab43d0
fix sonar smells
ghazwarhili Nov 5, 2023
b0a8706
fix using publicly writable directories is security-sensitive java:S5443
ghazwarhili Nov 5, 2023
cbf8acc
Handle Catch Exception instead of Throwable smells
ghazwarhili Nov 5, 2023
55203cd
refacto s3 test without bean mock
ghazwarhili Nov 6, 2023
1cb4564
unify testcontainer config
ghazwarhili Nov 6, 2023
e3167e2
clean code
ghazwarhili Nov 8, 2023
2b04ca6
Parent 17: update liquibase maven plugin (#15)
anistouri Oct 9, 2023
bfeea3f
Add our classic logback-test.xml for nicer logs (#17)
jonenst Oct 29, 2023
9e0ac92
powsybl ws dependencies 2.5.0 (#16)
AbdelHedhili Oct 31, 2023
0cb0674
Update to powsybl-ws-dependencies 2.6.0 (#18)
sBouzols Nov 23, 2023
b02628e
Add environment variable for embedded ES container (#19)
antoinebhs Jan 2, 2024
ccf3f6d
powsybl-ws-dependencies 2.7.0 (#23)
antoinebhs Feb 2, 2024
5717e8a
update to powsybl-ws-dependencies 2.8.0 (#25)
ayolab Mar 19, 2024
ab90e91
update to powsybl-ws-dependencies 2.9.0 (#27)
antoinebhs Apr 10, 2024
74e7e54
Disable index auto-creation by ElasticSearch (#30)
antoinebhs Apr 29, 2024
2eccb66
Refactor duplication endpoint
anistouri Apr 17, 2024
0dd6fba
Fix TU
anistouri Apr 18, 2024
cadf860
Code refactoring
anistouri Apr 24, 2024
6435368
remove whitespace
anistouri Apr 24, 2024
6cbad7e
Parent 19: update liquibase maven plugin
anistouri May 3, 2024
678e89b
Update to powsybl dependencies 2024.1.0 (#31)
etiennehomer May 17, 2024
dc833bc
Enable Prometheus in every microservice (#33)
antoinebhs May 29, 2024
cd2955f
update to powsybl-ws-dependencies v2.11.0 (#35)
AbdelHedhili Jun 14, 2024
d3b815d
replace OffsetDateTime with Instant
anistouri Jun 20, 2024
17b5b1f
add comment
anistouri Jun 20, 2024
7438f1d
Merge pull request #36 from powsybl/replace-LocalDateTime-by-Instant
anistouri Jun 20, 2024
6b5761c
refactor
souissimai Jul 17, 2024
3b1f5b2
Merge pull request #37 from powsybl/rename_file_when_converting_case
souissimai Jul 22, 2024
d05bd80
conflicts resolving
ghazwarhili Jul 25, 2024
7bd2878
merge main into branch
ghazwarhili Jul 25, 2024
bed9105
handle zip case file with s3
ghazwarhili Sep 5, 2024
e98c4fb
Merge branch 'main' into case_s3
jonenst Sep 17, 2024
099c976
Do not download the whole case file when it's not necessary + refacto
etiennehomer Sep 23, 2024
2f4a6b7
Rename test package to service
etiennehomer Sep 23, 2024
65edac3
Do not index case when withIndexation=false + tmp
etiennehomer Sep 24, 2024
d991f20
tmp
Sep 24, 2024
4a784cb
tmp
etiennehomer Sep 26, 2024
22a5b7e
Tmp
etiennehomer Sep 26, 2024
e0c40e0
tmp
etiennehomer Sep 26, 2024
2aba9eb
tmp
etiennehomer Sep 26, 2024
59cdeed
fix test
etiennehomer Sep 27, 2024
a8636cf
Merge branch 'main' into case_s3
etiennehomer Sep 27, 2024
4670e3c
Fix sonar
etiennehomer Sep 27, 2024
a1c8d60
secured zip
etiennehomer Sep 27, 2024
d302c6b
revert
etiennehomer Sep 27, 2024
ea91965
set back todo
etiennehomer Sep 27, 2024
1950468
start minioContainer only for s3 test
ghazwarhili Oct 7, 2024
2db73b4
fix some sonar code issues
ghazwarhili Oct 7, 2024
dba9843
code review remarqs
ghazwarhili Oct 11, 2024
a38600f
fix securityHotSpot
ghazwarhili Oct 11, 2024
7c2ac02
clean
etiennehomer Oct 11, 2024
2ab52f2
Merge branch 'case_s3' of https://github.com/powsybl/powsybl-case-ser…
etiennehomer Oct 11, 2024
2b051e6
d
etiennehomer Oct 15, 2024
8544992
Add test with LF.zip
etiennehomer Oct 16, 2024
83d68de
originalCaseName in postgres
etiennehomer Oct 17, 2024
8b61aa3
Compression format + originalName in postgres
etiennehomer Oct 18, 2024
5cbf729
Clean
etiennehomer Oct 18, 2024
df12461
Add test for .gz, .xml
etiennehomer Oct 18, 2024
5be2ad3
Sonar fixes
etiennehomer Oct 18, 2024
b7ce30c
Sonar fixes
etiennehomer Oct 18, 2024
c723614
Sonar fixes
etiennehomer Oct 18, 2024
ee478f5
Remove outdated TODO
etiennehomer Oct 18, 2024
faf83c1
Review changes
etiennehomer Oct 21, 2024
82a556a
Use file storage
etiennehomer Oct 21, 2024
3a27d6f
Fix bug datasourceExists() on compressed files
etiennehomer Oct 21, 2024
b775a19
Use spring-cloud-aws-starter-s3 3.2.0
etiennehomer Oct 22, 2024
7440835
Clean CaseException
etiennehomer Oct 22, 2024
63bc15f
Reviews fixes
etiennehomer Oct 22, 2024
93ac483
Reviews fixes
etiennehomer Oct 22, 2024
014afa9
Reviews fixes
etiennehomer Oct 22, 2024
ba149cd
Reviews fixes
etiennehomer Oct 22, 2024
d1d5557
Review fixes
etiennehomer Oct 23, 2024
7974e2a
review changes
etiennehomer Oct 23, 2024
b50cd85
Optimize archive duplication
etiennehomer Oct 23, 2024
addb864
use existing application-local.yml
etiennehomer Oct 23, 2024
c0671dc
Back to type: file
etiennehomer Oct 23, 2024
9883652
Merge branch 'main' into case_s3
etiennehomer Oct 23, 2024
34ff54a
remove infosFromDownloadCaseFileSummary()
etiennehomer Oct 23, 2024
7ade436
Use Jimfs !
etiennehomer Oct 24, 2024
5644ca7
Compress archived files
etiennehomer Oct 28, 2024
2ef97e9
Clean
etiennehomer Oct 28, 2024
a347c0a
Clean
etiennehomer Oct 28, 2024
5c8918e
Remove nested ternary
etiennehomer Oct 28, 2024
7c6e17e
Clean listName()
etiennehomer Oct 28, 2024
a4568c9
Merge branch 'case_s3' into case_s3_compress_archived_files
etiennehomer Oct 28, 2024
0398643
Decompress gz files from archives before calling DataSource API
etiennehomer Oct 29, 2024
143eab2
clean
etiennehomer Oct 29, 2024
4418273
Merge branch 'main' into case_s3
etiennehomer Oct 30, 2024
28cc495
Merge branch 'case_s3' into case_s3_compress_archived_files
etiennehomer Oct 30, 2024
6b73714
Add comments + clean
etiennehomer Oct 31, 2024
5d4c720
Clean author, licence
etiennehomer Nov 4, 2024
8f2d24b
Remove second withS3DownloadedDataSource() method
etiennehomer Nov 4, 2024
7706ee5
Clean
etiennehomer Nov 4, 2024
0d12be6
Merge branch 'case_s3_compress_archived_files' into case_s3
etiennehomer Nov 4, 2024
5acd02f
Fix .gz regex
etiennehomer Nov 4, 2024
9cbca2e
Fix sonar
etiennehomer Nov 4, 2024
c3bdd4f
Remove last compression extension
etiennehomer Nov 4, 2024
355c498
Space after if
etiennehomer Nov 4, 2024
460af0e
Clean removeExtension()
etiennehomer Nov 5, 2024
904215f
Fix
etiennehomer Nov 6, 2024
ccfc5cc
Remove Throwable
etiennehomer Nov 6, 2024
8d25d02
Clean
etiennehomer Nov 6, 2024
80e331a
Add fileName as requestParam to exportCase endpoint
etiennehomer Nov 7, 2024
2099593
Remove 'summaries' + remove warning on multiple files
etiennehomer Nov 7, 2024
e69fa42
clean comment
etiennehomer Nov 7, 2024
23a212b
use DELIMITER
etiennehomer Nov 7, 2024
97c4f56
listName(): filter and map fileNames in one instruction + call getOri…
etiennehomer Nov 7, 2024
16a7625
fileNames to filenames
etiennehomer Nov 7, 2024
5c8f7f0
Clean
etiennehomer Nov 7, 2024
6cf316c
remove Delete.builder()
etiennehomer Nov 7, 2024
9d69962
Rename storage to FS
etiennehomer Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<properties>
<liquibase-hibernate-package>com.powsybl.caseserver.repository</liquibase-hibernate-package>
<powsybl-ws-dependencies.version>2.15.0</powsybl-ws-dependencies.version>
<spring-cloud-aws-starter-s3>3.2.0</spring-cloud-aws-starter-s3>
</properties>

<build>
Expand Down Expand Up @@ -147,6 +148,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-aws-starter-s3</artifactId>
<version>${spring-cloud-aws-starter-s3}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
Expand Down
44 changes: 27 additions & 17 deletions src/main/java/com/powsybl/caseserver/CaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
package com.powsybl.caseserver;

import com.powsybl.caseserver.dto.CaseInfos;
import com.powsybl.caseserver.elasticsearch.CaseInfosService;
import com.powsybl.caseserver.service.CaseService;
import com.powsybl.caseserver.service.MetadataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -16,11 +19,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.ContentDisposition;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -33,7 +34,6 @@
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand All @@ -54,14 +54,21 @@ public class CaseController {
private static final Logger LOGGER = LoggerFactory.getLogger(CaseController.class);

@Autowired
@Qualifier("storageService")
private CaseService caseService;

@Autowired
private CaseInfosService caseInfosService;

@Autowired
private MetadataService metadataService;

@GetMapping(value = "/cases")
@Operation(summary = "Get all cases")
//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 @@ -72,30 +79,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.getCaseInfos(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 @@ -123,10 +131,9 @@ public ResponseEntity<byte[]> downloadCase(@PathVariable("caseUuid") UUID caseUu
public ResponseEntity<byte[]> exportCase(
@PathVariable UUID caseUuid,
@RequestParam String format,
@RequestParam(value = "fileName", required = false) String fileName,
@RequestBody(required = false) Map<String, Object> formatParameters) throws IOException {
LOGGER.debug("exportCase request received with parameter caseUuid = {}", caseUuid);
return caseService.exportCase(caseUuid, format, fileName, formatParameters).map(networkInfos -> {
return caseService.exportCase(caseUuid, format, formatParameters).map(networkInfos -> {
var headers = new HttpHeaders();
headers.setContentDisposition(
ContentDisposition.builder("attachment")
Expand Down Expand Up @@ -179,14 +186,17 @@ public ResponseEntity<UUID> duplicateCase(
@ApiResponse(responseCode = "404", description = "Source case not found")})
public ResponseEntity<Void> disableCaseExpiration(@PathVariable("caseUuid") UUID caseUuid) {
LOGGER.debug("disableCaseExpiration request received for caseUuid = {}", caseUuid);
caseService.disableCaseExpiration(caseUuid);
metadataService.disableCaseExpiration(caseUuid);
return ResponseEntity.ok().build();
}

@DeleteMapping(value = "/cases/{caseUuid}")
@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 All @@ -203,14 +213,14 @@ public ResponseEntity<Void> deleteCases() {
@Operation(summary = "Search cases by metadata")
public ResponseEntity<List<CaseInfos>> searchCases(@RequestParam(value = "q") String query) {
LOGGER.debug("search cases request received");
List<CaseInfos> cases = caseService.searchCases(query);
List<CaseInfos> cases = caseInfosService.searchCaseInfos(query);
return ResponseEntity.ok().body(cases);
}

@GetMapping(value = "/cases/metadata")
@Operation(summary = "Get cases Metadata")
public ResponseEntity<List<CaseInfos>> getMetadata(@RequestParam("ids") List<UUID> ids) {
LOGGER.debug("get Case metadata");
LOGGER.debug("get Cases metadata");
return ResponseEntity.ok().body(caseService.getMetadata(ids));
}
}
55 changes: 54 additions & 1 deletion src/main/java/com/powsybl/caseserver/CaseException.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ public final class CaseException extends RuntimeException {

public enum Type {
FILE_NOT_IMPORTABLE,
FILE_NOT_FOUND,
STORAGE_DIR_NOT_CREATED,
ILLEGAL_FILE_NAME,
DIRECTORY_ALREADY_EXISTS,
DIRECTORY_EMPTY,
DIRECTORY_NOT_FOUND,
ORIGINAL_FILE_NOT_FOUND,
TEMP_FILE_INIT,
TEMP_FILE_PROCESS,
TEMP_DIRECTORY_CREATION,
ZIP_FILE_PROCESS,
UNSUPPORTED_FORMAT
}

Expand All @@ -35,7 +41,16 @@ private CaseException(Type type, String msg) {
this.type = Objects.requireNonNull(type);
}

public static CaseException createDirectoryAreadyExists(Path directory) {
public CaseException(Type type, String message, Throwable e) {
super(message, e);
this.type = type;
}

public Type getType() {
return type;
}

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 All @@ -50,11 +65,26 @@ public static CaseException createDirectoryNotFound(UUID uuid) {
return new CaseException(Type.DIRECTORY_NOT_FOUND, "The directory with the following uuid doesn't exist: " + uuid);
}

public static CaseException createOriginalFileNotFound(UUID uuid) {
Objects.requireNonNull(uuid);
return new CaseException(Type.ORIGINAL_FILE_NOT_FOUND, "The original file were not retrieved in the directory with the following uuid: " + uuid);
}

public static CaseException createFileNotImportable(Path file) {
Objects.requireNonNull(file);
return new CaseException(Type.FILE_NOT_IMPORTABLE, "This file cannot be imported: " + file);
}

public static CaseException createFileNotImportable(String file, Exception e) {
Objects.requireNonNull(file);
return new CaseException(Type.FILE_NOT_IMPORTABLE, "This file cannot be imported: " + file, e);
}

public static CaseException createFileNameNotFound(UUID uuid) {
Objects.requireNonNull(uuid);
return new CaseException(Type.FILE_NOT_FOUND, "The file name with the following uuid doesn't exist: " + uuid);
}

public static CaseException createStorageNotInitialized(Path storageRootDir) {
Objects.requireNonNull(storageRootDir);
return new CaseException(Type.STORAGE_DIR_NOT_CREATED, "The storage is not initialized: " + storageRootDir);
Expand All @@ -65,6 +95,29 @@ public static CaseException createIllegalCaseName(String caseName) {
return new CaseException(Type.ILLEGAL_FILE_NAME, "This is not an acceptable case name: " + caseName);
}

public static CaseException createTempDirectory(UUID uuid, Exception e) {
Objects.requireNonNull(uuid);
return new CaseException(Type.TEMP_DIRECTORY_CREATION, "Error creating temporary directory: " + uuid, e);
}

public static CaseException initTempFile(UUID uuid, Throwable e) {
Objects.requireNonNull(uuid);
return new CaseException(Type.TEMP_FILE_INIT, "Error initializing temporary case file: " + uuid, e);
}

public static CaseException processTempFile(UUID uuid, Throwable e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not need version with exception

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Objects.requireNonNull(uuid);
return new CaseException(Type.TEMP_FILE_PROCESS, "Error processing temporary case file: " + uuid, e);
}

public static CaseException importZipContent(UUID uuid, Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

importZipContent and processTempFile unused to be removed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return new CaseException(Type.ZIP_FILE_PROCESS, "Error processing zip content file: " + uuid, e);
}

public static CaseException copyZipContent(UUID uuid, Exception e) {
return new CaseException(Type.ZIP_FILE_PROCESS, "Error copying zip content file: " + uuid, e);
}

public static CaseException createUnsupportedFormat(String format) {
return new CaseException(Type.UNSUPPORTED_FORMAT, "The format: " + format + " is unsupported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package com.powsybl.caseserver;

import com.powsybl.caseserver.service.CaseService;
import com.powsybl.caseserver.repository.CaseMetadataRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
package com.powsybl.caseserver;

import com.powsybl.caseserver.elasticsearch.CaseInfosService;
import com.powsybl.caseserver.services.SupervisionService;
import com.powsybl.caseserver.service.CaseService;
import com.powsybl.caseserver.service.SupervisionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/**
* Copyright (c) 2020, RTE (http://www.rte-france.com)
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.caseserver.datasource.util;
package com.powsybl.caseserver.datasource;

import com.powsybl.caseserver.CaseConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -21,6 +22,8 @@

/**
* @author Abdelsalem Hedhili <abdelsalem.hedhili at rte-france.com>
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
* @author Etienne Homer <etienne.homer at rte-france.com>
*/
@RestController
@RequestMapping(value = "/" + CaseConstants.API_VERSION)
Expand All @@ -29,6 +32,7 @@
public class CaseDataSourceController {

@Autowired
@Qualifier("caseDataSourceService")
private CaseDataSourceService caseDataSourceService;

@GetMapping(value = "/cases/{caseUuid}/datasource/baseName")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2023, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.caseserver.datasource;

import java.util.Set;
import java.util.UUID;

/**
* @author Abdelsalem Hedhili <abdelsalem.hedhili at rte-france.com>
*/
public interface CaseDataSourceService {
String getBaseName(UUID caseUuid);

Boolean datasourceExists(UUID caseUuid, String suffix, String ext);

Boolean datasourceExists(UUID caseUuid, String fileName);

byte[] getInputStream(UUID caseUuid, String suffix, String ext);

byte[] getInputStream(UUID caseUuid, String fileName);

Set<String> listName(UUID caseUuid, String regex);

}
Loading
Loading