Search in sources :

Example 21 with FederatedSource

use of ddf.catalog.source.FederatedSource 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)

Aggregations

FederatedSource (ddf.catalog.source.FederatedSource)21 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 HashSet (java.util.HashSet)10 Date (java.util.Date)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)7 HashMap (java.util.HashMap)7 CatalogFramework (ddf.catalog.CatalogFramework)6 Metacard (ddf.catalog.data.Metacard)6 SourceInfoRequest (ddf.catalog.operation.SourceInfoRequest)6 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)6 QueryImpl (ddf.catalog.operation.impl.QueryImpl)6 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)6 CatalogProvider (ddf.catalog.source.CatalogProvider)6 List (java.util.List)6 Set (java.util.Set)6 Result (ddf.catalog.data.Result)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)5 QueryRequest (ddf.catalog.operation.QueryRequest)5