use of org.commonjava.maven.galley.model.VirtualResource in project galley by Commonjava.
the class ArtifactManagerImpl method resolveFirstVirtualResource.
private VirtualResource resolveFirstVirtualResource(List<? extends Location> locations, ArtifactRef ref, final EventMetadata eventMetadata) throws TransferException {
locations = expander.expand(locations);
if (ref.isVariableVersion()) {
final ProjectVersionRefLocation resolved = resolveSingleVariableVersion(locations, ref, eventMetadata);
if (resolved != null) {
locations = Collections.singletonList(resolved.getLocation());
ref = (ArtifactRef) resolved.getRef();
}
}
return new VirtualResource(expander.expand(locations), formatArtifactPath(ref, mapper));
}
use of org.commonjava.maven.galley.model.VirtualResource in project galley by Commonjava.
the class ArtifactMetadataManagerImpl method store.
/* (non-Javadoc)
* @see org.commonjava.maven.galley.ArtifactMetadataManager#store(org.commonjava.maven.galley.model.Location, java.lang.String, java.lang.String, java.io.InputStream)
*/
@Override
public Transfer store(final Location location, final String groupId, final String filename, final InputStream stream, final EventMetadata eventMetadata) throws TransferException {
final VirtualResource virt = new VirtualResource(expander.expand(location), formatMetadataPath(groupId, filename));
final ConcreteResource selected = ArtifactRules.selectStorageResource(virt);
if (selected == null) {
logger.warn("Cannot deploy. No valid deploy points in group.");
throw new TransferException("No deployment locations available for: {}", virt.toConcreteResources());
}
return transferManager.store(selected, stream, eventMetadata);
}
use of org.commonjava.maven.galley.model.VirtualResource in project galley by Commonjava.
the class ArtifactMetadataManagerImpl method store.
/* (non-Javadoc)
* @see org.commonjava.maven.galley.ArtifactMetadataManager#store(org.commonjava.maven.galley.model.Location, org.commonjava.maven.atlas.ident.ref.ProjectRef, java.lang.String, java.io.InputStream)
*/
@Override
public Transfer store(final Location location, final ProjectRef ref, final String filename, final InputStream stream, final EventMetadata eventMetadata) throws TransferException {
final VirtualResource virt = new VirtualResource(expander.expand(location), formatMetadataPath(ref, filename));
final ConcreteResource selected = ArtifactRules.selectStorageResource(virt);
if (selected == null) {
logger.warn("Cannot deploy. No valid deploy points in group.");
throw new TransferException("No deployment locations available for: {}", virt.toConcreteResources());
}
return transferManager.store(selected, stream, eventMetadata);
}
use of org.commonjava.maven.galley.model.VirtualResource 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.maven.galley.model.VirtualResource in project galley by Commonjava.
the class ArtifactBatch method setArtifactToResourceMapping.
public void setArtifactToResourceMapping(final Map<ArtifactRef, Resource> mappings) {
artifactMappings = new HashMap<>();
final Set<ConcreteResource> resources = new HashSet<>();
for (final Entry<ArtifactRef, Resource> entry : mappings.entrySet()) {
final ArtifactRef artifact = entry.getKey();
final Resource resource = entry.getValue();
if (resource instanceof ConcreteResource) {
artifactMappings.put(artifact, Collections.singletonList((ConcreteResource) resource));
resources.add((ConcreteResource) resource);
} else {
final List<ConcreteResource> res = ((VirtualResource) resource).toConcreteResources();
artifactMappings.put(artifact, res);
resources.addAll(res);
}
}
setResources(resources);
}
Aggregations