use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class ContentController method rescanAll.
public void rescanAll(final EventMetadata eventMetadata) throws IndyWorkflowException {
try {
final List<ArtifactStore> stores = storeManager.query().concreteStores().getAll();
contentManager.rescanAll(stores, 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.IndyWorkflowException in project indy by Commonjava.
the class ReplicationController method addStoresFrom.
private <T extends ArtifactStore> void addStoresFrom(final List<ArtifactStore> result, final String remotesUrl, final ReplicationDTO dto, final Class<T> type) throws IndyWorkflowException {
final HttpGet req = newGet(remotesUrl, dto);
CloseableHttpClient client = null;
try {
String siteId = new URL(remotesUrl).getHost();
client = http.createClient(siteId);
CloseableHttpResponse response = client.execute(req, http.createContext(siteId));
final StatusLine statusLine = response.getStatusLine();
final int status = statusLine.getStatusCode();
if (status == HttpStatus.SC_OK) {
final String json = HttpResources.entityToString(response);
final StoreListingDTO<T> listing = serializer.readValue(json, serializer.getTypeFactory().constructParametricType(StoreListingDTO.class, type));
if (listing != null) {
result.addAll(listing.getItems());
}
} else {
throw new IndyWorkflowException(status, "Request: %s failed: %s", remotesUrl, statusLine);
}
} catch (final IOException | IndyHttpException e) {
throw new IndyWorkflowException("Failed to retrieve endpoints from: %s. Reason: %s", e, remotesUrl, e.getMessage());
} finally {
IOUtils.closeQuietly(client);
}
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class DefaultDirectContentAccess method listRaw.
@Override
public Map<String, List<StoreResource>> listRaw(ArtifactStore store, List<String> parentPathList) throws IndyWorkflowException {
CompletionService<List<StoreResource>> executor = new ExecutorCompletionService<>(executorService);
Map<String, Future<List<StoreResource>>> futures = new HashMap<>();
Logger logger = LoggerFactory.getLogger(getClass());
for (final String path : parentPathList) {
logger.debug("Requesting listing of {} in {}", path, store);
Future<List<StoreResource>> future = executor.submit(() -> {
logger.trace("Starting listing of {} in {}", path, store);
List<StoreResource> listRaw = listRaw(store, path);
logger.trace("Listing of {} in {} finished", path, store);
return listRaw;
});
futures.put(path, future);
}
final Map<String, List<StoreResource>> result = new HashMap<>();
for (String path : parentPathList) {
try {
logger.trace("Waiting for listing of {} in {}", path, store);
Future<List<StoreResource>> future = futures.get(path);
List<StoreResource> listing = future.get();
logger.debug("Listing of {} in {} received", path, store);
if (listing != null) {
result.put(path, listing);
}
} catch (InterruptedException ex) {
throw new IndyWorkflowException("Listing retrieval of %s in %s was interrupted", ex, path, store);
} catch (ExecutionException ex) {
throw new IndyWorkflowException("There was an error in listing retrieval of %s in %s: %s", ex, path, store, ex);
}
}
return result;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class DefaultDirectContentAccess method retrieveRaw.
@Override
public Transfer retrieveRaw(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.info("Attempting to retrieve: {} from: {}", path, store.getKey());
Transfer item = null;
try {
item = downloadManager.retrieve(store, path, eventMetadata);
} catch (IndyWorkflowException e) {
e.filterLocationErrors();
}
return item;
}
use of org.commonjava.indy.IndyWorkflowException in project indy by Commonjava.
the class DefaultDownloadManager method store.
/*
* (non-Javadoc)
* @see org.commonjava.indy.core.rest.util.FileManager#upload(java.util.List, java.lang.String,
* java.io.InputStream)
*/
@Override
public Transfer store(final List<? extends ArtifactStore> stores, final String path, final InputStream stream, final TransferOperation op, final EventMetadata eventMetadata) throws IndyWorkflowException {
final ContentQuality quality = getQuality(path);
HostedRepository selected = null;
for (final ArtifactStore store : stores) {
if (storeManager.isReadonly(store)) {
logger.info("The store {} is readonly, store operation not allowed");
continue;
}
if (storeIsSuitableFor(store, quality, op)) {
selected = (HostedRepository) store;
break;
}
}
if (selected == null) {
logger.warn("Cannot deploy. No valid deploy points in group.");
throw new IndyWorkflowException(ApplicationStatus.BAD_REQUEST.code(), "No deployment locations available.");
}
logger.info("Storing: {} in selected: {} with event metadata: {}", path, selected, eventMetadata);
store(selected, path, stream, op, eventMetadata);
return getStorageReference(selected.getKey(), path);
}
Aggregations