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());
}
Aggregations