Search in sources :

Example 1 with FileNotFoundEvent

use of org.commonjava.maven.galley.event.FileNotFoundEvent in project galley by Commonjava.

the class TransferManagerImpl method retrieveFirst.

@Override
public Transfer retrieveFirst(final VirtualResource virt, final EventMetadata eventMetadata) throws TransferException {
    Transfer target = null;
    TransferException lastError = null;
    int tries = 0;
    for (final ConcreteResource res : virt) {
        tries++;
        if (res == null) {
            continue;
        }
        try {
            target = retrieve(res, true, eventMetadata);
            lastError = null;
            if (target != null && target.exists()) {
                return target;
            }
        } catch (final TransferException e) {
            logger.warn("Failed to retrieve: {}. {} more tries. (Reason: {})", res, (virt.toConcreteResources().size() - tries), e.getMessage());
            lastError = e;
        }
    }
    if (lastError != null) {
        throw lastError;
    }
    fileEventManager.fire(new FileNotFoundEvent(virt, eventMetadata));
    return null;
}
Also used : TransferException(org.commonjava.maven.galley.TransferException) FileNotFoundEvent(org.commonjava.maven.galley.event.FileNotFoundEvent) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource)

Aggregations

TransferException (org.commonjava.maven.galley.TransferException)1 FileNotFoundEvent (org.commonjava.maven.galley.event.FileNotFoundEvent)1 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)1 Transfer (org.commonjava.maven.galley.model.Transfer)1