Skip to content

Commit

Permalink
Sonar fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Homer <[email protected]>
  • Loading branch information
etiennehomer committed Oct 18, 2024
1 parent df12461 commit 5be2ad3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/main/java/com/powsybl/caseserver/service/S3CaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class S3CaseService implements CaseService {
public static final int MAX_SIZE = 500000000;
public static final List<String> COMPRESSION_FORMATS = List.of("bz2", "gz", "xz", "zst");
public static final List<String> ARCHIVE_FORMATS = List.of("zip");
public static final String DELIMITER = "/";

private ComputationManager computationManager = LocalComputationManager.getDefault();

Expand Down Expand Up @@ -99,7 +100,6 @@ private <R, T1 extends Throwable, T2 extends Throwable> R withTempCopy(UUID case
FailableConsumer<Path, T1> contentInitializer, FailableFunction<Path, R, T2> f) {
Path tempdirPath;
Path tempCasePath;
String compressionFormat;
try {
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------"));
tempdirPath = Files.createTempDirectory(caseUuid.toString(), attr);
Expand Down Expand Up @@ -191,19 +191,19 @@ public Map<String, String> getCaseMetadata(UUID caseUuid) {

// key format is "gsi-cases/UUID/filename"
private UUID parseUuidFromKey(String key) {
int firstSlash = key.indexOf('/');
int secondSlash = key.indexOf('/', firstSlash + 1);
int firstSlash = key.indexOf(DELIMITER);
int secondSlash = key.indexOf(DELIMITER, firstSlash + 1);
return UUID.fromString(key.substring(firstSlash + 1, secondSlash));
}

private String parseFilenameFromKey(String key) {
int firstSlash = key.indexOf('/');
int secondSlash = key.indexOf('/', firstSlash + 1);
int firstSlash = key.indexOf(DELIMITER);
int secondSlash = key.indexOf(DELIMITER, firstSlash + 1);
return key.substring(secondSlash + 1);
}

private String uuidToPrefixKey(UUID uuid) {
return CASES_PREFIX + uuid.toString() + "/";
return CASES_PREFIX + uuid.toString() + DELIMITER;
}

private String uuidAndFilenameToKey(UUID uuid, String filename) {
Expand Down Expand Up @@ -339,7 +339,7 @@ static boolean isArchivedCaseFile(String caseName) {

public Set<String> listName(UUID caseUuid, String regex) {
List<S3Object> s3Objects = getCaseFileSummaries(caseUuid);
List<String> fileNames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(CASES_PREFIX + caseUuid.toString() + "/", "")).toList();
List<String> fileNames = s3Objects.stream().map(obj -> Paths.get(obj.key()).toString().replace(CASES_PREFIX + caseUuid.toString() + DELIMITER, "")).toList();
if (Objects.nonNull(getCompressionFormat(caseUuid)) && getCompressionFormat(caseUuid).equals("zip")) {
fileNames = fileNames.stream().filter(name -> !name.equals(getOriginalFilename(caseUuid))).toList();
} else if (isCompressedCaseFile(fileNames.get(0))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public abstract class AbstractCaseDataSourceControllerTest {
@Value("${case-store-directory:#{systemProperties['user.home'].concat(\"/cases\")}}")
protected String rootDirectory;

static String CGMES_ZIP_NAME = "CGMES_v2415_MicroGridTestConfiguration_BC_BE_v2.zip";
static final String CGMES_ZIP_NAME = "CGMES_v2415_MicroGridTestConfiguration_BC_BE_v2.zip";

static String CGMES_FILE_NAME = "CGMES_v2415_MicroGridTestConfiguration_BC_BE_v2/MicroGridTestConfiguration_BC_BE_DL_V2.xml";
static final String CGMES_FILE_NAME = "CGMES_v2415_MicroGridTestConfiguration_BC_BE_v2/MicroGridTestConfiguration_BC_BE_DL_V2.xml";

UUID cgmesCaseUuid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ static GenericContainer<?> createMinioContainer() {
try {
GenericContainer<?> minioContainer = new GenericContainer(
String.format("%s:%s", MINIO_DOCKER_IMAGE_NAME, MINIO_DOCKER_IMAGE_VERSION))
// .withClasspathResourceMapping("/", "/data/", BindMode.READ_WRITE)
.withCommand("server /data")
.withExposedPorts(MINIO_PORT)
.waitingFor(new HttpWaitStrategy()
Expand Down

0 comments on commit 5be2ad3

Please sign in to comment.