Search in sources :

Example 51 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestRegistryStore method testUpdateConfigurationIOException.

@Test
public void testUpdateConfigurationIOException() throws Exception {
    assertThat(registryStore.getRegistryId(), is(""));
    when(configAdmin.getConfiguration(any())).thenThrow(new IOException());
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    registryStore.registryInfoQuery();
}
Also used : ResultImpl(ddf.catalog.data.impl.ResultImpl) IOException(java.io.IOException) Test(org.junit.Test)

Example 52 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestRegistryStore method testUpdateConfigurationUriNoPort.

@Test
public void testUpdateConfigurationUriNoPort() throws Exception {
    assertThat(registryStore.getRegistryId(), is(""));
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    registryStore.setRegistryUrl("http://testurl/example");
    registryStore.registryInfoQuery();
    assertThat(registryStore.getRegistryId(), is("registryId"));
}
Also used : ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Example 53 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class TestRegistryStore method registryInfoQuery.

@Test
public void registryInfoQuery() throws Exception {
    assertThat(registryStore.getRegistryId(), is(""));
    queryResults.add(new ResultImpl(getDefaultMetacard()));
    registryStore.registryInfoQuery();
    ArgumentCaptor<QueryRequest> captor = ArgumentCaptor.forClass(QueryRequest.class);
    verify(registryStore).query(captor.capture());
    assertThat(captor.getValue().getPropertyValue(SecurityConstants.SECURITY_SUBJECT), notNullValue());
    assertThat(registryStore.getRegistryId(), is("registryId"));
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) ResultImpl(ddf.catalog.data.impl.ResultImpl) Test(org.junit.Test)

Example 54 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class WfsSource method query.

@Override
public SourceResponse query(QueryRequest request) throws UnsupportedQueryException {
    Wfs wfs = factory.getClient();
    Query query = request.getQuery();
    if (query == null) {
        LOGGER.debug("WFS Source {}: Incoming query is null.", getId());
        return null;
    }
    LOGGER.debug("WFS Source {}: Received query: \n{}", getId(), query);
    SourceResponseImpl simpleResponse = null;
    GetFeatureType getFeature = buildGetFeatureRequest(query);
    try {
        LOGGER.debug("WFS Source {}: Sending query ...", getId());
        Wfs20FeatureCollection featureCollection = wfs.getFeature(getFeature);
        int numResults = -1;
        if (featureCollection == null) {
            throw new UnsupportedQueryException("Invalid results returned from server");
        }
        numResults = featureCollection.getMembers().size();
        if (featureCollection.getNumberReturned() == null) {
            LOGGER.debug("Number Returned Attribute was not added to the response");
        } else if (!featureCollection.getNumberReturned().equals(BigInteger.valueOf(numResults))) {
            LOGGER.debug("Number Returned Attribute ({}) did not match actual number returned ({})", featureCollection.getNumberReturned(), numResults);
        }
        availabilityTask.updateLastAvailableTimestamp(System.currentTimeMillis());
        LOGGER.debug("WFS Source {}: Received featureCollection with {} metacards.", getId(), numResults);
        List<Result> results = new ArrayList<Result>(numResults);
        for (int i = 0; i < numResults; i++) {
            Metacard mc = featureCollection.getMembers().get(i);
            mc = transform(mc, DEFAULT_WFS_TRANSFORMER_ID);
            Result result = new ResultImpl(mc);
            results.add(result);
            debugResult(result);
        }
        //Fetch total results available
        long totalResults = 0;
        if (featureCollection.getNumberMatched() == null) {
            totalResults = Long.valueOf(numResults);
        } else if (featureCollection.getNumberMatched().equals(UNKNOWN)) {
            totalResults = Long.valueOf(numResults);
        } else if (StringUtils.isNumeric(featureCollection.getNumberMatched())) {
            totalResults = Long.parseLong(featureCollection.getNumberMatched());
        }
        simpleResponse = new SourceResponseImpl(request, results, totalResults);
    } catch (WfsException wfse) {
        LOGGER.debug(WFS_ERROR_MESSAGE, wfse);
        throw new UnsupportedQueryException("Error received from WFS Server", wfse);
    } catch (Exception ce) {
        String msg = handleClientException(ce);
        throw new UnsupportedQueryException(msg, ce);
    }
    return simpleResponse;
}
Also used : Query(ddf.catalog.operation.Query) Wfs(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) Wfs20FeatureCollection(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20FeatureCollection) ArrayList(java.util.ArrayList) ResultImpl(ddf.catalog.data.impl.ResultImpl) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) WebApplicationException(javax.ws.rs.WebApplicationException) SecurityServiceException(ddf.security.service.SecurityServiceException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) JAXBException(javax.xml.bind.JAXBException) CatalogTransformerException(ddf.catalog.transform.CatalogTransformerException) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException) Result(ddf.catalog.data.Result) Metacard(ddf.catalog.data.Metacard) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType)

Example 55 with ResultImpl

use of ddf.catalog.data.impl.ResultImpl in project ddf by codice.

the class FederationAdminTest method setup.

@Before
public void setup() throws Exception {
    parser = new XmlParser();
    configurator = parser.configureParser(Arrays.asList(RegistryObjectType.class.getPackage().getName(), EbrimConstants.OGC_FACTORY.getClass().getPackage().getName(), EbrimConstants.GML_FACTORY.getClass().getPackage().getName()), this.getClass().getClassLoader());
    federationAdmin = new FederationAdmin(helper) {

        @Override
        public BundleContext getContext() {
            return context;
        }
    };
    federationAdmin.setFederationAdminService(federationAdminService);
    federationAdmin.setRegistryTransformer(registryTransformer);
    federationAdmin.setMetacardMarshaller(new MetacardMarshaller(parser));
    federationAdmin.setSlotHelper(new SlotTypeHelper());
    federationAdmin.setRegistryMapConverter(new RegistryPackageWebConverter());
    federationAdmin.setRegistryTypeConverter(new RegistryPackageTypeConverter());
    federationAdmin.setSourceConfigRefresh(sourceConfiguration);
    mcard = new MetacardImpl(new RegistryObjectMetacardType());
    mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "myId");
    mcard.setAttribute(RegistryObjectMetacardType.PUBLISHED_LOCATIONS, new ArrayList<>());
    mcard.setId("someUUID");
    when(queryResponse.getResults()).thenReturn(Collections.singletonList(new ResultImpl(mcard)));
    when(catalogFramework.query(any(QueryRequest.class))).thenReturn(queryResponse);
    catalogStoreMap.put("myDest", store);
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) QueryRequest(ddf.catalog.operation.QueryRequest) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) SlotTypeHelper(org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper) RegistryPackageWebConverter(org.codice.ddf.registry.schemabindings.converter.web.RegistryPackageWebConverter) ResultImpl(ddf.catalog.data.impl.ResultImpl) RegistryObjectMetacardType(org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) RegistryPackageTypeConverter(org.codice.ddf.registry.schemabindings.converter.type.RegistryPackageTypeConverter) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Aggregations

ResultImpl (ddf.catalog.data.impl.ResultImpl)91 Result (ddf.catalog.data.Result)59 Test (org.junit.Test)56 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)47 Metacard (ddf.catalog.data.Metacard)46 ArrayList (java.util.ArrayList)35 SourceResponse (ddf.catalog.operation.SourceResponse)30 QueryRequest (ddf.catalog.operation.QueryRequest)28 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)20 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)18 QueryResponse (ddf.catalog.operation.QueryResponse)15 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)15 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)12 BinaryContent (ddf.catalog.data.BinaryContent)10 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)10 QueryImpl (ddf.catalog.operation.impl.QueryImpl)9 Query (ddf.catalog.operation.Query)7 PolicyResponse (ddf.catalog.plugin.PolicyResponse)7 File (java.io.File)7 Before (org.junit.Before)7