Search in sources :

Example 86 with SourceUnavailableException

use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.

the class CatalogBundle method isFederatedSourceReady.

private boolean isFederatedSourceReady(String id) throws InvalidSyntaxException {
    CatalogFramework framework = getService(CatalogFramework.class);
    FederatedSource source = serviceManager.getServiceReferences(FederatedSource.class, null).stream().map(serviceManager::getService).filter(src -> id.equals(src.getId())).findFirst().orElse(null);
    if (source != null && framework != null) {
        SourceInfoRequestEnterprise request = new SourceInfoRequestEnterprise(true);
        try {
            SourceInfoResponse sources = framework.getSourceInfo(request);
            return sources.getSourceInfo().stream().filter(descriptor -> descriptor.getSourceId().equals(source.getId())).map(descriptor -> descriptor.isAvailable() && source.isAvailable()).findFirst().orElse(false);
        } catch (SourceUnavailableException ignore) {
        }
    }
    return false;
}
Also used : SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) Awaitility.await(org.awaitility.Awaitility.await) SourceInfoRequestLocal(ddf.catalog.operation.impl.SourceInfoRequestLocal) Logger(org.slf4j.Logger) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) CatalogFramework(ddf.catalog.CatalogFramework) FederatedSource(ddf.catalog.source.FederatedSource) SourceInfoRequestEnterprise(ddf.catalog.operation.impl.SourceInfoRequestEnterprise) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) CatalogProvider(ddf.catalog.source.CatalogProvider) Configuration(org.osgi.service.cm.Configuration) Map(java.util.Map) Optional(java.util.Optional) DictionaryMap(org.codice.ddf.configuration.DictionaryMap) ServiceReference(org.osgi.framework.ServiceReference) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) FederatedSource(ddf.catalog.source.FederatedSource) CatalogFramework(ddf.catalog.CatalogFramework) SourceInfoRequestEnterprise(ddf.catalog.operation.impl.SourceInfoRequestEnterprise) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse)

Example 87 with SourceUnavailableException

use of ddf.catalog.source.SourceUnavailableException in project ddf by codice.

the class DuplicationValidator method query.

private SourceResponse query(Set<Attribute> attributes) {
    final Filter filter = filterBuilder.allOf(filterBuilder.anyOf(buildFilters(attributes)));
    LOGGER.debug("filter {}", filter);
    QueryImpl query = new QueryImpl(filter);
    query.setRequestsTotalResultsCount(false);
    QueryRequest request = new QueryRequestImpl(query);
    SourceResponse response = null;
    try {
        response = catalogFramework.query(request);
    } catch (FederationException | SourceUnavailableException | UnsupportedQueryException e) {
        LOGGER.debug("Query failed ", e);
    }
    return response;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponse(ddf.catalog.operation.SourceResponse) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FederationException(ddf.catalog.federation.FederationException)

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