[OpenLayers-Commits] r12068 - in sandbox/bartvde/exception/openlayers: lib/OpenLayers/Format tests/Format/WFSCapabilities

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Jun 7 17:38:35 EDT 2011


Author: bartvde
Date: 2011-06-07 14:38:34 -0700 (Tue, 07 Jun 2011)
New Revision: 12068

Modified:
   sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/WFSCapabilities.js
   sandbox/bartvde/exception/openlayers/tests/Format/WFSCapabilities/v1.html
Log:
and now hooked it into WFS Capabilities parsing

Modified: sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/WFSCapabilities.js
===================================================================
--- sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/WFSCapabilities.js	2011-06-07 21:31:25 UTC (rev 12067)
+++ sandbox/bartvde/exception/openlayers/lib/OpenLayers/Format/WFSCapabilities.js	2011-06-07 21:38:34 UTC (rev 12068)
@@ -5,6 +5,7 @@
 
 /**
  * @requires OpenLayers/Format/XML.js
+ * @requires OpenLayers/Format/OGCExceptionReport.js
  */
 
 /**
@@ -67,6 +68,11 @@
         }
         var parser = new constr(this.options);
         var capabilities = parser.read(data);
+        if (capabilities.service === undefined) {
+            // an error must have happened, so parse it and report back
+            var format = new OpenLayers.Format.OGCExceptionReport();
+            capabilities.error = format.read(data);
+        }
         capabilities.version = version;
         return capabilities;
     },

Modified: sandbox/bartvde/exception/openlayers/tests/Format/WFSCapabilities/v1.html
===================================================================
--- sandbox/bartvde/exception/openlayers/tests/Format/WFSCapabilities/v1.html	2011-06-07 21:31:25 UTC (rev 12067)
+++ sandbox/bartvde/exception/openlayers/tests/Format/WFSCapabilities/v1.html	2011-06-07 21:38:34 UTC (rev 12068)
@@ -2,6 +2,23 @@
 <head> 
     <script src="../../OLLoader.js"></script>
     <script type="text/javascript">
+
+    function test_read_exception(t) {
+        t.plan(1);
+        var parser = new OpenLayers.Format.WFSCapabilities();
+        var text = '<?xml version="1.0" encoding="UTF-8"?>' +
+'<ows:ExceptionReport language="en" version="1.0.0"' +
+'    xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd"' +
+'    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">' +
+'    <ows:Exception locator="foo" exceptionCode="InvalidParameterValue">' +
+'        <ows:ExceptionText>Update error: Error occured updating features</ows:ExceptionText>' +
+'        <ows:ExceptionText>Second exception line</ows:ExceptionText>' +
+'    </ows:Exception>' +
+'</ows:ExceptionReport>';
+
+        var obj = parser.read(text);
+        t.ok(!!obj.error, "Error reported correctly");
+    }
     
     function test_read(t) {
         t.plan(33);



More information about the Commits mailing list