/** * Creates a class representation of the document. * * @return OGCCapabilities class representation of the configuration document * @throws InvalidCapabilitiesException */ @Override public OGCCapabilities parseCapabilities() throws InvalidCapabilitiesException { LOG.entering(); LOG.logDebug("Parsing Capabilties Request."); ServiceIdentification serviceIdentification = null; ServiceProvider serviceProvider = null; UserDefinedSymbolization uds = null; OperationsMetadata metadata = null; Layer layer = null; String version = parseVersion(); try { serviceIdentification = parseServiceIdentification(); serviceProvider = parseServiceProvider(); LOG.logDebug( "Retrieved serviceIdentification and serviceProvider information " + "from the request."); metadata = parseOperationsMetadata(); LOG.logDebug("Retrieved metadData information from the request."); uds = parseUserDefinedSymbolization(); Element layerElem = (Element) XMLTools.getRequiredNode(getRootElement(), "./Capability/Layer", nsContext); LOG.logDebug("Layer Element retrieved."); layer = parseLayers(layerElem, null); } catch (XMLParsingException e) { String msg = "Error parsing the capabilities request to retrieve 'serviceIdentification'," + " 'serviceProvider', 'metaData' and 'layer' " + e.getMessage(); throw new InvalidCapabilitiesException(msg); } catch (UnknownCRSException e) { throw new InvalidCapabilitiesException(getClass().getName(), e.getMessage()); } WMPSCapabilities wmpsCapabilities = new WMPSCapabilities(version, serviceIdentification, serviceProvider, uds, metadata, layer); LOG.exiting(); return wmpsCapabilities; }
GmlResult handleRequest(GetGmlObject request) { if (!config.hasUniquePrefixMapping()) { return new GmlResult( request, new InconsistentRequestException(get("WFS_CONF_FT_PREFICES_NOT_UNIQUE2"))); } String objectId = request.getObjectId(); MappedFeatureType type = config.getFeatureType(objectId); if (type == null) { LOG.logDebug("The GML type could not be determined for the incoming GMLObjectID"); return new GmlResult( request, new InvalidParameterValueException("getgmlobject", get("WFS_NO_SUCH_FEATURE", objectId))); } if (type.isAbstract()) { String msg = Messages.getMessage("WFS_FEATURE_TYPE_ABSTRACT", type.getName()); return new GmlResult(request, new OGCWebServiceException("getgmlobject", msg)); } if (!type.isVisible()) { String msg = Messages.getMessage("WFS_FEATURE_TYPE_INVISIBLE", type.getName()); return new GmlResult(request, new OGCWebServiceException("getgmlobject", msg)); } int idx = objectId.indexOf("_GEOM_"); int geom = -1; if (idx > 0) { try { geom = parseInt(objectId.substring(idx + 6)); } catch (NumberFormatException e) { LOG.logDebug("Stack trace: ", e); return new GmlResult( request, new InvalidParameterValueException( "getgmlobject", get("WFS_NO_SUCH_FEATURE", request.getObjectId()))); } objectId = objectId.substring(0, idx); LOG.logDebug("Trying to find geometry object number " + geom); } LOG.logDebug("Feature ID: ", objectId); Set<FeatureId> set = singleton(new FeatureId(objectId)); Filter filter = new FeatureFilter(new ArrayList<FeatureId>(set)); Datastore ds = type.getGMLSchema().getDatastore(); Query q = new Query( null, null, null, null, null, new QualifiedName[] {type.getName()}, null, null, filter, null, -1, -1); try { FeatureCollection col = ds.performQuery(q, new MappedFeatureType[] {type}); if (col.size() == 0) { return new GmlResult( request, new InvalidParameterValueException( "getgmlobject", get("WFS_NO_SUCH_FEATURE", request.getObjectId()))); } Feature feature = col.getFeature(0); // different formats are not supported anyway, so just use the first one FormatType format = config.getFeatureTypeList().getFeatureType(type.getName()).getOutputFormats()[0]; if (geom > -1) { try { return new GmlResult(request, feature.getGeometryPropertyValues()[geom], format); } catch (ArrayIndexOutOfBoundsException e) { return new GmlResult( request, new InvalidParameterValueException( "getgmlobject", get("WFS_NO_SUCH_FEATURE", request.getObjectId()))); } } return new GmlResult(request, feature, format); } catch (DatastoreException e) { LOG.logDebug("Stack trace: ", e); return new GmlResult(request, new OGCWebServiceException("getgmlobject", e.getMessage())); } catch (UnknownCRSException e) { LOG.logDebug("Stack trace: ", e); return new GmlResult(request, new OGCWebServiceException("getgmlobject", e.getMessage())); } }