use of org.commonjava.indy.content.ContentGenerator in project indy by Commonjava.
the class DefaultContentManager method list.
@Override
public List<StoreResource> list(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
List<StoreResource> listed;
if (group == store.getKey().getType()) {
List<ArtifactStore> members;
try {
members = storeManager.query().packageType(store.getPackageType()).enabledState(true).getOrderedConcreteStoresInGroup(store.getName());
} catch (final IndyDataException e) {
throw new IndyWorkflowException("Failed to lookup concrete members of: %s. Reason: %s", e, store, e.getMessage());
}
listed = new ArrayList<>();
for (final ContentGenerator generator : contentGenerators) {
final List<StoreResource> generated = generator.generateGroupDirectoryContent((Group) store, members, path, eventMetadata);
if (generated != null) {
listed.addAll(generated);
}
}
for (final ArtifactStore member : members) {
List<StoreResource> storeListing = null;
try {
storeListing = list(member, path, eventMetadata);
} catch (IndyWorkflowException e) {
e.filterLocationErrors();
}
if (storeListing != null) {
listed.addAll(storeListing);
}
}
} else {
if (checkListingMask(store, path)) {
listed = downloadManager.list(store, path);
} else {
listed = new ArrayList<>();
}
for (final ContentGenerator producer : contentGenerators) {
final List<StoreResource> produced = producer.generateDirectoryContent(store, path, listed, eventMetadata);
if (produced != null) {
listed.addAll(produced);
}
}
}
return dedupeListing(listed);
}
use of org.commonjava.indy.content.ContentGenerator in project indy by Commonjava.
the class DefaultContentManager method doRetrieve.
private Transfer doRetrieve(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
logger.info("Attempting to retrieve: {} from: {}", path, store.getKey());
if (!checkMask(store, path)) {
return null;
}
if (store.isDisabled()) {
logger.info("Content not available in repository layer due to store disabled for {}, path is {}", store, path);
return null;
}
Transfer item = null;
try {
item = downloadManager.retrieve(store, path, eventMetadata);
if (item == null) {
for (final ContentGenerator generator : contentGenerators) {
logger.debug("Attempting to generate content for path: {} in: {} via: {}", path, store, generator);
item = generator.generateFileContent(store, path, eventMetadata);
if (item != null) {
break;
}
}
}
} catch (IndyWorkflowException e) {
e.filterLocationErrors();
}
return item;
}
Aggregations