Skip to content

Commit 2f8684c

Browse files
committed
added report method
1 parent dd9359a commit 2f8684c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

elements/webdav.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,35 @@ apf.webdav = function(struct, tagName){
702702
: null);
703703
};
704704

705+
this.report = function(sPath, reportName, oProperties, callback) {
706+
var aCont = ['<?xml version="1.0" encoding="utf-8" ?>',
707+
'<D:' + reportName + ' xmlns:D="', apf.webdav.NS.D, '">'];
708+
if (oProperties) {
709+
for (var prop in oProperties) {
710+
aCont.push('<D:' + prop, (oProperties[prop]
711+
? '>' + oProperties[prop] + '</D:' + prop + '>'
712+
: '/>'));
713+
}
714+
}
715+
aCont.push('</D:', reportName, '>');
716+
717+
this.method = "REPORT";
718+
this.doRequest(function(data, state, extra) {
719+
var iStatus = parseInt(extra.status);
720+
if (state != apf.SUCCESS) {
721+
var oError = WebDAVError.call(this, "Unable to fetch report on '" + sPath
722+
+ "'. Server says: "
723+
+ apf.webdav.STATUS_CODES[String(iStatus)]);
724+
if (this.dispatchEvent("error", {
725+
error : oError,
726+
bubbles : true
727+
}) === false)
728+
throw oError;
729+
}
730+
callback.call(this, data, state, extra);
731+
}, sPath, aCont.join(""));
732+
};
733+
705734
/**
706735
* Wrapper function that centrally manages locking of resources. Files and
707736
* directories (resources) can be locked prior to any modifying operation to

0 commit comments

Comments
 (0)