Search in sources :

Example 1 with ExcludesFilter

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);
    }
}
Also used : RepositoryListener(org.apache.archiva.metadata.audit.RepositoryListener) RepositoryStorageRuntimeException(org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException) ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ExcludesFilter(org.apache.archiva.filter.ExcludesFilter) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata)

Aggregations

ExcludesFilter (org.apache.archiva.filter.ExcludesFilter)1 RepositoryListener (org.apache.archiva.metadata.audit.RepositoryListener)1 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)1 ReadMetadataRequest (org.apache.archiva.metadata.repository.storage.ReadMetadataRequest)1 RepositoryStorageRuntimeException (org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException)1