Search in sources :

Example 51 with XmlSchema

use of org.apache.ws.commons.schema.XmlSchema in project ddf by codice.

the class WfsSource method buildFeatureFilters.

private void buildFeatureFilters(List<FeatureTypeType> featureTypes, FilterCapabilities filterCapabilities) throws SecurityServiceException {
    Wfs wfs = factory.getClient();
    if (filterCapabilities == null) {
        return;
    }
    // Use local Map for metacardtype registrations and once they are populated with latest
    // MetacardTypes, then do actual registration
    Map<String, MetacardTypeRegistration> mcTypeRegs = new HashMap<String, MetacardTypeRegistration>();
    this.featureTypeFilters.clear();
    for (FeatureTypeType featureTypeType : featureTypes) {
        String ftSimpleName = featureTypeType.getName().getLocalPart();
        if (StringUtils.isNotBlank(forcedFeatureType) && !StringUtils.equals(forcedFeatureType, ftSimpleName)) {
            continue;
        }
        if (mcTypeRegs.containsKey(ftSimpleName)) {
            LOGGER.debug("WfsSource {}: MetacardType {} is already registered - skipping to next metacard type", getId(), ftSimpleName);
            continue;
        }
        LOGGER.debug("ftName: {}", ftSimpleName);
        try {
            XmlSchema schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(featureTypeType.getName()));
            if (schema == null) {
                // Some WFS 2.0.0 DescribeFeatureRequests return inconsistent results when
                // the `:` character is encoded in the URL, ie Prefix:SomeFeature is encoded to
                // Prefix%3ASomeFeature. To avoid this issue, we will make a call without the prefix
                // if the previous call does not work.
                schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(new QName(featureTypeType.getName().getNamespaceURI(), featureTypeType.getName().getLocalPart(), "")));
            }
            if (schema != null) {
                // Update local map with enough info to create actual MetacardType registrations
                // later
                MetacardTypeRegistration registration = createFeatureMetacardTypeRegistration(featureTypeType, ftSimpleName, schema);
                mcTypeRegs.put(ftSimpleName, registration);
                FeatureMetacardType featureMetacardType = registration.getFtMetacard();
                lookupFeatureConverter(ftSimpleName, featureMetacardType);
                MetacardMapper metacardAttributeToFeaturePropertyMapper = lookupMetacardAttributeToFeaturePropertyMapper(featureMetacardType.getFeatureType());
                this.featureTypeFilters.put(featureMetacardType.getFeatureType(), new WfsFilterDelegate(featureMetacardType, filterCapabilities, registration.getSrs(), metacardAttributeToFeaturePropertyMapper, coordinateOrder));
            }
        } catch (WfsException | IllegalArgumentException wfse) {
            LOGGER.debug(WFS_ERROR_MESSAGE, wfse);
        } catch (WebApplicationException wae) {
            LOGGER.debug(handleWebApplicationException(wae), wae);
        }
    }
    registerFeatureMetacardTypes(mcTypeRegs);
    if (featureTypeFilters.isEmpty()) {
        LOGGER.debug("Wfs Source {}: No Feature Type schemas validated.", getId());
    }
    LOGGER.debug("Wfs Source {}: Number of validated Features = {}", getId(), featureTypeFilters.size());
    updateSupportedSpatialOperators(filterCapabilities.getSpatialCapabilities().getSpatialOperators());
}
Also used : FeatureTypeType(net.opengis.wfs.v_2_0_0.FeatureTypeType) WebApplicationException(javax.ws.rs.WebApplicationException) Wfs(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) XmlSchema(org.apache.ws.commons.schema.XmlSchema) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.DescribeFeatureTypeRequest) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) MetacardMapper(org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper)

Aggregations

XmlSchema (org.apache.ws.commons.schema.XmlSchema)51 QName (javax.xml.namespace.QName)37 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)37 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)35 Test (org.junit.Test)35 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)28 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)11 ArrayList (java.util.ArrayList)10 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)6 Iterator (java.util.Iterator)6 List (java.util.List)5 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)5 Map (java.util.Map)4 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 HashMap (java.util.HashMap)3 XmlSchemaComplexContent (org.apache.ws.commons.schema.XmlSchemaComplexContent)3 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)3 XmlSchemaObjectTable (org.apache.ws.commons.schema.XmlSchemaObjectTable)3 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)3 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)3