Hi! Today I’d like to show you how the jQuery.dpm library works and how it communicates with the user interface.
Besides taking care of global data as XML headers or defining some additional functions, what the library offers is (method with correspoding WebDAV call in brackets):
- get (
- post (
- head (
- mkcol, createFolder (
- put, createFile (
- remove (
- report (
- getVersionTreeReport (
- checkout (
- uncheckout (
- checkin (
- versionControl (
- lock (
- unlock (
- propfind, getProperty (
- proppatch, setProperty, removeProperty (
And here’s a diagram represeting how a jquery.dpm method works. As you see by the
prepare function we configurate accordingly an XHR that then is sent to the server:
isCollection: Returns whether an element is a collection or not by looking for a collection XML tag inside a resourcetype property. For a DPM server there’s no need to use it since a DPM response includes a specific property iscollection to check this, but the method is needed for standard WebDAV server support.
getNodesByTag: Works exactly like the standard getElementsByTagName, however introduces the ability to filter those results by namespace, which is important for handling WebDAV results.
seekToNode: Sets resource variable to first node matched via getNodesByTag, and returns this, allowing further processing.
eachNode: Executes a function on each element.
nodeText: Get the text contained by a node.
nodeName: Returns the name of a node (the tag name, essentially).
extendbeforesend: jQuery ajax option beforeSend may be set to a function reference, and this function will fire prior to the request being sent. It gets the XHR object, so this is the point you will want to do things like set headers, for example.
prepare: Prepares the WebDAV call. Here we want to ensure integrity of call object, verify WebDAV method requested, set any authorization information (if necesssary), and return the modified call object. WebDAV servers usually respond in XML but some WebDAV methods will not return anything at all, or return an empty response. This matters to jQuery in that the success method of a jQuery.ajax options object won’t fire if the reponse could not be parsed (although the complete method will). Is needed to be aware of what dataType of your ajax response will be, and set it appropriately.
An XML response of the DPM server looks like this:
Depending on the context in the interface and the w2ui library, the XML data is parsed in JSON format and adapted with a specific dpmFilters method. And considering that is a petition on the network, the way to use it is by taking advantage of jQuery ajax callbacks, like for example success.
And that’s all. I hope that with this post you have now a clear vision of how DPMbox communicates with a DPM server.