refactoring
This commit is contained in:
@@ -23,25 +23,30 @@ public class MavenHandler {
|
|||||||
return optionalInputStream
|
return optionalInputStream
|
||||||
.map(inputStream -> new GetFileResponse(fileName, inputStream));
|
.map(inputStream -> new GetFileResponse(fileName, inputStream));
|
||||||
} else {
|
} else {
|
||||||
for (ExternalMavenService externalMavenService : externalMavenServices) {
|
return findInMirrors(path, fileName);
|
||||||
final String nameForStore = "/" + externalMavenService.getId() + "/" + path;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
optionalInputStream = minioService.get(nameForStore);
|
private Optional<GetFileResponse> findInMirrors(String path, String fileName) {
|
||||||
if (optionalInputStream.isPresent()) {
|
Optional<InputStream> result;
|
||||||
return optionalInputStream
|
for (ExternalMavenService externalMavenService : externalMavenServices) {
|
||||||
|
final String nameForStore = "/" + externalMavenService.getId() + "/" + path;
|
||||||
|
|
||||||
|
result = minioService.get(nameForStore);
|
||||||
|
if (result.isPresent()) {
|
||||||
|
return result
|
||||||
|
.map(inputStream -> new GetFileResponse(fileName, inputStream));
|
||||||
|
} else {
|
||||||
|
result = externalMavenService.getFile(path);
|
||||||
|
if (result.isPresent()) {
|
||||||
|
minioService.put(nameForStore, result.get());
|
||||||
|
return minioService.get(nameForStore)
|
||||||
.map(inputStream -> new GetFileResponse(fileName, inputStream));
|
.map(inputStream -> new GetFileResponse(fileName, inputStream));
|
||||||
} else {
|
|
||||||
optionalInputStream = externalMavenService.getFile(path);
|
|
||||||
if (optionalInputStream.isPresent()) {
|
|
||||||
minioService.put(nameForStore, optionalInputStream.get());
|
|
||||||
return minioService.get(nameForStore)
|
|
||||||
.map(inputStream -> new GetFileResponse(fileName, inputStream));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putFile(String path, InputStream inputStream) {
|
public void putFile(String path, InputStream inputStream) {
|
||||||
|
|||||||
Reference in New Issue
Block a user