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());
}
}
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());
}
}
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;
}
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);
}
}
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);
}
Aggregations