use of org.apache.archiva.metadata.repository.filter.IncludesFilter in project archiva by apache.
the class DefaultMergeRepositoriesService method mergeBySkippingConflicts.
public void mergeBySkippingConflicts(String sourceRepositoryId, String targetRepositoryId) throws RepositoryMergerException, ArchivaRestServiceException {
RepositorySession repositorySession = repositorySessionFactory.createSession();
try {
List<ArtifactMetadata> conflictSourceArtifacts = repositoryMerger.getConflictingArtifacts(repositorySession.getRepository(), sourceRepositoryId, targetRepositoryId);
MetadataRepository metadataRepository = repositorySession.getRepository();
List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts(sourceRepositoryId);
sourceArtifacts.removeAll(conflictSourceArtifacts);
ManagedRepository repository = managedRepositoryAdmin.getManagedRepository(targetRepositoryId);
if (repository.isReleases() && !repository.isSnapshots()) {
mergeWithOutSnapshots(metadataRepository, sourceArtifacts, sourceRepositoryId, targetRepositoryId);
} else {
Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>(sourceArtifacts);
repositoryMerger.merge(metadataRepository, sourceRepositoryId, targetRepositoryId, artifactsWithOutConflicts);
for (ArtifactMetadata metadata : sourceArtifacts) {
triggerAuditEvent(targetRepositoryId, metadata.getId(), AuditEvent.MERGING_REPOSITORIES);
}
}
doScanRepository(targetRepositoryId, false);
} catch (MetadataRepositoryException e) {
throw new ArchivaRestServiceException(e.getMessage(), e);
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(e.getMessage(), e);
} finally {
repositorySession.close();
}
}
use of org.apache.archiva.metadata.repository.filter.IncludesFilter in project archiva by apache.
the class DefaultMergeRepositoriesService method mergeWithOutSnapshots.
private void mergeWithOutSnapshots(MetadataRepository metadataRepository, List<ArtifactMetadata> sourceArtifacts, String sourceRepoId, String repoid) throws RepositoryMergerException {
List<ArtifactMetadata> artifactsWithOutSnapshots = new ArrayList<>();
for (ArtifactMetadata metadata : sourceArtifacts) {
if (VersionUtil.isSnapshot(metadata.getProjectVersion())) // if ( metadata.getProjectVersion().contains( VersionUtil.SNAPSHOT ) )
{
artifactsWithOutSnapshots.add(metadata);
} else {
triggerAuditEvent(repoid, metadata.getId(), AuditEvent.MERGING_REPOSITORIES);
}
}
sourceArtifacts.removeAll(artifactsWithOutSnapshots);
Filter<ArtifactMetadata> artifactListWithOutSnapShots = new IncludesFilter<ArtifactMetadata>(sourceArtifacts);
repositoryMerger.merge(metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots);
}
Aggregations