refactoring

This commit is contained in:
2022-05-07 20:04:30 +03:00
parent 07eb599f12
commit b79ae4f76b

View File

@@ -23,17 +23,23 @@ public class MavenHandler {
return optionalInputStream
.map(inputStream -> new GetFileResponse(fileName, inputStream));
} else {
return findInMirrors(path, fileName);
}
}
private Optional<GetFileResponse> findInMirrors(String path, String fileName) {
Optional<InputStream> result;
for (ExternalMavenService externalMavenService : externalMavenServices) {
final String nameForStore = "/" + externalMavenService.getId() + "/" + path;
optionalInputStream = minioService.get(nameForStore);
if (optionalInputStream.isPresent()) {
return optionalInputStream
result = minioService.get(nameForStore);
if (result.isPresent()) {
return result
.map(inputStream -> new GetFileResponse(fileName, inputStream));
} else {
optionalInputStream = externalMavenService.getFile(path);
if (optionalInputStream.isPresent()) {
minioService.put(nameForStore, optionalInputStream.get());
result = externalMavenService.getFile(path);
if (result.isPresent()) {
minioService.put(nameForStore, result.get());
return minioService.get(nameForStore)
.map(inputStream -> new GetFileResponse(fileName, inputStream));
}
@@ -42,7 +48,6 @@ public class MavenHandler {
return Optional.empty();
}
}
public void putFile(String path, InputStream inputStream) {
minioService.put("/local/" + path, inputStream);