Skip to content

Commit

Permalink
Remove delimiter from @value
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Homer <etiennehomer@gmail.com>
  • Loading branch information
etiennehomer committed Nov 21, 2024
1 parent 51c1186 commit 1ab3446
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/powsybl/caseserver/service/S3CaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private String parseFilenameFromKey(String key) {
}

public String uuidToKeyPrefix(UUID uuid) {
return rootDirectory + uuid.toString() + DELIMITER;
return rootDirectory + DELIMITER + uuid.toString() + DELIMITER;
}

public String uuidToKeyWithFileName(UUID uuid, String filename) {
Expand Down Expand Up @@ -254,7 +254,7 @@ public Optional<byte[]> getCaseBytes(UUID caseUuid) {
public List<CaseInfos> getCases() {
List<CaseInfos> caseInfosList = new ArrayList<>();
CaseInfos caseInfos;
for (S3Object o : getCaseS3Objects(rootDirectory)) {
for (S3Object o : getCaseS3Objects(rootDirectory + DELIMITER)) {
caseInfos = getCaseInfos(parseUuidFromKey(o.key()));
if (Objects.nonNull(caseInfos)) {
caseInfosList.add(caseInfos);
Expand Down Expand Up @@ -319,7 +319,7 @@ public Set<String> listName(UUID caseUuid, String regex) {
filenames = List.of(removeExtension(originalFilename, "." + getCompressionFormat(caseUuid)));
} else {
List<S3Object> s3Objects = getCaseS3Objects(caseUuid);
filenames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(rootDirectory + caseUuid.toString() + DELIMITER, "")).toList();
filenames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(rootDirectory + DELIMITER + caseUuid.toString() + DELIMITER, "")).toList();
// For archived cases :
if (isArchivedCaseFile(originalFilename)) {
filenames = filenames.stream()
Expand Down Expand Up @@ -411,9 +411,9 @@ private void copyEntry(UUID sourcecaseUuid, UUID caseUuid, String fileName) {
// To optimize copy, files to copy are not downloaded on the case-server. They are directly copied on the S3 server.
CopyObjectRequest copyObjectRequest = CopyObjectRequest.builder()
.sourceBucket(bucketName)
.sourceKey(rootDirectory + sourcecaseUuid + DELIMITER + fileName)
.sourceKey(rootDirectory + DELIMITER + sourcecaseUuid + DELIMITER + fileName)
.destinationBucket(bucketName)
.destinationKey(rootDirectory + caseUuid + DELIMITER + fileName)
.destinationKey(rootDirectory + DELIMITER + caseUuid + DELIMITER + fileName)
.build();
try {
s3Client.copyObject(copyObjectRequest);
Expand Down Expand Up @@ -526,7 +526,7 @@ public void deleteCase(UUID caseUuid) {
public void deleteAllCases() {
ListObjectsV2Request listObjectsRequest = ListObjectsV2Request.builder()
.bucket(bucketName)
.prefix(rootDirectory)
.prefix(rootDirectory + DELIMITER)
.build();

ListObjectsV2Response listObjectsResponse = s3Client.listObjectsV2(listObjectsRequest);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cleaning-cases-cron: 0 * 2 * * ?
storage:
type: FS # FS or S3
s3:
rootDirectory: cases/
rootDirectory: cases

0 comments on commit 1ab3446

Please sign in to comment.