Search in sources :

Example 6 with InvalidRepositoryContentConsumer

use of org.apache.archiva.consumers.InvalidRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testTimestampRepositoryScannerProcessUnmodified.

@Test
public void testTimestampRepositoryScannerProcessUnmodified() throws Exception {
    ManagedRepository repository = createSimpleRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setProcessUnmodified(true);
    consumer.setIncludes(ARTIFACT_PATTERNS);
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), getTimestampAsMillis("20061101.000000"));
    assertNotNull("Stats should not be null.", stats);
    assertEquals("Stats.totalFileCount", 4, stats.getTotalFileCount());
    assertEquals("Stats.newFileCount", 3, stats.getNewFileCount());
    assertEquals("Processed Count", 3, consumer.getProcessCount());
    assertEquals("Processed Count (of invalid items)", 1, badconsumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Example 7 with InvalidRepositoryContentConsumer

use of org.apache.archiva.consumers.InvalidRepositoryContentConsumer in project archiva by apache.

the class ArchivaCli method doScan.

private void doScan(String path, String[] consumers) throws ConsumerException, MalformedURLException {
    BasicManagedRepository repo = new BasicManagedRepository(Paths.get(path).getFileName().toString(), "Archiva CLI Provided Repo", Paths.get(path).getParent());
    repo.setLocation(Paths.get(path).toUri());
    List<KnownRepositoryContentConsumer> knownConsumerList = new ArrayList<>();
    knownConsumerList.addAll(getConsumerList(consumers));
    List<InvalidRepositoryContentConsumer> invalidConsumerList = Collections.emptyList();
    List<String> ignoredContent = new ArrayList<>();
    ignoredContent.addAll(Arrays.asList(RepositoryScanner.IGNORABLE_CONTENT));
    RepositoryScanner scanner = applicationContext.getBean(RepositoryScanner.class);
    try {
        RepositoryScanStatistics stats = scanner.scan(repo, knownConsumerList, invalidConsumerList, ignoredContent, RepositoryScanner.FRESH_SCAN);
        LOGGER.info(stats.toDump(repo));
    } catch (RepositoryScannerException e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) RepositoryScanner(org.apache.archiva.repository.scanner.RepositoryScanner) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) RepositoryScanStatistics(org.apache.archiva.repository.scanner.RepositoryScanStatistics) ArrayList(java.util.ArrayList) RepositoryScannerException(org.apache.archiva.repository.scanner.RepositoryScannerException) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer)

Example 8 with InvalidRepositoryContentConsumer

use of org.apache.archiva.consumers.InvalidRepositoryContentConsumer in project archiva by apache.

the class RepositoryContentConsumers method getSelectedInvalidConsumers.

/**
 * Get the list of {@link InvalidRepositoryContentConsumer} objects that are
 * selected according to the active configuration.
 *
 * @return the list of {@link InvalidRepositoryContentConsumer} that have been selected
 * by the active configuration.
 */
public synchronized List<InvalidRepositoryContentConsumer> getSelectedInvalidConsumers() throws RepositoryAdminException {
    // FIXME only for testing
    if (selectedInvalidConsumers != null) {
        return selectedInvalidConsumers;
    }
    List<InvalidRepositoryContentConsumer> ret = new ArrayList<>();
    List<String> invalidSelected = getSelectedInvalidConsumerIds();
    for (InvalidRepositoryContentConsumer consumer : getAvailableInvalidConsumers()) {
        if (invalidSelected.contains(consumer.getId())) {
            ret.add(consumer);
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer)

Example 9 with InvalidRepositoryContentConsumer

use of org.apache.archiva.consumers.InvalidRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testTimestampRepositoryScannerFreshScan.

@Test
public void testTimestampRepositoryScannerFreshScan() throws Exception {
    ManagedRepository repository = createSimpleRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setIncludes(ARTIFACT_PATTERNS);
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), RepositoryScanner.FRESH_SCAN);
    assertNotNull("Stats should not be null.", stats);
    assertEquals("Stats.totalFileCount", 4, stats.getTotalFileCount());
    assertEquals("Stats.newFileCount", 4, stats.getNewFileCount());
    assertEquals("Processed Count", 3, consumer.getProcessCount());
    assertEquals("Processed Count (of invalid items)", 1, badconsumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Example 10 with InvalidRepositoryContentConsumer

use of org.apache.archiva.consumers.InvalidRepositoryContentConsumer in project archiva by apache.

the class RepositoryScannerTest method testDefaultRepositoryArtifactScanner.

@Test
public void testDefaultRepositoryArtifactScanner() throws Exception {
    List<String> actualArtifactPaths = new ArrayList<>();
    actualArtifactPaths.add("invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar");
    actualArtifactPaths.add("invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar");
    actualArtifactPaths.add("invalid/invalid/1.0/invalid-1.0b.jar");
    actualArtifactPaths.add("invalid/invalid/1.0/invalid-2.0.jar");
    actualArtifactPaths.add("invalid/invalid-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar");
    actualArtifactPaths.add("org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar");
    actualArtifactPaths.add("org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar");
    actualArtifactPaths.add("org/apache/maven/A/1.0/A-1.0.war");
    actualArtifactPaths.add("org/apache/maven/A/1.0/A-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/B/2.0/B-2.0.pom");
    actualArtifactPaths.add("org/apache/maven/B/1.0/B-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar");
    actualArtifactPaths.add("org/apache/maven/C/1.0/C-1.0.war");
    actualArtifactPaths.add("org/apache/maven/C/1.0/C-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/discovery/1.0/discovery-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0-test-sources.jar");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0.jar");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0-sources.jar");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0.zip");
    actualArtifactPaths.add("org/apache/maven/testing/1.0/testing-1.0.tar.gz");
    actualArtifactPaths.add("org/apache/maven/samplejar/2.0/samplejar-2.0.pom");
    actualArtifactPaths.add("org/apache/maven/samplejar/2.0/samplejar-2.0.jar");
    actualArtifactPaths.add("org/apache/maven/samplejar/1.0/samplejar-1.0.pom");
    actualArtifactPaths.add("org/apache/maven/samplejar/1.0/samplejar-1.0.jar");
    actualArtifactPaths.add("org/apache/testgroup/discovery/1.0/discovery-1.0.pom");
    actualArtifactPaths.add("javax/sql/jdbc/2.0/jdbc-2.0.jar");
    ManagedRepository repository = createDefaultRepository();
    List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>();
    KnownScanConsumer consumer = new KnownScanConsumer();
    consumer.setIncludes(ARTIFACT_PATTERNS);
    knownConsumers.add(consumer);
    List<InvalidRepositoryContentConsumer> invalidConsumers = new ArrayList<>();
    InvalidScanConsumer badconsumer = new InvalidScanConsumer();
    invalidConsumers.add(badconsumer);
    RepositoryScanner scanner = lookupRepositoryScanner();
    RepositoryScanStatistics stats = scanner.scan(repository, knownConsumers, invalidConsumers, getIgnoreList(), RepositoryScanner.FRESH_SCAN);
    assertNotNull("Stats should not be null.", stats);
    assertMinimumHits("Stats.totalFileCount", actualArtifactPaths.size(), stats.getTotalFileCount());
    assertMinimumHits("Processed Count", actualArtifactPaths.size(), consumer.getProcessCount());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer) Test(org.junit.Test)

Aggregations

InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)15 ArrayList (java.util.ArrayList)12 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)12 BasicManagedRepository (org.apache.archiva.repository.BasicManagedRepository)11 Test (org.junit.Test)11 ManagedRepository (org.apache.archiva.repository.ManagedRepository)9 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)8 Path (java.nio.file.Path)2 RepositoryScannerException (org.apache.archiva.repository.scanner.RepositoryScannerException)2 Date (java.util.Date)1 BaseFile (org.apache.archiva.common.utils.BaseFile)1 RepositoryContentConsumer (org.apache.archiva.consumers.RepositoryContentConsumer)1 ConsumerWantsFilePredicate (org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate)1 RepositoryConversionException (org.apache.archiva.converter.RepositoryConversionException)1 RepositoryScanStatistics (org.apache.archiva.repository.scanner.RepositoryScanStatistics)1 RepositoryScanner (org.apache.archiva.repository.scanner.RepositoryScanner)1 ConsumerProcessFileClosure (org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure)1 TriggerBeginScanClosure (org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure)1 TriggerScanCompletedClosure (org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1