API change to better accommodate for the 1..* cardinality of HTTPType and addition of Constraint

This commit is contained in:
ahocevar
2011-11-07 16:47:33 +01:00
parent 4076c1af99
commit ffafa93168
4 changed files with 23 additions and 23 deletions

View File

@@ -171,24 +171,24 @@ OpenLayers.Format.OWSCommon.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
this.readChildNodes(node, dcp.http);
},
"Get": function(node, http) {
http.get = this.getAttributeNS(node,
this.namespaces.xlink, "href");
if (!http.constraints) {
http.constraints = {};
if (!http.get) {
http.get = [];
}
var obj = {};
var obj = {
url: this.getAttributeNS(node, this.namespaces.xlink, "href")
};
this.readChildNodes(node, obj);
http.constraints.get = obj.constraints;
http.get.push(obj);
},
"Post": function(node, http) {
http.post = this.getAttributeNS(node,
this.namespaces.xlink, "href");
if (!http.constraints) {
http.constraints = {};
if (!http.post) {
http.post = [];
}
var obj = {};
var obj = {
url: this.getAttributeNS(node, this.namespaces.xlink, "href")
};
this.readChildNodes(node, obj);
http.constraints.post = obj.constraints;
http.post.push(obj);
},
"Parameter": function(node, operation) {
if (!operation.parameters) {

View File

@@ -6,7 +6,7 @@
function test_read_exception(t) {
t.plan(6);
var text = '<?xml version="1.0" encoding="UTF-8"?>' +
'<ows:ExceptionReport xml:lang="en" version="1.0.0"' +
'<ows:ExceptionReport xml:lang="en" version="1.1.0"' +
' xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.1.0/owsExceptionReport.xsd"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/1.1">' +
' <ows:Exception locator="foo" exceptionCode="InvalidParameterValue">' +
@@ -18,7 +18,7 @@
var format = new OpenLayers.Format.OWSCommon();
var result = format.read(text);
var report = result.exceptionReport;
t.eq(report.version, "1.0.0", "Version parsed correctly");
t.eq(report.version, "1.1.0", "Version parsed correctly");
t.eq(report.language, "en", "Language parsed correctly");
var exception = report.exceptions[0];
t.eq(exception.code, "InvalidParameterValue", "exceptionCode properly parsed");

View File

@@ -40,7 +40,7 @@
t.eq(obj.serviceProvider.serviceContact.contactInfo.phone.voice, "+49-251-83-30088", "Voice phone correctly parsed");
// operationsMetadata (from OWSCommon)
t.eq(obj.operationsMetadata.DescribeSensor.dcp.http.post, "http://v-swe.uni-muenster.de:8080/WeatherSOS/sos", "POST url for DescribeSensor correctly parsed");
t.eq(obj.operationsMetadata.DescribeSensor.dcp.http.post[0].url, "http://v-swe.uni-muenster.de:8080/WeatherSOS/sos", "POST url for DescribeSensor correctly parsed");
var counter = 0;
for (var key in obj.operationsMetadata.DescribeSensor.parameters.procedure.allowedValues) {
if (counter == 0) {

View File

@@ -30,16 +30,16 @@
// ows:OperationsMetadata
var operationsMetadata = obj.operationsMetadata;
t.eq(operationsMetadata.GetCapabilities.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetCapabilities url is correct");
t.eq(operationsMetadata.GetCapabilities.dcp.http.constraints.get.GetEncoding.allowedValues,
t.eq(operationsMetadata.GetCapabilities.dcp.http.get[0].url, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetCapabilities url is correct");
t.eq(operationsMetadata.GetCapabilities.dcp.http.get[0].constraints.GetEncoding.allowedValues,
{'KVP': true},
"ows:OperationsMetadata GetCapabilities Constraints Get is correct");
t.eq(operationsMetadata.GetFeatureInfo.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetFeatureInfo url is correct");
t.eq(operationsMetadata.GetFeatureInfo.dcp.http.constraints.get,
t.eq(operationsMetadata.GetFeatureInfo.dcp.http.get[0].url, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetFeatureInfo url is correct");
t.eq(operationsMetadata.GetFeatureInfo.dcp.http.get[0].constraints,
undefined,
"ows:OperationsMetadata GetFeatureInfo Constraints Get is correct");
t.eq(operationsMetadata.GetTile.dcp.http.get, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetTile url is correct");
t.eq(operationsMetadata.GetTile.dcp.http.constraints.get,
t.eq(operationsMetadata.GetTile.dcp.http.get[0].url, "http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?", "ows:OperationsMetadata GetTile url is correct");
t.eq(operationsMetadata.GetTile.dcp.http.get[0].constraints,
undefined,
"ows:OperationsMetadata GetTile Constraints Get is correct");
}
@@ -56,7 +56,7 @@
t.eq(numOfLayers, 1, "correct count of layers");
var layer = contents.layers[0];
t.eq(layer.abstract, "Coastline/shorelines (BA010)", "layer abstract is correct");
t.eq(layer['abstract'], "Coastline/shorelines (BA010)", "layer abstract is correct");
t.eq(layer.identifier, "coastlines", "layer identifier is correct");
t.eq(layer.title, "Coastlines", "layer title is correct");
@@ -99,7 +99,7 @@
var dimensions = layer.dimensions;
t.eq(dimensions.length, 1, "correct count of dimensions");
t.eq(dimensions[0].title, "Time", "first dimension title is correct");
t.eq(dimensions[0].abstract, "Monthly datasets", "first dimension abstract is correct");
t.eq(dimensions[0]['abstract'], "Monthly datasets", "first dimension abstract is correct");
t.eq(dimensions[0].identifier, "TIME", "first dimension identifier is correct");
t.eq(dimensions[0]['default'], "default", "first dimension default is correct");
t.eq(dimensions[0].values.length, 3, "first dimension has correct count of values");