Search in sources :

Example 21 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testUnconfiguredGetContentTypes.

@Test(expected = IllegalStateException.class)
public void testUnconfiguredGetContentTypes() throws IngestException {
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
    provider.getContentTypes();
}
Also used : CatalogProvider(ddf.catalog.source.CatalogProvider) Test(org.junit.Test)

Example 22 with CatalogProvider

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

the class RemoteSolrCatalogProviderTest method testUnconfiguredUpdate.

@Test(expected = IllegalStateException.class)
public void testUnconfiguredUpdate() throws IngestException {
    CatalogProvider provider = new MockedRemoteSolrCatalogProvider(null);
    provider.update(mock(UpdateRequest.class));
}
Also used : CatalogProvider(ddf.catalog.source.CatalogProvider) UpdateRequest(ddf.catalog.operation.UpdateRequest) Test(org.junit.Test)

Example 23 with CatalogProvider

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

the class CatalogBundle method waitForCatalogProvider.

public CatalogProvider waitForCatalogProvider() throws InterruptedException {
    LOGGER.info("Waiting for CatalogProvider to become available.");
    serviceManager.printInactiveBundlesInfo();
    CatalogProvider provider = null;
    CatalogFramework framework = null;
    long timeoutLimit = System.currentTimeMillis() + CATALOG_PROVIDER_TIMEOUT;
    boolean available = false;
    while (!available) {
        if (provider == null) {
            ServiceReference<CatalogFramework> frameworkRef = serviceManager.getServiceReference(CatalogFramework.class);
            ServiceReference<CatalogProvider> providerRef = serviceManager.getServiceReference(CatalogProvider.class);
            if (providerRef != null) {
                provider = serviceManager.getService(providerRef);
            }
            if (frameworkRef != null) {
                framework = serviceManager.getService(frameworkRef);
            }
        }
        if (framework != null && provider != null) {
            SourceInfoRequestLocal sourceInfoRequestEnterprise = new SourceInfoRequestLocal(true);
            try {
                SourceInfoResponse sources = framework.getSourceInfo(sourceInfoRequestEnterprise);
                Set<SourceDescriptor> sourceInfo = sources.getSourceInfo();
                for (SourceDescriptor sourceDescriptor : sourceInfo) {
                    if (sourceDescriptor.getSourceId().equals(provider.getId())) {
                        available = sourceDescriptor.isAvailable() && provider.isAvailable();
                        LOGGER.info("CatalogProvider.isAvailable = {}", available);
                    }
                }
            } catch (SourceUnavailableException e) {
                available = false;
            }
        }
        if (!available) {
            if (System.currentTimeMillis() > timeoutLimit) {
                LOGGER.info("CatalogProvider.isAvailable = false");
                serviceManager.printInactiveBundles();
                fail(String.format("Catalog provider timed out after %d minutes.", TimeUnit.MILLISECONDS.toMinutes(CATALOG_PROVIDER_TIMEOUT)));
            }
            Thread.sleep(1000);
        }
    }
    LOGGER.info("CatalogProvider is available.");
    return provider;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) SourceDescriptor(ddf.catalog.source.SourceDescriptor) CatalogProvider(ddf.catalog.source.CatalogProvider) CatalogFramework(ddf.catalog.CatalogFramework) SourceInfoRequestLocal(ddf.catalog.operation.impl.SourceInfoRequestLocal) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse)

Example 24 with CatalogProvider

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

the class MigrateCommand method getCatalogProviders.

private List<CatalogProvider> getCatalogProviders() {
    ServiceTracker st = new ServiceTracker(bundleContext, CatalogProvider.class.getName(), null);
    st.open();
    ServiceReference<CatalogProvider>[] serviceRefs = st.getServiceReferences();
    Map<ServiceReference<CatalogProvider>, CatalogProvider> map = new TreeMap<>(new ServiceComparator());
    if (null != serviceRefs) {
        for (ServiceReference<CatalogProvider> serviceReference : serviceRefs) {
            map.put(serviceReference, (CatalogProvider) st.getService(serviceReference));
        }
    }
    return new ArrayList<>(map.values());
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) CatalogProvider(ddf.catalog.source.CatalogProvider) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) ServiceReference(org.osgi.framework.ServiceReference) ServiceComparator(ddf.catalog.util.impl.ServiceComparator)

Example 25 with CatalogProvider

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

the class MigrateCommand method promptForProvider.

private CatalogProvider promptForProvider(String whichProvider, String id, List<CatalogProvider> providers) throws IOException {
    List<String> providersIdList = providers.stream().map(p -> p.getClass().getSimpleName()).collect(Collectors.toList());
    while (true) {
        if (StringUtils.isBlank(id) || !providersIdList.contains(id)) {
            console.println("Please enter the Source ID of the \"" + whichProvider + "\" Provider:");
        } else {
            break;
        }
        id = getInput(whichProvider + " Provider ID: ");
    }
    final String providerId = id;
    final CatalogProvider provider = providers.stream().filter(p -> p.getClass().getSimpleName().equals(providerId)).findFirst().orElse(null);
    return provider;
}
Also used : QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) StringUtils(org.apache.commons.lang.StringUtils) SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) LoggerFactory(org.slf4j.LoggerFactory) ServiceComparator(ddf.catalog.util.impl.ServiceComparator) ArrayList(java.util.ArrayList) Command(org.apache.karaf.shell.api.action.Command) Metacard(ddf.catalog.data.Metacard) Map(java.util.Map) QueryRequest(ddf.catalog.operation.QueryRequest) SortByImpl(ddf.catalog.filter.impl.SortByImpl) SourceProcessingDetails(ddf.catalog.operation.SourceProcessingDetails) SortOrder(org.opengis.filter.sort.SortOrder) ServiceReference(org.osgi.framework.ServiceReference) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Logger(org.slf4j.Logger) IOException(java.io.IOException) FederationException(ddf.catalog.federation.FederationException) Collectors(java.util.stream.Collectors) Provider(org.codice.ddf.commands.catalog.facade.Provider) List(java.util.List) SourceResponse(ddf.catalog.operation.SourceResponse) TreeMap(java.util.TreeMap) CatalogProvider(ddf.catalog.source.CatalogProvider) Service(org.apache.karaf.shell.api.action.lifecycle.Service) CatalogFacade(org.codice.ddf.commands.catalog.facade.CatalogFacade) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Filter(org.opengis.filter.Filter) Option(org.apache.karaf.shell.api.action.Option) CatalogProvider(ddf.catalog.source.CatalogProvider)

Aggregations

CatalogProvider (ddf.catalog.source.CatalogProvider)41 Test (org.junit.Test)26 QueryRequest (ddf.catalog.operation.QueryRequest)13 ArrayList (java.util.ArrayList)9 Result (ddf.catalog.data.Result)8 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)8 FederatedSource (ddf.catalog.source.FederatedSource)8 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)8 Metacard (ddf.catalog.data.Metacard)7 QueryResponse (ddf.catalog.operation.QueryResponse)7 CatalogFramework (ddf.catalog.CatalogFramework)6 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)6 Source (ddf.catalog.source.Source)6 ByteSource (com.google.common.io.ByteSource)5 FederationStrategy (ddf.catalog.federation.FederationStrategy)5 Query (ddf.catalog.operation.Query)5 QueryImpl (ddf.catalog.operation.impl.QueryImpl)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 FederationException (ddf.catalog.federation.FederationException)4 QueryOperations (ddf.catalog.impl.operations.QueryOperations)4