use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class SearchCommand method getHits.
/**
* Returns the total hits matching {@param filter} or -1 if unknown
*/
private static long getHits(final Filter filter, final CatalogFacade catalogProvider) {
try {
final QueryImpl hitsQuery = new QueryImpl(filter);
hitsQuery.setRequestsTotalResultsCount(true);
hitsQuery.setPageSize(1);
return catalogProvider.query(new QueryRequestImpl(hitsQuery)).getHits();
} catch (UnsupportedQueryException | SourceUnavailableException | FederationException e) {
LOGGER.debug("Unable to get hits for catalog:search command", e);
return -1;
}
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class ValidateCommand method getMetacardsFromCatalogInternal.
private List<Metacard> getMetacardsFromCatalogInternal() throws CatalogCommandException {
List<Metacard> results = new ArrayList<>();
try {
QueryImpl query = new QueryImpl(getFilter());
SourceResponse response = getCatalog().query(new QueryRequestImpl(query));
List<Result> resultList = response.getResults();
if (resultList != null) {
results.addAll(resultList.stream().map(Result::getMetacard).filter(Objects::nonNull).collect(Collectors.toList()));
}
} catch (UnsupportedQueryException | SourceUnavailableException | FederationException | CQLException | ParseException e) {
throw new CatalogCommandException("Error executing catalog:validate", e);
}
return results;
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class OperationsStorageSupport method prepareStorageRequest.
<T extends StorageRequest> T prepareStorageRequest(T storageRequest, Supplier<List<ContentItem>> getContentItems) throws IngestException, SourceUnavailableException {
validateStorageRequest(storageRequest, getContentItems);
queryOperations.setFlagsOnRequest(storageRequest);
if (Requests.isLocal(storageRequest) && (!sourceOperations.isSourceAvailable(sourceOperations.getCatalog()) || !isStorageAvailable(sourceOperations.getStorage()))) {
String message = "Local provider is not available, cannot perform storage operation.";
SourceUnavailableException sourceUnavailableException = new SourceUnavailableException(message);
if (INGEST_LOGGER.isWarnEnabled()) {
INGEST_LOGGER.warn(message, sourceUnavailableException);
}
throw sourceUnavailableException;
}
return storageRequest;
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class QueryOperations method createUnavailableProcessingDetails.
private ProcessingDetailsImpl createUnavailableProcessingDetails(Source source) {
ProcessingDetailsImpl exception = new ProcessingDetailsImpl();
SourceUnavailableException sue = new SourceUnavailableException("Source \"" + source.getId() + "\" is unavailable and will not be queried");
exception.setException(sue);
exception.setSourceId(source.getId());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Source Unavailable", sue);
}
return exception;
}
use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.
the class DeleteOperations method performLocalDelete.
private DeleteResponse performLocalDelete(DeleteRequest deleteRequest, DeleteStorageRequest deleteStorageRequest) throws IngestException {
if (!Requests.isLocal(deleteRequest)) {
return null;
}
try {
sourceOperations.getStorage().delete(deleteStorageRequest);
} catch (StorageException e) {
LOGGER.info("Unable to delete stored content items. Not removing stored metacards", e);
throw new InternalIngestException("Unable to delete stored content items. Not removing stored metacards.", e);
}
DeleteResponse deleteResponse = sourceOperations.getCatalog().delete(deleteRequest);
deleteResponse = injectAttributes(deleteResponse);
try {
historian.version(deleteResponse);
} catch (SourceUnavailableException e) {
LOGGER.debug("Could not version deleted item!", e);
throw new IngestException("Could not version deleted Item!");
}
return deleteResponse;
}
Aggregations