* This class does not deals directly with GML encoding. Instead, it works by taking the
* FeatureResults produced in execute()
and constructs a GetFeaturesResult
* wich is passed to a GML2FeatureResponseDelegate
, as if it where the result of a
* GetFeature WFS request.
*
FeatureResult
s generated by the execute
method in the
* superclass and constructs a GetFeaturesResult
wich is passed to a
* GML2FeatureResponseDelegate
.
- *
- * @see AbstractFeatureInfoResponse#writeTo(OutputStream)
+ *
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@@ -82,25 +76,25 @@ public void write(FeatureCollectionType results, GetFeatureInfoRequest fInfoReq,
// the 'request' object we'll pass to our OutputFormat
GetFeatureType gfreq = WfsFactory.eINSTANCE.createGetFeatureType();
gfreq.setBaseUrl(fInfoReq.getBaseUrl());
-
+
for (int i=0; i < results.getFeature().size(); i++) {
-
+
FeatureCollection fc = (FeatureCollection) results.getFeature().get(i);
Name name = FeatureCollectionDecorator.getName(fc);
QName qname = new QName(name.getNamespaceURI(), name.getLocalPart());
-
+
features.getFeature().add(fc);
QueryType qt = WfsFactory.eINSTANCE.createQueryType();
-
+
qt.setTypeName(Collections.singletonList(qname));
-
+
String crs = GML2EncodingUtils.epsgCode(fc.getSchema().getCoordinateReferenceSystem());
if (crs != null) {
final String srsName = "EPSG:" + crs;
try {
qt.setSrsName(new URI(srsName));
-
+
} catch (URISyntaxException e) {
throw new ServiceException(
"Unable to determite coordinate system for featureType "
@@ -116,14 +110,7 @@ public void write(FeatureCollectionType results, GetFeatureInfoRequest fInfoReq,
// accept it.
Service serviceDesc = new Service("wms", null, null, Collections.EMPTY_LIST);
Operation opDescriptor = new Operation("", serviceDesc, null, new Object[] { gfreq });
-
- final GeoServer gs = wms.getGeoServer();
-
- FeatureTypeSchemaBuilder sb = new FeatureTypeSchemaBuilder.GML3(gs);
- WFSConfiguration configuration = new WFSConfiguration(gs, sb, new WFS(sb));
-
- GML3OutputFormat format = new GML3OutputFormat(gs, configuration);
- format.write(features, out, opDescriptor);
+ outputFormat.write(features, out, opDescriptor);
}
}
diff --git a/src/wms/src/main/java/org/geoserver/wms/featureinfo/XML311FeatureInfoOutputFormat.java b/src/wms/src/main/java/org/geoserver/wms/featureinfo/XML311FeatureInfoOutputFormat.java
index 3ecae655890..5914ea6e0e9 100644
--- a/src/wms/src/main/java/org/geoserver/wms/featureinfo/XML311FeatureInfoOutputFormat.java
+++ b/src/wms/src/main/java/org/geoserver/wms/featureinfo/XML311FeatureInfoOutputFormat.java
@@ -5,7 +5,7 @@
*/
package org.geoserver.wms.featureinfo;
-import org.geoserver.wms.WMS;
+import org.geoserver.wfs.xml.GML3OutputFormat;
/**
* A GetFeatureInfo response handler specialized in producing GML 3.1.1 data for a GetFeatureInfo request.
@@ -28,10 +28,10 @@ public class XML311FeatureInfoOutputFormat extends GML3FeatureInfoOutputFormat {
/**
* Default constructor, sets up the supported output format String.
*
- * @param wms WMS to use.
+ * @param outputFormat format to use
*/
- public XML311FeatureInfoOutputFormat(WMS wms) {
- super(wms, FORMAT);
+ public XML311FeatureInfoOutputFormat(GML3OutputFormat outputFormat) {
+ super(outputFormat, FORMAT);
}
-}
\ No newline at end of file
+}
diff --git a/src/wms/src/test/java/org/geoserver/wms/wms_1_3/GetFeatureInfoIntegrationTest.java b/src/wms/src/test/java/org/geoserver/wms/wms_1_3/GetFeatureInfoIntegrationTest.java
index c2b898ae0ad..c724d1073b7 100644
--- a/src/wms/src/test/java/org/geoserver/wms/wms_1_3/GetFeatureInfoIntegrationTest.java
+++ b/src/wms/src/test/java/org/geoserver/wms/wms_1_3/GetFeatureInfoIntegrationTest.java
@@ -21,6 +21,7 @@
import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.XpathEngine;
+import org.eclipse.xsd.XSDSchema;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.data.test.MockData;
@@ -35,6 +36,7 @@
import org.geoserver.wms.featureinfo.TextFeatureInfoOutputFormat;
import org.geoserver.wms.featureinfo.XML311FeatureInfoOutputFormat;
import org.geoserver.wms.wms_1_1_1.CapabilitiesTest;
+import org.geotools.filter.v1_1.OGC;
import org.geotools.util.logging.Logging;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -840,4 +842,23 @@ public void testGetFeatureInfoOnLineStringsWithGenericGeometry() throws Exceptio
assertThat(xpath.evaluate("boolean(//wfs:FeatureCollection/gml:featureMember/gs:genericLines[@fid='line.2'][gs:name='line2'])", result), is("true"));
assertThat(xpath.evaluate("boolean(//wfs:FeatureCollection/gml:featureMember/gs:genericLines[@fid='line.3'][gs:name='line3'])", result), is("true"));
}
+
+ @Test
+ public void testSchemaLeak() throws Exception {
+ String layer = getLayerId(MockData.FORESTS);
+ String request = "wms?version=1.3.0&bbox=-0.002,-0.002,0.002,0.002&styles=&format=jpeg&info_format=" + GML3FeatureInfoOutputFormat.FORMAT + "&request=GetFeatureInfo&layers="
+ + layer + "&query_layers=" + layer + "&width=20&height=20&i=10&j=10";
+ // prime system, make sure everything is wired
+ getAsDOM(request);
+
+ // count how many imports in the OGC filter schema
+ XSDSchema schema = OGC.getInstance().getSchema();
+ int expectedImportCounts = schema.getReferencingDirectives().size();
+
+ // now check how many there are after anothe request, should not go up
+ getAsDOM(request);
+ int actualImportCounts = schema.getReferencingDirectives().size();
+ assertEquals(expectedImportCounts, actualImportCounts);
+ }
+
}