use of org.commonjava.indy.change.event.IndyStoreErrorEvent in project indy by Commonjava.
the class DefaultDownloadManager method list.
@Override
public List<StoreResource> list(final List<? extends ArtifactStore> stores, final String path) throws IndyWorkflowException {
final String dir = PathUtils.dirname(path);
final List<StoreResource> result = new ArrayList<>();
try {
final List<ListingResult> results = transfers.listAll(locationExpander.expand(new VirtualResource(LocationUtils.toLocations(stores), path)));
for (final ListingResult lr : results) {
if (lr != null && lr.getListing() != null) {
for (final String file : lr.getListing()) {
result.add(new StoreResource((KeyedLocation) lr.getLocation(), dir, file));
}
}
}
} catch (final BadGatewayException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Bad gateway: " + e.getMessage(), e);
} catch (final TransferTimeoutException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Timeout: " + e.getMessage(), e);
} catch (final TransferLocationException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Location Error: " + e.getMessage(), e);
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list ALL paths: {} from: {}. Reason: {}", e, path, stores, e.getMessage());
}
return dedupeListing(result);
}
use of org.commonjava.indy.change.event.IndyStoreErrorEvent in project indy by Commonjava.
the class DefaultDownloadManager method list.
@Override
public List<StoreResource> list(final ArtifactStore store, final String path) throws IndyWorkflowException {
final List<StoreResource> result = new ArrayList<>();
if (store.getKey().getType() == StoreType.group) {
try {
final List<ListingResult> results = transfers.listAll(locationExpander.expand(new VirtualResource(LocationUtils.toLocations(store), path)));
for (final ListingResult lr : results) {
if (lr != null && lr.getListing() != null) {
for (final String file : lr.getListing()) {
result.add(new StoreResource((KeyedLocation) lr.getLocation(), path, file));
}
}
}
} catch (final BadGatewayException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Bad gateway: " + e.getMessage(), e);
} catch (final TransferTimeoutException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Timeout: " + e.getMessage(), e);
} catch (final TransferLocationException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Location Error: " + e.getMessage(), e);
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list ALL paths: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
}
} else {
final KeyedLocation loc = LocationUtils.toLocation(store);
final StoreResource res = new StoreResource(loc, path);
if (store instanceof RemoteRepository) {
try {
final ListingResult lr = transfers.list(res);
if (lr != null && lr.getListing() != null) {
for (final String file : lr.getListing()) {
result.add(new StoreResource(loc, path, file));
}
}
} catch (final BadGatewayException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Bad gateway: " + e.getMessage(), e);
} catch (final TransferTimeoutException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Timeout: " + e.getMessage(), e);
} catch (final TransferLocationException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
logger.warn("Location Error: " + e.getMessage(), e);
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
}
} else {
try {
final ListingResult listing = transfers.list(res);
if (listing != null && listing.getListing() != null) {
for (final String child : listing.getListing()) {
result.add(new StoreResource(loc, path, child));
}
}
} catch (final TransferLocationException e) {
Location location = res.getLocation();
KeyedLocation kl = (KeyedLocation) location;
logger.warn("Timeout / bad gateway: " + e.getMessage(), e);
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to list path: {} from: {}. Reason: {}", e, path, store.getKey(), e.getMessage());
}
}
}
return dedupeListing(result);
}
use of org.commonjava.indy.change.event.IndyStoreErrorEvent in project indy by Commonjava.
the class DefaultDownloadManager method fireIndyStoreErrorEvent.
private void fireIndyStoreErrorEvent(TransferLocationException e) {
Location location = e.getLocation();
KeyedLocation kl = (KeyedLocation) location;
fileEventManager.fire(new IndyStoreErrorEvent(kl.getKey(), e));
}
use of org.commonjava.indy.change.event.IndyStoreErrorEvent in project indy by Commonjava.
the class DefaultDownloadManager method retrieve.
private Transfer retrieve(final ArtifactStore store, final String path, final boolean suppressFailures, final EventMetadata eventMetadata) throws IndyWorkflowException {
if (store.getKey().getType() == StoreType.group) {
return null;
}
if (!PathMaskChecker.checkMask(store, path)) {
return null;
}
final ConcreteResource res = new ConcreteResource(LocationUtils.toLocation(store), path);
if (store.getType() != hosted && nfc.isMissing(res)) {
return null;
}
Transfer target;
try {
if (store instanceof RemoteRepository) {
target = transfers.retrieve(res, suppressFailures, eventMetadata);
} else {
target = transfers.getCacheReference(res);
if (target == null || !target.exists()) {
target = null;
}
}
} catch (final TransferLocationException e) {
fileEventManager.fire(new IndyStoreErrorEvent(store.getKey(), e));
logger.warn("Timeout / bad gateway: " + res + ". Reason: " + e.getMessage(), e);
throw new IndyWorkflowException("Failed to retrieve path: {} from: {}. Reason: {}", e, path, store, e.getMessage());
} catch (final TransferContentException e) {
logger.warn("Content-Length mismatch: " + res + ". Reason: " + e.getMessage() + "\nNOTE: This may be a network error; will retry download on next request.", e);
throw new IndyWorkflowException("Failed to retrieve path: {} from: {}. Reason: {}", e, path, store, e.getMessage());
} catch (final TransferException e) {
logger.error(e.getMessage(), e);
throw new IndyWorkflowException("Failed to retrieve path: {} from: {}. Reason: {}", e, path, store, e.getMessage());
}
return target;
}
Aggregations