use of org.commonjava.maven.galley.model.VirtualResource in project galley by Commonjava.
the class ArtifactManagerImpl method resolveArtifactMappings.
private void resolveArtifactMappings(final ArtifactBatch batch, final EventMetadata eventMetadata) throws TransferException {
final Map<ArtifactRef, Resource> resources = new HashMap<ArtifactRef, Resource>(batch.size());
for (final ArtifactRef artifact : batch) {
final VirtualResource virt = resolveFirstVirtualResource(batch.getLocations(artifact), artifact, eventMetadata);
resources.put(artifact, virt);
}
batch.setArtifactToResourceMapping(resources);
}
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 galley by Commonjava.
the class ArtifactManagerImpl method listAvailableArtifacts.
// TODO: This may be incompatible with snapshots, which will have LOTS of entries...
@Override
public Map<TypeAndClassifier, ConcreteResource> listAvailableArtifacts(final Location location, final ProjectVersionRef ref, final EventMetadata metadata) throws TransferException {
final List<ListingResult> listingResults = transferManager.listAll(new VirtualResource(expander.expand(location), formatArtifactPath(ref.asProjectVersionRef(), mapper)), metadata);
if (listingResults == null || listingResults.isEmpty()) {
return Collections.emptyMap();
}
final Map<TypeAndClassifier, ConcreteResource> result = new LinkedHashMap<TypeAndClassifier, ConcreteResource>();
final String prefix = String.format("%s-%s", ref.getArtifactId(), ref.getVersionString());
for (final ListingResult listingResult : listingResults) {
//FIXME: snapshot handling.
for (final String fname : listingResult.getListing()) {
if (fname.startsWith(prefix)) {
final String remainder = fname.substring(prefix.length());
String classifier = null;
String type = null;
if (remainder.startsWith("-")) {
// must have a classifier.
final int extPos = remainder.indexOf('.');
if (extPos < 2) {
logger.warn("Listing found unparsable filename: '{}' from: {}. Skipping", fname, location);
continue;
}
classifier = remainder.substring(1, extPos);
type = remainder.substring(extPos + 1);
} else if (remainder.startsWith(".")) {
type = remainder.substring(1);
}
final ConcreteResource res = (ConcreteResource) listingResult.getResource().getChild(fname);
result.put(new SimpleTypeAndClassifier(type, classifier), res);
}
}
}
return result;
}
use of org.commonjava.maven.galley.model.VirtualResource in project indy by Commonjava.
the class IndyLocationExpander method expand.
/** Using the same basic logic as {@link IndyLocationExpander#expand(Collection)}, convert the specified {@link Resource} into a
* {@link VirtualResource} that contains references to the expanded {@link Location} list.
*
* @see IndyLocationExpander#expand(Collection)
*/
@Override
public VirtualResource expand(final Resource resource) throws TransferException {
List<Location> locations;
if (resource instanceof VirtualResource) {
final List<ConcreteResource> concrete = ((VirtualResource) resource).toConcreteResources();
final List<ConcreteResource> result = new ArrayList<ConcreteResource>();
for (final ConcreteResource cr : concrete) {
final List<Location> expanded = expand(cr.getLocation());
for (final Location location : expanded) {
result.add(new ConcreteResource(location, cr.getPath()));
}
}
return new VirtualResource(result);
} else {
final ConcreteResource cr = (ConcreteResource) resource;
locations = expand(cr.getLocation());
return new VirtualResource(locations, cr.getPath());
}
}
Aggregations