Search in sources :

Example 6 with ElementSetType

use of net.opengis.cat.csw.v_2_0_2.ElementSetType in project ddf by codice.

the class AbstractCswSource method createElementSetName.

private ElementSetNameType createElementSetName(ElementSetType type) {
    ElementSetNameType elementSetNameType = new ElementSetNameType();
    elementSetNameType.setValue(type);
    return elementSetNameType;
}
Also used : ElementSetNameType(net.opengis.cat.csw.v_2_0_2.ElementSetNameType)

Example 7 with ElementSetType

use of net.opengis.cat.csw.v_2_0_2.ElementSetType in project ddf by codice.

the class AbstractCswSource method createGetRecordsRequest.

private GetRecordsType createGetRecordsRequest(Query query, ElementSetType elementSetName, List<QName> elementNames) throws UnsupportedQueryException {
    GetRecordsType getRecordsType = new GetRecordsType();
    getRecordsType.setVersion(cswVersion);
    getRecordsType.setService(CswConstants.CSW);
    getRecordsType.setResultType(ResultType.RESULTS);
    getRecordsType.setStartPosition(BigInteger.valueOf(query.getStartIndex()));
    getRecordsType.setMaxRecords(BigInteger.valueOf(query.getPageSize()));
    getRecordsType.setOutputFormat(MediaType.APPLICATION_XML);
    if (!isOutputSchemaSupported()) {
        String msg = "CSW Source: " + cswSourceConfiguration.getId() + " does not support output schema: " + cswSourceConfiguration.getOutputSchema() + ".";
        throw new UnsupportedQueryException(msg);
    }
    getRecordsType.setOutputSchema(cswSourceConfiguration.getOutputSchema());
    getRecordsType.setAbstractQuery(createQuery(query, elementSetName, elementNames));
    return getRecordsType;
}
Also used : UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType)

Example 8 with ElementSetType

use of net.opengis.cat.csw.v_2_0_2.ElementSetType in project ddf by codice.

the class AbstractCswSource method createQuery.

private JAXBElement<QueryType> createQuery(Query query, ElementSetType elementSetType, List<QName> elementNames) throws UnsupportedQueryException {
    QueryType queryType = new QueryType();
    QName queryTypeQName = null;
    try {
        if (StringUtils.isNotBlank(cswSourceConfiguration.getQueryTypeName())) {
            String[] parts = cswSourceConfiguration.getQueryTypeName().split(":");
            if (parts.length > 1) {
                queryTypeQName = new QName(cswSourceConfiguration.getQueryTypeNamespace(), parts[1], parts[0]);
            } else {
                queryTypeQName = new QName(cswSourceConfiguration.getQueryTypeNamespace(), cswSourceConfiguration.getQueryTypeName());
            }
        }
    } catch (IllegalArgumentException e) {
        LOGGER.debug("Unable to parse query type QName of {}.  Defaulting to CSW Record", cswSourceConfiguration.getQueryTypeName());
    }
    if (queryTypeQName == null) {
        queryTypeQName = new QName(CswConstants.CSW_OUTPUT_SCHEMA, CswConstants.CSW_RECORD_LOCAL_NAME, CswConstants.CSW_NAMESPACE_PREFIX);
    }
    queryType.setTypeNames(Arrays.asList(queryTypeQName));
    if (null != elementSetType) {
        queryType.setElementSetName(createElementSetName(elementSetType));
    } else if (!CollectionUtils.isEmpty(elementNames)) {
        queryType.setElementName(elementNames);
    } else {
        queryType.setElementSetName(createElementSetName(ElementSetType.FULL));
    }
    SortByType sortBy = createSortBy(query);
    if (sortBy != null) {
        queryType.setSortBy(sortBy);
    }
    QueryConstraintType constraint = createQueryConstraint(query);
    if (null != constraint) {
        queryType.setConstraint(constraint);
    }
    ObjectFactory objectFactory = new ObjectFactory();
    return objectFactory.createQuery(queryType);
}
Also used : ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) QName(javax.xml.namespace.QName) SortByType(net.opengis.filter.v_1_1_0.SortByType) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType)

Example 9 with ElementSetType

use of net.opengis.cat.csw.v_2_0_2.ElementSetType in project ddf by codice.

the class TestRegistryStore method setup.

@Before
public void setup() throws Exception {
    parser = new XmlParser();
    marshaller = new MetacardMarshaller(new XmlParser());
    context = mock(BundleContext.class);
    provider = mock(Converter.class);
    cswSourceConfiguration = new CswSourceConfiguration();
    factory = mock(SecureCxfClientFactory.class);
    transformer = mock(TransformerManager.class);
    encryptionService = mock(EncryptionService.class);
    configAdmin = mock(ConfigurationAdmin.class);
    configuration = mock(Configuration.class);
    subject = mock(Subject.class);
    queryResults = new ArrayList<>();
    registryStore = spy(new RegistryStoreImpl(context, cswSourceConfiguration, provider, factory, encryptionService) {

        @Override
        protected void validateOperation() {
        }

        @Override
        public boolean isAvailable() {
            return availability;
        }

        @Override
        protected SourceResponse query(QueryRequest queryRequest, ElementSetType elementSetName, List<QName> elementNames, Csw csw) throws UnsupportedQueryException {
            if (queryResults == null) {
                throw new UnsupportedQueryException("Test - Bad Query");
            }
            return new SourceResponseImpl(queryRequest, queryResults);
        }

        @Override
        protected CapabilitiesType getCapabilities() {
            return mock(CapabilitiesType.class);
        }

        @Override
        public void configureCswSource() {
        }

        ;

        @Override
        protected Subject getSystemSubject() {
            return subject;
        }

        @Override
        BundleContext getBundleContext() {
            return context;
        }
    });
    registryStore.setFilterBuilder(filterBuilder);
    registryStore.setFilterAdapter(filterAdapter);
    registryStore.setConfigAdmin(configAdmin);
    registryStore.setMetacardMarshaller(new MetacardMarshaller(parser));
    registryStore.setSchemaTransformerManager(transformer);
    registryStore.setAutoPush(true);
    registryStore.setRegistryUrl("http://test.url:0101/example");
    properties = new Hashtable<>();
    properties.put(RegistryStoreImpl.ID, "registryId");
    registryStore.setMetacardMarshaller(marshaller);
    when(configAdmin.getConfiguration(any())).thenReturn(configuration);
    when(configuration.getProperties()).thenReturn(properties);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) XmlParser(org.codice.ddf.parser.xml.XmlParser) TransformerManager(org.codice.ddf.spatial.ogc.csw.catalog.common.transformer.TransformerManager) Configuration(org.osgi.service.cm.Configuration) CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) QueryRequest(ddf.catalog.operation.QueryRequest) SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) MetacardMarshaller(org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) Subject(ddf.security.Subject) EncryptionService(ddf.security.encryption.EncryptionService) ElementSetType(net.opengis.cat.csw.v_2_0_2.ElementSetType) Converter(com.thoughtworks.xstream.converters.Converter) List(java.util.List) ArrayList(java.util.ArrayList) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) BundleContext(org.osgi.framework.BundleContext) Before(org.junit.Before)

Aggregations

QName (javax.xml.namespace.QName)5 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)4 ElementSetType (net.opengis.cat.csw.v_2_0_2.ElementSetType)4 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)4 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)3 Result (ddf.catalog.data.Result)2 QueryRequest (ddf.catalog.operation.QueryRequest)2 Subject (ddf.security.Subject)2 ArrayList (java.util.ArrayList)2 JAXBException (javax.xml.bind.JAXBException)2 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)2 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)2 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)2 SortByType (net.opengis.filter.v_1_1_0.SortByType)2 MetacardMarshaller (org.codice.ddf.registry.schemabindings.helper.MetacardMarshaller)2 Csw (org.codice.ddf.spatial.ogc.csw.catalog.common.Csw)2 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)2 BundleContext (org.osgi.framework.BundleContext)2 Converter (com.thoughtworks.xstream.converters.Converter)1 Metacard (ddf.catalog.data.Metacard)1