Commit dc0af829 authored by Andrea Aime's avatar Andrea Aime
Browse files

[GEOS-6026] WMS capabilities should report workspace qualified styles as ... qualified

parent 7a2e8027
......@@ -79,6 +79,7 @@ import org.opengis.filter.sort.SortBy;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.TransformException;
import org.opengis.util.InternationalString;
import org.springframework.util.Assert;
import org.vfny.geoserver.util.ResponseUtils;
import org.xml.sax.Attributes;
......@@ -1036,9 +1037,11 @@ public class Capabilities_1_3_0_Transformer extends TransformerBase {
} catch (IOException e) {
throw new RuntimeException(e);
}
element("Name", defaultStyle.getName());
element("Title", ftStyle.getTitle());
element("Abstract", ftStyle.getAbstract());
element("Name", defaultStyle.prefixedName());
if (ftStyle.getDescription() != null) {
element("Title", ftStyle.getDescription().getTitle());
element("Abstract", ftStyle.getDescription().getAbstract());
}
handleLegendURL(layer, layer.getLegend(), null, layer.getDefaultStyle());
end("Style");
......@@ -1052,15 +1055,23 @@ public class Capabilities_1_3_0_Transformer extends TransformerBase {
throw new RuntimeException(e);
}
start("Style");
element("Name", styleInfo.getName());
element("Title", ftStyle.getTitle());
element("Abstract", ftStyle.getAbstract());
element("Name", styleInfo.prefixedName());
if (ftStyle.getDescription() != null) {
element("Title", ftStyle.getDescription().getTitle());
element("Abstract", ftStyle.getDescription().getAbstract());
}
handleLegendURL(layer, null, styleInfo, styleInfo);
end("Style");
}
}
}
}
private void element(String element, InternationalString is) {
if (is != null) {
element(element, is.toString());
}
}
protected Set<LayerInfo> handleLayerGroups(Iterator<LayerGroupInfo> layerGroups) throws FactoryException,
TransformException, IOException {
......
......@@ -75,6 +75,7 @@ import org.geotools.xml.transform.Translator;
import org.opengis.feature.type.Name;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.operation.TransformException;
import org.opengis.util.InternationalString;
import org.springframework.util.Assert;
import org.vfny.geoserver.util.ResponseUtils;
import org.xml.sax.Attributes;
......@@ -944,9 +945,11 @@ public class GetCapabilitiesTransformer extends TransformerBase {
} catch (IOException e) {
throw new RuntimeException(e);
}
element("Name", defaultStyle.getName());
element("Title", ftStyle.getTitle());
element("Abstract", ftStyle.getAbstract());
element("Name", defaultStyle.prefixedName());
if (ftStyle.getDescription() != null) {
element("Title", ftStyle.getDescription().getTitle());
element("Abstract", ftStyle.getDescription().getAbstract());
}
handleLegendURL(layer, layer.getLegend(), null ,layer.getDefaultStyle());
end("Style");
......@@ -959,9 +962,11 @@ public class GetCapabilitiesTransformer extends TransformerBase {
throw new RuntimeException(e);
}
start("Style");
element("Name", styleInfo.getName());
element("Title", ftStyle.getTitle());
element("Abstract", ftStyle.getAbstract());
element("Name", styleInfo.prefixedName());
if (ftStyle.getDescription() != null) {
element("Title", ftStyle.getDescription().getTitle());
element("Abstract", ftStyle.getDescription().getAbstract());
}
handleLegendURL(layer, null, styleInfo, styleInfo);
end("Style");
}
......@@ -973,6 +978,12 @@ public class GetCapabilitiesTransformer extends TransformerBase {
private void element(String element, InternationalString is) {
if (is != null) {
element(element, is.toString());
}
}
/**
* Inserts the ScaleHint element in the layer information.
* <p>
......
......@@ -28,6 +28,7 @@ import org.geoserver.catalog.LayerGroupInfo;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.StyleInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.config.ContactInfo;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.data.test.MockData;
......@@ -50,8 +51,7 @@ public class CapabilitiesTest extends WMSTestSupport {
super.setUpTestData(testData);
testData.setUpDefaultRasterLayers();
}
@Override
protected void onSetUp(SystemTestData testData) throws Exception {
super.onSetUp(testData);
......@@ -65,10 +65,16 @@ public class CapabilitiesTest extends WMSTestSupport {
global.getSettings().setProxyBaseUrl("src/test/resources/geoserver");
getGeoServer().save(global);
// add a workspace qualified style
WorkspaceInfo ws = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
testData.addStyle(ws, "Lakes", "Lakes.sld", SystemTestData.class, catalog);
StyleInfo lakesStyle = catalog.getStyleByName(ws, "Lakes");
LayerInfo lakesLayer = catalog.getLayerByName(MockData.LAKES.getLocalPart());
lakesLayer.setDefaultStyle(lakesStyle);
catalog.save(lakesLayer);
}
@Test
public void testCapabilities() throws Exception {
Document dom = dom(get("wms?request=getCapabilities&version=1.1.1"), false);
......@@ -452,4 +458,12 @@ public class CapabilitiesTest extends WMSTestSupport {
}
@Test
public void testStyleWorkspaceQualified() throws Exception {
Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.1.1", true);
// check the style name got prefixed too
assertXpathEvaluatesTo("cite:Lakes", "//Layer[Name='cite:Lakes']/Style[1]/Name", doc);
}
}
......@@ -30,6 +30,7 @@ import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.MetadataLinkInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.StyleInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.config.ContactInfo;
import org.geoserver.config.GeoServerInfo;
import org.geoserver.data.test.MockData;
......@@ -78,6 +79,13 @@ public class CapabilitiesIntegrationTest extends WMSTestSupport {
global.getSettings().setProxyBaseUrl("src/test/resources/geoserver");
getGeoServer().save(global);
// add a workspace qualified style
WorkspaceInfo ws = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
testData.addStyle(ws, "Lakes", "Lakes.sld", SystemTestData.class, catalog);
StyleInfo lakesStyle = catalog.getStyleByName(ws, "Lakes");
LayerInfo lakesLayer = catalog.getLayerByName(MockData.LAKES.getLocalPart());
lakesLayer.setDefaultStyle(lakesStyle);
catalog.save(lakesLayer);
}
......@@ -339,7 +347,7 @@ public class CapabilitiesIntegrationTest extends WMSTestSupport {
getGeoServer().save(service);
Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
print(doc);
// print(doc);
String base = "wms:WMS_Capabilities/wms:Service/";
assertXpathEvaluatesTo("WMS", base + "wms:Name", doc);
......@@ -525,4 +533,14 @@ public class CapabilitiesIntegrationTest extends WMSTestSupport {
Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
assertXpathEvaluatesTo("1", "count(//wms:GetMap[wms:Format = '" + OpenLayersMapOutputFormat.MIME_TYPE + "'])", doc);
}
@Test
public void testStyleWorkspaceQualified() throws Exception {
Document doc = getAsDOM("wms?service=WMS&request=getCapabilities&version=1.3.0", true);
// check the style name got prefixed too
assertXpathEvaluatesTo("cite:Lakes",
"//wms:Layer[wms:Name='cite:Lakes']/wms:Style[1]/wms:Name", doc);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment