Search in sources :

Example 11 with IndyDataException

use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.

the class AdminController method store.

public boolean store(final ArtifactStore store, final String user, final boolean skipExisting) throws IndyWorkflowException {
    try {
        String changelog = store.getMetadata(ArtifactStore.METADATA_CHANGELOG);
        if (changelog == null) {
            changelog = "Changelog not provided";
        }
        final ChangeSummary summary = new ChangeSummary(user, changelog);
        logger.info("Persisting artifact store: {} using: {}", store, storeManager);
        return storeManager.storeArtifactStore(store, summary, skipExisting, true, new EventMetadata());
    } catch (final IndyDataException e) {
        throw new IndyWorkflowException(ApplicationStatus.SERVER_ERROR.code(), "Failed to store: {}. Reason: {}", e, store.getKey(), e.getMessage());
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) EventMetadata(org.commonjava.maven.galley.event.EventMetadata)

Example 12 with IndyDataException

use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.

the class ContentController method deleteAll.

public void deleteAll(final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
    try {
        final List<ArtifactStore> stores = storeManager.query().concreteStores().getAll();
        contentManager.deleteAll(stores, path, eventMetadata);
    } catch (final IndyDataException e) {
        throw new IndyWorkflowException(ApplicationStatus.SERVER_ERROR.code(), "Failed to retrieve list of concrete stores. Reason: {}", e, e.getMessage());
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException)

Example 13 with IndyDataException

use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.

the class NfcController method getMissing.

public NotFoundCacheDTO getMissing(final StoreKey key) throws IndyWorkflowException {
    final NotFoundCacheDTO dto = new NotFoundCacheDTO();
    if (key.getType() == group) {
        List<ArtifactStore> stores;
        try {
            stores = storeManager.query().packageType(key.getPackageType()).getOrderedConcreteStoresInGroup(key.getName());
        } catch (final IndyDataException e) {
            throw new IndyWorkflowException("Failed to retrieve concrete constituent ArtifactStores for: %s.", e, key);
        }
        final List<? extends KeyedLocation> locations = toLocations(stores);
        for (final KeyedLocation location : locations) {
            final Set<String> missing = cache.getMissing(location);
            if (missing != null && !missing.isEmpty()) {
                final List<String> paths = new ArrayList<String>(missing);
                Collections.sort(paths);
                dto.addSection(location.getKey(), paths);
            }
        }
    } else {
        ArtifactStore store;
        try {
            store = storeManager.getArtifactStore(key);
        } catch (final IndyDataException e) {
            throw new IndyWorkflowException("Failed to retrieve ArtifactStore: %s.", e, key);
        }
        if (store != null) {
            final Set<String> missing = cache.getMissing(toLocation(store));
            final List<String> paths = new ArrayList<String>(missing);
            Collections.sort(paths);
            dto.addSection(key, paths);
        }
    }
    return dto;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) ArrayList(java.util.ArrayList) NotFoundCacheDTO(org.commonjava.indy.model.core.dto.NotFoundCacheDTO)

Example 14 with IndyDataException

use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.

the class DefaultContentManager method exists.

@Override
public // TODO: to add content generation handling here, for things like merged metadata, checksum files, etc.
boolean exists(ArtifactStore store, String path) throws IndyWorkflowException {
    if (!checkMask(store, path)) {
        return false;
    }
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.debug("Checking existence of: {} in: {}", path, store.getKey());
    if (store instanceof Group) {
        try {
            final List<ArtifactStore> allMembers = storeManager.query().packageType(store.getPackageType()).enabledState(true).getOrderedConcreteStoresInGroup(store.getName());
            logger.debug("Trying to retrieve suitable transfer for: {} in group: {} members:\n{}", path, allMembers, store.getName());
            for (ArtifactStore member : allMembers) {
                if (exists(member, path)) {
                    return true;
                }
            }
            return false;
        } catch (final IndyDataException e) {
            throw new IndyWorkflowException("Failed to lookup concrete members of: %s. Reason: %s", e, store, e.getMessage());
        }
    } else {
        return downloadManager.exists(store, path);
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) Logger(org.slf4j.Logger)

Example 15 with IndyDataException

use of org.commonjava.indy.data.IndyDataException in project indy by Commonjava.

the class StatsController method getEndpointsListing.

public EndpointViewListing getEndpointsListing(final String baseUri, final UriFormatter uriFormatter) throws IndyWorkflowException {
    final List<ArtifactStore> stores = new ArrayList<ArtifactStore>();
    try {
        stores.addAll(dataManager.getAllArtifactStores());
    } catch (final IndyDataException e) {
        throw new IndyWorkflowException(ApplicationStatus.SERVER_ERROR.code(), "Failed to retrieve all endpoints: {}", e, e.getMessage());
    }
    final List<EndpointView> points = new ArrayList<EndpointView>();
    for (final ArtifactStore store : stores) {
        final StoreKey key = store.getKey();
        final String resourceUri = uriFormatter.formatAbsolutePathTo(baseUri, "content", key.getPackageType(), key.getType().singularEndpointName(), key.getName());
        final EndpointView point = new EndpointView(store, resourceUri);
        if (!points.contains(point)) {
            points.add(point);
        }
    }
    return new EndpointViewListing(points);
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) EndpointView(org.commonjava.indy.model.core.dto.EndpointView) EndpointViewListing(org.commonjava.indy.model.core.dto.EndpointViewListing) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) ArrayList(java.util.ArrayList) StoreKey(org.commonjava.indy.model.core.StoreKey)

Aggregations

IndyDataException (org.commonjava.indy.data.IndyDataException)75 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)50 StoreKey (org.commonjava.indy.model.core.StoreKey)30 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)26 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)24 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)24 Transfer (org.commonjava.maven.galley.model.Transfer)19 ArrayList (java.util.ArrayList)17 Group (org.commonjava.indy.model.core.Group)17 IOException (java.io.IOException)16 Logger (org.slf4j.Logger)16 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)14 HashSet (java.util.HashSet)10 List (java.util.List)7 StoreType (org.commonjava.indy.model.core.StoreType)7 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)7 HostedRepository (org.commonjava.indy.model.core.HostedRepository)6 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)6 ContentGenerator (org.commonjava.indy.content.ContentGenerator)5 InputStream (java.io.InputStream)4