Search in sources :

Example 6 with ContentGenerator

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);
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) ContentGenerator(org.commonjava.indy.content.ContentGenerator) StoreResource(org.commonjava.indy.content.StoreResource) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException)

Example 7 with ContentGenerator

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;
}
Also used : ContentGenerator(org.commonjava.indy.content.ContentGenerator) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Transfer(org.commonjava.maven.galley.model.Transfer)

Aggregations

ContentGenerator (org.commonjava.indy.content.ContentGenerator)7 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)6 IndyDataException (org.commonjava.indy.data.IndyDataException)5 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)5 Transfer (org.commonjava.maven.galley.model.Transfer)5 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)2 ArrayList (java.util.ArrayList)1 ContentDigester (org.commonjava.indy.content.ContentDigester)1 DirectContentAccess (org.commonjava.indy.content.DirectContentAccess)1 IndyLocationExpander (org.commonjava.indy.content.IndyLocationExpander)1 StoreResource (org.commonjava.indy.content.StoreResource)1 DefaultContentDigester (org.commonjava.indy.core.content.DefaultContentDigester)1 DefaultContentManager (org.commonjava.indy.core.content.DefaultContentManager)1 DefaultDirectContentAccess (org.commonjava.indy.core.content.DefaultDirectContentAccess)1 DefaultDownloadManager (org.commonjava.indy.core.content.DefaultDownloadManager)1 MemoryStoreDataManager (org.commonjava.indy.mem.data.MemoryStoreDataManager)1 Group (org.commonjava.indy.model.core.Group)1 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)1 PromoteConfig (org.commonjava.indy.promote.conf.PromoteConfig)1 PromoteValidationsManager (org.commonjava.indy.promote.validate.PromoteValidationsManager)1