Search in sources :

Example 1 with ListingJob

use of org.commonjava.maven.galley.spi.transport.ListingJob in project galley by Commonjava.

the class ListingHandler method list.

public ListingResult list(final ConcreteResource resource, final Transfer target, final int timeoutSeconds, final Transport transport, final boolean suppressFailures) throws TransferException {
    if (nfc.isMissing(resource)) {
        logger.debug("NFC: Already marked as missing: {}", resource);
        return null;
    }
    if (transport == null) {
        logger.warn("No transports available to handle: {} with location type: {}", resource, resource.getLocation().getClass().getSimpleName());
        return null;
    }
    logger.debug("LIST {}", resource);
    final ListingJob job = transport.createListingJob(resource, target, timeoutSeconds);
    // TODO: execute this stuff in a thread just like downloads/publishes. Requires cache storage...
    try {
        final ListingResult result = job.call();
        if (job.getError() != null) {
            logger.debug("NFC: Download error. Marking as missing: {}", resource);
            nfc.addMissing(resource);
            if (!suppressFailures) {
                throw job.getError();
            }
        } else if (result == null) {
            logger.debug("NFC: Download did not complete. Marking as missing: {}", resource);
            nfc.addMissing(resource);
        }
        return result;
    } catch (final TimeoutException e) {
        if (!suppressFailures) {
            throw new TransferTimeoutException(target, "Timed-out download: {}. Reason: {}", e, resource, e.getMessage());
        }
    } catch (final TransferException e) {
        if (!suppressFailures) {
            throw e;
        }
    } catch (final Exception e) {
        if (!suppressFailures) {
            throw new TransferException("Failed listing: {}. Reason: {}", e, resource, e.getMessage());
        }
    }
    return null;
}
Also used : TransferTimeoutException(org.commonjava.maven.galley.TransferTimeoutException) TransferException(org.commonjava.maven.galley.TransferException) ListingResult(org.commonjava.maven.galley.model.ListingResult) ListingJob(org.commonjava.maven.galley.spi.transport.ListingJob) TimeoutException(java.util.concurrent.TimeoutException) TransferTimeoutException(org.commonjava.maven.galley.TransferTimeoutException) TransferLocationException(org.commonjava.maven.galley.TransferLocationException) TransferException(org.commonjava.maven.galley.TransferException) TimeoutException(java.util.concurrent.TimeoutException) TransferTimeoutException(org.commonjava.maven.galley.TransferTimeoutException)

Aggregations

TimeoutException (java.util.concurrent.TimeoutException)1 TransferException (org.commonjava.maven.galley.TransferException)1 TransferLocationException (org.commonjava.maven.galley.TransferLocationException)1 TransferTimeoutException (org.commonjava.maven.galley.TransferTimeoutException)1 ListingResult (org.commonjava.maven.galley.model.ListingResult)1 ListingJob (org.commonjava.maven.galley.spi.transport.ListingJob)1