[Zope-CVS] CVS: Packages/Moztop/moztop/content/lib - jsdav.js:1.11
Stephan Richter
srichter@cbu.edu
Sun, 30 Mar 2003 14:45:45 -0500
Update of /cvs-repository/Packages/Moztop/moztop/content/lib
In directory cvs.zope.org:/tmp/cvs-serv19463/moztop/content/lib
Modified Files:
jsdav.js
Log Message:
Worked a lot on jsdav lib. All HTTP methods now have at least a stub
implementation and I think all of the XML Elements are mapped now (except
prop, which is quiet flexible - more than I could handle so far).
Started writing tests. Wow, this is a lot of work, but it really allows us
to find bugs and finish the error handling.
=== Packages/Moztop/moztop/content/lib/jsdav.js 1.10 => 1.11 === (1158/1258 lines abridged)
--- Packages/Moztop/moztop/content/lib/jsdav.js:1.10 Thu Mar 27 11:45:34 2003
+++ Packages/Moztop/moztop/content/lib/jsdav.js Sun Mar 30 14:45:15 2003
@@ -103,10 +103,6 @@
- Implement Handler.
- - Implement lockinfo XML structure.
-
- - Implement lockdiscovery XML strucutre.
-
- Implement Timeout header.
- Implement Authorization header.
@@ -132,9 +128,9 @@
******************************************************************************/
// Some constants
-const RESOURCE_DEPTH = '0';
-const CHILDREN_DEPTH = '1';
-const ALLSUBS_DEPTH = 'infinity';
+const DAV_RESOURCE_DEPTH = '0';
+const DAV_CHILDREN_DEPTH = '1';
+const DAV_INFINITY_DEPTH = 'infinity';
const xml_decl = '<?xml version="1.0" encoding="utf-8" ?>\n'
/* WebDAV Status Code Extensions
@@ -515,11 +511,40 @@
}
-DavClient.prototype.LOCK = function(url, content, headers) {
+DavClient.prototype.LOCK = function(url, lockinfo, authorization,
+ ifclause, depth, callback) {
/* Implementation of WebDAV command LOCK.
See http://asg.web.cmu.edu/rfc/rfc2518.html#sec-8.10
*/
+ var request = new XMLHttpRequest();
+
+ function handleResponse(error) {
+ locks = new LockDiscovery();
+ locks.parseXML(request.responseXML.documentElement);
+ request.callback(locks);
+ }
+
+ // Make sure we have a URL
+ if (!url) {
+ alert("You must supply a URL");
+ return;
+ }
[-=- -=- -=- 1158 lines omitted -=- -=- -=-]
+ sub = node.childNodes[index];
+ if (sub.localName == 'lockentry') {
+ entry = new LockEntry();
+ entry.parseXML(sub);
+ this.entries[this.entries.length] = entry;
+ }
+ }
+ },
+ createXML: function(parent, doc) {
+ node = doc.createElementNS('DAV:', 'supportedlock');
+ for (var index = 0; index < this.entries.length; index++) {
+ this.entries[index].createXML(node, doc);
+ }
+ parent.appendChild(node);
+ }
+}
+
+
+/* jsdav specific exceptions */
+
+function DavInvalidDepthValueError(value) {
+ /* Handles invalid depth value errors. The constructor accepts the
+ false value. */
+ this.value = value;
+}
+
+DavInvalidDepthValueError.prototype = {
serialize: function() {
- var doc = this.createXML();
- var serializer = new XMLSerializer();
- return xml_decl + serializer.serializeToString(doc);
+ return ("The value '" + this.value + "' is not a valid depth. Use " +
+ "one of the following values instead: 0, 1, infinity");
}
}
+
+function DavWrongTypeError(expected, received) {
+ /* Handles invalid depth value errors. The constructor accepts the
+ false value. */
+ this.expected = expected;
+ this.received = received;
+}
+
+DavWrongTypeError.prototype = {
+ serialize: function() {
+ return ("Expected object type to be [" + this.expected + "], but is [" +
+ this.received + "].");
+ }
+}