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