Search in sources :

Example 71 with UnsupportedQueryException

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

the class RefreshRegistryEntriesTest method testSubscriptionEntityRemovalFailedQuery.

@Test
public void testSubscriptionEntityRemovalFailedQuery() throws Exception {
    Metacard localMetacard = getPopulatedTestRegistryMetacard("mcardId", "testRegId", 0, true);
    when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMetacard));
    when(registryStore.query(any(QueryRequest.class))).thenThrow(new UnsupportedQueryException("query error"));
    when(registryStore.isPullAllowed()).thenReturn(true);
    when(registryStore.getId()).thenReturn(TEST_ID);
    when(registryStore.getRegistryId()).thenReturn("remoteRegId");
    when(registryStore.isAvailable()).thenReturn(true);
    refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
    refreshRegistryEntries.refreshRegistryEntries();
    verify(federationAdminService, never()).deleteRegistryEntriesByMetacardIds(Collections.singletonList(localMetacard.getId()));
}
Also used : Metacard(ddf.catalog.data.Metacard) QueryRequest(ddf.catalog.operation.QueryRequest) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) Test(org.junit.Test)

Example 72 with UnsupportedQueryException

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

the class RefreshRegistryEntriesTest method testMultipleStores.

@Test
public void testMultipleStores() throws Exception {
    Metacard mcard = getPopulatedTestRegistryMetacard();
    RegistryStore registryStore2 = mock(RegistryStore.class);
    when(registryStore2.getId()).thenReturn("id2");
    when(registryStore2.getRegistryId()).thenReturn("regId2");
    when(registryStore2.isAvailable()).thenReturn(true);
    when(registryStore2.isPullAllowed()).thenReturn(true);
    SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(mcard)));
    when(registryStore2.query(any(QueryRequest.class))).thenReturn(response);
    when(registryStore.query(any(QueryRequest.class))).thenThrow(new UnsupportedQueryException());
    when(registryStore.isAvailable()).thenReturn(true);
    when(registryStore.isPullAllowed()).thenReturn(true);
    when(registryStore2.query(any(QueryRequest.class))).thenReturn(response);
    List<RegistryStore> stores = new ArrayList<>();
    stores.add(registryStore);
    stores.add(registryStore2);
    refreshRegistryEntries.setRegistryStores(stores);
    refreshRegistryEntries.refreshRegistryEntries();
    verify(federationAdminService).addRegistryEntries(Collections.singletonList(mcard), null);
}
Also used : Metacard(ddf.catalog.data.Metacard) RegistryStore(org.codice.ddf.registry.api.internal.RegistryStore) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Example 73 with UnsupportedQueryException

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

the class RegistryIdPostIngestPluginTest method testInitCatalogNotAvailable.

@Test
public void testInitCatalogNotAvailable() throws Exception {
    when(security.runAsAdminWithException(any(PrivilegedExceptionAction.class))).thenThrow(new PrivilegedActionException(new UnsupportedQueryException("exception")));
    registryIdPostIngestPlugin.init();
    assertThat(registryIdPostIngestPlugin.getRegistryIds().size(), equalTo(0));
    verify(executorService).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class));
}
Also used : PrivilegedActionException(java.security.PrivilegedActionException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) TimeUnit(java.util.concurrent.TimeUnit) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) Test(org.junit.Test)

Example 74 with UnsupportedQueryException

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

the class SourceQueryRunnable method normalize.

private void normalize(Query query, List<Result> responseResults) {
    if (shouldNormalizeRelevance) {
        FilteringSolrIndex index = null;
        try {
            index = solrIndexFuture.get(FUTURE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
            index.add(responseResults);
            List<Result> indexResults = index.query(new QueryRequestImpl(query)).getResults();
            normalizeRelevance(indexResults, results);
        } catch (InterruptedException | ExecutionException | TimeoutException e) {
            LOGGER.debug("Failed to get index for relevance normalization", e);
        } catch (UnsupportedQueryException e) {
            LOGGER.debug("Failed to parse query for relevance normalization", e);
        } catch (IngestException e) {
            LOGGER.debug("Failed to ingest results for relevance normalization", e);
        }
    } else if (shouldNormalizeDistance) {
        normalizeDistances(query, results);
    }
}
Also used : FilteringSolrIndex(org.codice.ddf.ui.searchui.query.solr.FilteringSolrIndex) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) IngestException(ddf.catalog.source.IngestException) ExecutionException(java.util.concurrent.ExecutionException) Result(ddf.catalog.data.Result) TimeoutException(java.util.concurrent.TimeoutException)

Example 75 with UnsupportedQueryException

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

the class FilterAdapterTest method assertFilterFails.

private void assertFilterFails(Filter filter) {
    FilterDelegate<String> delegate = new FilterToTextDelegate();
    FilterAdapter fa = new GeotoolsFilterAdapterImpl();
    try {
        fa.adapt(filter, delegate);
        fail("Expected UnsupportedQueryException");
    } catch (UnsupportedQueryException e) {
    // pass
    }
}
Also used : FilterToTextDelegate(ddf.catalog.filter.delegate.FilterToTextDelegate) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Aggregations

UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)85 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)34 FederationException (ddf.catalog.federation.FederationException)31 QueryRequest (ddf.catalog.operation.QueryRequest)31 Metacard (ddf.catalog.data.Metacard)28 QueryImpl (ddf.catalog.operation.impl.QueryImpl)27 Filter (org.opengis.filter.Filter)27 ArrayList (java.util.ArrayList)26 Result (ddf.catalog.data.Result)25 QueryResponse (ddf.catalog.operation.QueryResponse)25 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)25 Test (org.junit.Test)21 SourceResponse (ddf.catalog.operation.SourceResponse)16 IngestException (ddf.catalog.source.IngestException)15 IOException (java.io.IOException)15 Query (ddf.catalog.operation.Query)12 CreateResponse (ddf.catalog.operation.CreateResponse)10 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)9 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)9 Subject (ddf.security.Subject)9