use of org.apache.archiva.consumers.ConsumerException in project archiva by apache.
the class DuplicateArtifactsConsumerTest method testConsumerArtifactFileNotExist.
@Test
public void testConsumerArtifactFileNotExist() throws Exception {
consumer.beginScan(config, new Date());
try {
consumer.processFile("com/example/test/test-artifact/2.0/test-artifact-2.0.jar");
fail("Should have failed to find file");
} catch (ConsumerException e) {
assertTrue(e.getCause() instanceof NoSuchFileException);
} finally {
consumer.completeScan();
}
verify(metadataRepository, never()).addMetadataFacet(eq(TEST_REPO), Matchers.<MetadataFacet>anyObject());
}
use of org.apache.archiva.consumers.ConsumerException in project archiva by apache.
the class RepositoryPurgeConsumer method beginScan.
@Override
public void beginScan(ManagedRepository repository, Date whenGathered) throws ConsumerException {
ManagedRepositoryContent repositoryContent;
repositoryContent = repository.getContent();
repositorySession = repositorySessionFactory.createSession();
if (repository.supportsFeature(ArtifactCleanupFeature.class)) {
ArtifactCleanupFeature acf = repository.getFeature(ArtifactCleanupFeature.class).get();
int retentionPeriodInDays = acf.getRetentionPeriod().getDays();
int retentionCount = acf.getRetentionCount();
if (retentionPeriodInDays != 0) {
repoPurge = new DaysOldRepositoryPurge(repositoryContent, retentionPeriodInDays, retentionCount, repositorySession, listeners);
} else {
repoPurge = new RetentionCountRepositoryPurge(repositoryContent, retentionCount, repositorySession, listeners);
}
deleteReleasedSnapshots = acf.isDeleteReleasedSnapshots();
} else {
throw new ConsumerException("The repository does not support the ArtifactCleanup feature " + repository.getId());
}
cleanUp = new CleanupReleasedSnapshotsRepositoryPurge(repositoryContent, metadataTools, repositoryRegistry, repositorySession, listeners);
}
use of org.apache.archiva.consumers.ConsumerException in project archiva by apache.
the class NexusIndexerConsumer method processFile.
@Override
public void processFile(String path) throws ConsumerException {
Path artifactFile = managedRepository.resolve(path);
ArtifactIndexingTask task = new ArtifactIndexingTask(repository, artifactFile, ArtifactIndexingTask.Action.ADD, repository.getIndexingContext());
try {
log.debug("Queueing indexing task '{}' to add or update the artifact in the index.", task);
scheduler.queueTask(task);
} catch (TaskQueueException e) {
throw new ConsumerException(e.getMessage(), e);
}
}
use of org.apache.archiva.consumers.ConsumerException in project archiva by apache.
the class SimpleArtifactConsumer method processFile.
public void processFile(String path, boolean executeOnEntireRepo) throws ConsumerException {
log.info("Processing entry [{}] from repository [{}]", path, this.repository.getId());
try {
ManagedRepositoryContent repositoryContent = repository.getContent();
ArtifactReference artifact = repositoryContent.toArtifactReference(path);
repositorySession.getRepository().getArtifacts(repository.getId(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
} catch (LayoutException | MetadataResolutionException e) {
throw new ConsumerException(e.getLocalizedMessage(), e);
}
}
use of org.apache.archiva.consumers.ConsumerException in project archiva by apache.
the class NexusIndexerConsumer method processFile.
@Override
public void processFile(String path, boolean executeOnEntireRepo) throws Exception {
if (executeOnEntireRepo) {
processFile(path);
} else {
Path artifactFile = managedRepository.resolve(path);
// specify in indexing task that this is not a repo scan request!
ArtifactIndexingTask task = new ArtifactIndexingTask(repository, artifactFile, ArtifactIndexingTask.Action.ADD, repository.getIndexingContext(), false);
// only update index we don't need to scan the full repo here
task.setOnlyUpdate(true);
try {
log.debug("Queueing indexing task '{}' to add or update the artifact in the index.", task);
scheduler.queueTask(task);
} catch (TaskQueueException e) {
throw new ConsumerException(e.getMessage(), e);
}
}
}
Aggregations