in src/main/java/org/apache/sling/cli/impl/nexus/RepositoryService.java [128:168]
public LocalRepository download(@NotNull StagingRepository repository) throws IOException {
readWriteLock.readLock().lock();
LocalRepository localRepository = repositories.get(repository.getRepositoryId());
if (localRepository == null) {
readWriteLock.readLock().unlock();
readWriteLock.writeLock().lock();
try {
if (!repositories.containsKey(repository.getRepositoryId())) {
Path rootFolder = Files.createTempDirectory(repository.getRepositoryId() + "_");
Set<Artifact> artifacts = getArtifacts(repository);
try (CloseableHttpClient client = httpClientFactory.newClient()) {
for (Artifact artifact : artifacts) {
String fileRelativePath = artifact.getRepositoryRelativePath();
String relativeFolderPath = fileRelativePath.substring(0, fileRelativePath.lastIndexOf('/'));
Path artifactFolderPath = Files.createDirectories(rootFolder.resolve(relativeFolderPath));
downloadFileFromRepository(repository, client, artifactFolderPath, fileRelativePath);
downloadFileFromRepository(repository, client, artifactFolderPath,
artifact.getRepositoryRelativeSignaturePath());
downloadFileFromRepository(repository, client, artifactFolderPath,
artifact.getRepositoryRelativeSha1SumPath());
downloadFileFromRepository(repository, client, artifactFolderPath,
artifact.getRepositoryRelativeMd5SumPath());
}
}
localRepository = new LocalRepository(repository, artifacts, rootFolder);
repositories.put(localRepository.getRepositoryId(), localRepository);
}
readWriteLock.readLock().lock();
} finally {
readWriteLock.writeLock().unlock();
}
}
try {
if (localRepository == null) {
throw new IOException("Failed to download repository artifacts.");
}
return localRepository;
} finally {
readWriteLock.readLock().unlock();
}
}