summaryrefslogtreecommitdiff
path: root/misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
committerChris Schlaeger <chris@linux.com>2014-08-12 21:56:44 +0200
commitea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch)
treeaf67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js
parent59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff)
downloadpostrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js')
-rw-r--r--misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js108
1 files changed, 108 insertions, 0 deletions
diff --git a/misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js b/misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js
new file mode 100644
index 0000000..61a9da5
--- /dev/null
+++ b/misc/openlayers/lib/OpenLayers/Format/OGCExceptionReport.js
@@ -0,0 +1,108 @@
+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
+ * full list of contributors). Published under the 2-clause BSD license.
+ * See license.txt in the OpenLayers distribution or repository for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Format/XML.js
+ */
+
+/**
+ * Class: OpenLayers.Format.OGCExceptionReport
+ * Class to read exception reports for various OGC services and versions.
+ *
+ * Inherits from:
+ * - <OpenLayers.Format.XML>
+ */
+OpenLayers.Format.OGCExceptionReport = OpenLayers.Class(OpenLayers.Format.XML, {
+
+ /**
+ * Property: namespaces
+ * {Object} Mapping of namespace aliases to namespace URIs.
+ */
+ namespaces: {
+ ogc: "http://www.opengis.net/ogc"
+ },
+
+ /**
+ * Property: regExes
+ * Compiled regular expressions for manipulating strings.
+ */
+ regExes: {
+ trimSpace: (/^\s*|\s*$/g),
+ removeSpace: (/\s*/g),
+ splitSpace: (/\s+/),
+ trimComma: (/\s*,\s*/g)
+ },
+
+ /**
+ * Property: defaultPrefix
+ */
+ defaultPrefix: "ogc",
+
+ /**
+ * Constructor: OpenLayers.Format.OGCExceptionReport
+ * Create a new parser for OGC exception reports.
+ *
+ * Parameters:
+ * options - {Object} An optional object whose properties will be set on
+ * this instance.
+ */
+
+ /**
+ * APIMethod: read
+ * Read OGC exception report data from a string, and return an object with
+ * information about the exceptions.
+ *
+ * Parameters:
+ * data - {String} or {DOMElement} data to read/parse.
+ *
+ * Returns:
+ * {Object} Information about the exceptions that occurred.
+ */
+ read: function(data) {
+ var result;
+ if(typeof data == "string") {
+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
+ }
+ var root = data.documentElement;
+ var exceptionInfo = {exceptionReport: null};
+ if (root) {
+ this.readChildNodes(data, exceptionInfo);
+ if (exceptionInfo.exceptionReport === null) {
+ // fall-back to OWSCommon since this is a common output format for exceptions
+ // we cannot easily use the ows readers directly since they differ for 1.0 and 1.1
+ exceptionInfo = new OpenLayers.Format.OWSCommon().read(data);
+ }
+ }
+ return exceptionInfo;
+ },
+
+ /**
+ * Property: readers
+ * Contains public functions, grouped by namespace prefix, that will
+ * be applied when a namespaced node is found matching the function
+ * name. The function will be applied in the scope of this parser
+ * with two arguments: the node being read and a context object passed
+ * from the parent.
+ */
+ readers: {
+ "ogc": {
+ "ServiceExceptionReport": function(node, obj) {
+ obj.exceptionReport = {exceptions: []};
+ this.readChildNodes(node, obj.exceptionReport);
+ },
+ "ServiceException": function(node, exceptionReport) {
+ var exception = {
+ code: node.getAttribute("code"),
+ locator: node.getAttribute("locator"),
+ text: this.getChildValue(node)
+ };
+ exceptionReport.exceptions.push(exception);
+ }
+ }
+ },
+
+ CLASS_NAME: "OpenLayers.Format.OGCExceptionReport"
+
+});