Search in sources :

Example 61 with SourceUnavailableException

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;
    }
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException)

Example 62 with SourceUnavailableException

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;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) SourceResponse(ddf.catalog.operation.SourceResponse) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) FederationException(ddf.catalog.federation.FederationException) Result(ddf.catalog.data.Result) CatalogCommandException(org.codice.ddf.commands.util.CatalogCommandException) Metacard(ddf.catalog.data.Metacard) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Objects(java.util.Objects) CQLException(org.geotools.filter.text.cql2.CQLException) ParseException(java.text.ParseException)

Example 63 with SourceUnavailableException

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;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException)

Example 64 with SourceUnavailableException

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;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl)

Example 65 with SourceUnavailableException

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;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) DeleteResponse(ddf.catalog.operation.DeleteResponse) InternalIngestException(ddf.catalog.source.InternalIngestException) InternalIngestException(ddf.catalog.source.InternalIngestException) IngestException(ddf.catalog.source.IngestException) StorageException(ddf.catalog.content.StorageException)

Aggregations

SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)87 FederationException (ddf.catalog.federation.FederationException)39 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)38 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)33 Metacard (ddf.catalog.data.Metacard)30 IngestException (ddf.catalog.source.IngestException)30 QueryResponse (ddf.catalog.operation.QueryResponse)29 QueryImpl (ddf.catalog.operation.impl.QueryImpl)28 ArrayList (java.util.ArrayList)26 Test (org.junit.Test)26 QueryRequest (ddf.catalog.operation.QueryRequest)24 CatalogFramework (ddf.catalog.CatalogFramework)22 HashMap (java.util.HashMap)19 Result (ddf.catalog.data.Result)18 Filter (org.opengis.filter.Filter)18 CreateResponse (ddf.catalog.operation.CreateResponse)17 List (java.util.List)16 Map (java.util.Map)16 ContentType (ddf.catalog.data.ContentType)14 IOException (java.io.IOException)14