Search in sources :

Example 1 with ConsumerException

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());
}
Also used : NoSuchFileException(java.nio.file.NoSuchFileException) ConsumerException(org.apache.archiva.consumers.ConsumerException) Date(java.util.Date) Test(org.junit.Test)

Example 2 with ConsumerException

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);
}
Also used : ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) ConsumerException(org.apache.archiva.consumers.ConsumerException) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature)

Example 3 with ConsumerException

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);
    }
}
Also used : Path(java.nio.file.Path) ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) ConsumerException(org.apache.archiva.consumers.ConsumerException) TaskQueueException(org.apache.archiva.redback.components.taskqueue.TaskQueueException)

Example 4 with ConsumerException

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);
    }
}
Also used : LayoutException(org.apache.archiva.repository.LayoutException) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) ConsumerException(org.apache.archiva.consumers.ConsumerException) ArtifactReference(org.apache.archiva.model.ArtifactReference) MetadataResolutionException(org.apache.archiva.metadata.repository.MetadataResolutionException)

Example 5 with ConsumerException

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);
        }
    }
}
Also used : Path(java.nio.file.Path) ArtifactIndexingTask(org.apache.archiva.scheduler.indexing.ArtifactIndexingTask) ConsumerException(org.apache.archiva.consumers.ConsumerException) TaskQueueException(org.apache.archiva.redback.components.taskqueue.TaskQueueException)

Aggregations

ConsumerException (org.apache.archiva.consumers.ConsumerException)10 Path (java.nio.file.Path)5 IOException (java.io.IOException)3 TaskQueueException (org.apache.archiva.redback.components.taskqueue.TaskQueueException)2 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)2 ArtifactIndexingTask (org.apache.archiva.scheduler.indexing.ArtifactIndexingTask)2 NoSuchFileException (java.nio.file.NoSuchFileException)1 Date (java.util.Date)1 ChecksummedFile (org.apache.archiva.checksum.ChecksummedFile)1 UnsupportedBaseContextException (org.apache.archiva.indexer.UnsupportedBaseContextException)1 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)1 RepositoryProblemFacet (org.apache.archiva.metadata.model.facets.RepositoryProblemFacet)1 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)1 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)1 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)1 ArtifactReference (org.apache.archiva.model.ArtifactReference)1 LayoutException (org.apache.archiva.repository.LayoutException)1 ManagedRepository (org.apache.archiva.repository.ManagedRepository)1 RepositoryException (org.apache.archiva.repository.RepositoryException)1 RepositoryNotFoundException (org.apache.archiva.repository.RepositoryNotFoundException)1