use of org.apache.archiva.filter.ExcludesFilter in project archiva by apache.
the class DefaultMetadataResolver method resolveArtifacts.
@Override
public Collection<ArtifactMetadata> resolveArtifacts(RepositorySession session, String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException {
try {
MetadataRepository metadataRepository = session.getRepository();
Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts(session, repoId, namespace, projectId, projectVersion);
ExcludesFilter<String> filter = new ExcludesFilter<String>(createArtifactIdList(artifacts));
ReadMetadataRequest readMetadataRequest = new ReadMetadataRequest().repositoryId(repoId).namespace(namespace).projectId(projectId).projectVersion(projectVersion).filter(filter);
Collection<ArtifactMetadata> storageArtifacts = repositoryStorage.readArtifactsMetadata(readMetadataRequest);
if (storageArtifacts != null && !storageArtifacts.isEmpty()) {
log.debug("Resolved artifacts from storage: {}", storageArtifacts);
for (ArtifactMetadata artifact : storageArtifacts) {
try {
metadataRepository.updateArtifact(session, repoId, namespace, projectId, projectVersion, artifact);
} catch (MetadataRepositoryException e) {
log.warn("Unable to persist resolved information: {}", e.getMessage(), e);
}
}
session.markDirty();
artifacts = new ArrayList<>(artifacts);
artifacts.addAll(storageArtifacts);
}
return artifacts;
} catch (RepositoryStorageRuntimeException e) {
for (RepositoryListener listener : listeners) {
listener.addArtifactProblem(session, repoId, namespace, projectId, projectVersion, e);
}
throw new MetadataResolutionException(e.getMessage(), e);
}
}
Aggregations