Search in sources :

Example 6 with RepositoryContentConsumer

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

the class ConsumerWantsFilePredicate method evaluate.

@Override
public boolean evaluate(RepositoryContentConsumer object) {
    boolean satisfies = false;
    RepositoryContentConsumer consumer = (RepositoryContentConsumer) object;
    if (wantsFile(consumer, FilenameUtils.separatorsToUnix(basefile.getRelativePath()))) {
        satisfies = true;
        // regardless of the timestamp, we record that it was wanted so it doesn't get counted as invalid
        wantedFileCount++;
        if (!consumer.isProcessUnmodified()) {
            // Timestamp finished points to the last successful scan, not this current one.
            if (basefile.lastModified() < changesSince) {
                // Skip file as no change has occurred.
                satisfies = false;
            }
        }
    }
    return satisfies;
}
Also used : RepositoryContentConsumer(org.apache.archiva.consumers.RepositoryContentConsumer)

Example 7 with RepositoryContentConsumer

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

the class ConsumerProcessFileClosure method execute.

@Override
public void execute(RepositoryContentConsumer input) {
    RepositoryContentConsumer consumer = (RepositoryContentConsumer) input;
    String id = consumer.getId();
    try {
        log.debug("Sending to consumer: {}", id);
        long startTime = System.currentTimeMillis();
        consumer.processFile(basefile.getRelativePath(), executeOnEntireRepo);
        long endTime = System.currentTimeMillis();
        if (consumerTimings != null) {
            Long value = consumerTimings.get(id);
            consumerTimings.put(id, (value != null ? value : 0) + endTime - startTime);
        }
        if (consumerCounts != null) {
            Long value = consumerCounts.get(id);
            consumerCounts.put(id, (value != null ? value : 0) + 1);
        }
    } catch (Exception e) {
        /* Intentionally Catch all exceptions.
             * So that the discoverer processing can continue.
             */
        log.error("Consumer [{}] had an error when processing file [" + "{}]: {}", id, basefile.getAbsolutePath(), e.getMessage(), e);
    }
}
Also used : RepositoryContentConsumer(org.apache.archiva.consumers.RepositoryContentConsumer)

Aggregations

RepositoryContentConsumer (org.apache.archiva.consumers.RepositoryContentConsumer)7 InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)3 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BaseFile (org.apache.archiva.common.utils.BaseFile)2 ConsumerWantsFilePredicate (org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate)2 ConsumerProcessFileClosure (org.apache.archiva.repository.scanner.functors.ConsumerProcessFileClosure)2 TriggerBeginScanClosure (org.apache.archiva.repository.scanner.functors.TriggerBeginScanClosure)2 TriggerScanCompletedClosure (org.apache.archiva.repository.scanner.functors.TriggerScanCompletedClosure)2 IOException (java.io.IOException)1 FileSystem (java.nio.file.FileSystem)1 FileSystems (java.nio.file.FileSystems)1 FileVisitResult (java.nio.file.FileVisitResult)1 FileVisitor (java.nio.file.FileVisitor)1 Files (java.nio.file.Files)1 PathMatcher (java.nio.file.PathMatcher)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1