Class: Folder

Folder Class

Namespace

ITHit.WebDAV.Client

Represents a folder in a WebDAV repository.

Extends

Members

ActiveLocksArray

List of locks applied to this item.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    // Infinite lock
    oFile.LockAsync(ITHit.WebDAV.Client.LockScope.Shared, false, "User 1", -1, function(oInfiniteLockAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.LockInfo} oInfiniteLockInfo */
        var oInfiniteLockInfo = oInfiniteLockAsyncResult.Result;

        // Minute lock
        oFile.LockAsync(ITHit.WebDAV.Client.LockScope.Shared, false, "User 2", 60, function(oMinuteLockAsyncResult) {

            /** @typedef {ITHit.WebDAV.Client.LockInfo} oMinuteLockInfo */
            var oMinuteLockInfo = oMinuteLockAsyncResult.Result;

            // Refresh item from server to read locks
            oFile.RefreshAsync(function(oAsyncResult) {

                for (var i = 0, l = oFile.ActiveLocks.length; i < l; i++) {

                    /** @typedef {ITHit.WebDAV.Client.LockInfo} oLockInfo */
                    var oLockInfo = oFile.ActiveLocks[i];
                    var sTimeOut = oLockInfo.TimeOut === -1 ? "Infinite" : oLockInfo.TimeOut + ' sec';

                    // Show item locks
                    console.log([
                        oLockInfo.Owner,
                        oLockInfo.LockToken.Href,
                        oLockInfo.LockToken.LockToken,
                        oLockInfo.LockScope,
                        oLockInfo.Deep,
                        sTimeOut
                    ].join(' '));
                }

                fCallback(oFile, oInfiniteLockInfo, oMinuteLockInfo);
            });

        });
    });
});

AvailableBytesnumber

Number of bytes available for this user on server. -1 if server does not support Quota.

CreationDateDate

The date item was created.

DisplayNamestring

User friendly item name.

Hrefstring

This item path on the server.

LastModifiedDate

Most recent modification date.
List of item properties.

ResourceTypestring

Type of the item (File or Folder).
See:
Current WebDAV session.

SupportedLocksArray

Retrieves information about supported locks. Item can support exclusive, shared locks or do not support any locks. If you set exclusive lock other users will not be able to set any locks. If you set shared lock other users will be able to set shared lock on the item.
See:
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oAsyncResult.Result;

    if (oFile.SupportedLocks.length === 0) {
        console.log('Locks are not supported.');
    }

    for (var i = 0, l = oFile.SupportedLocks.length; i < l; i++) {
        if (oFile.SupportedLocks[i] === ITHit.WebDAV.Client.LockScope.Exclusive) {
            console.log('Item supports exclusive locks.');
        }
        if (oFile.SupportedLocks[i] === ITHit.WebDAV.Client.LockScope.Shared) {
            console.log('Item supports shared locks.');
        }
    }

    fCallback(oAsyncResult);
});

UsedBytesnumber

Number of bytes used by this user on server. -1 if server does not support Quota.

VersionControlled

Returns true if file is under version control. Otherwise false. To detect if version control could be enabled for this item call GetSupportedFeaturesAsync and check for VersionControl token. To enable version control call PutUnderVersionControlAsync.

Methods

inherited CopyToAsync(oDestinationFolder, sDestinationName, bDeep, bOverwrite, oLockTokens, fCallback)

Copies this item to destination folder.
Name Type Description
oDestinationFolder ITHit.WebDAV.Client.Folder Folder to move to.
sDestinationName string Name to assign to copied item.
bDeep boolean Indicates whether children of this item should be copied.
bOverwrite boolean Whether existing destination item shall be overwritten.
oLockTokens Array.<ITHit.WebDAV.Client.LockUriTokenPair> optional Lock tokens for destination folder.
fCallback ITHit.WebDAV.Client.HierarchyItem~CopyToAsyncCallback Function to call when operation is completed.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/Products/';
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oFolderAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
        var oFolder = oFolderAsyncResult.Result;

        oFile.CopyToAsync(oFolder, 'myproduct.txt', true, null, null, function(oAsyncResult) {

            if (oAsyncResult.IsSuccess) {
                console.log('Copy successfully completed.');
            } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.PreconditionFailedException) {
                console.log('The item with such name exists and `overwrite` was `false`.');
            } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.WebDavHttpException) {
                var sErrorText = oAsyncResult.Error.Message + ' ' + oAsyncResult.Error.Status.Code + ' ' +
                    oAsyncResult.Error.Status.Description;

                // Find which items failed to copy.
                for(var i = 0, l = oAsyncResult.Error.Multistatus.Responses.length; i < l; i++) {
                    var oResponse = oAsyncResult.Error.Multistatus.Responses[i];
                    sErrorText += '\n' + oResponse.Href + ' ' + oResponse.Status.Code + ' ' +
                        oResponse.Status.Description;
                }

                console.log('Copy error: ' + sErrorText);
            } else {
                console.log('Copy error: ' + String(oAsyncResult.Error));
            }

            fCallback(oAsyncResult);
        });
    });
});

CreateFileAsync(sName, sLockTokens, sContent, aProperties, fCallback){ITHit.WebDAV.Client.Request}

Creates a new file with a specified name as a child of this folder.
Name Type Description
sName string Name of the new file.
sLockTokens string Lock token for current folder.
sContent string File content.
aProperties Array.<ITHit.WebDAV.Client.PropertyName> Additional properties requested from server. Default is empty array.
fCallback ITHit.WebDAV.Client.Folder~CreateFileAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    oFolder.CreateFileAsync('myfile.txt', null, 'Hello World!', null, function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.File} oFile */
        var oFile = oAsyncResult.Result;

        if (oAsyncResult.Error) {
            console.log(oAsyncResult.toString());
        }

        if (oAsyncResult.IsSuccess) {
            console.log(oFile.DisplayName); // myfile.txt
        }

        fCallback(oAsyncResult);
    });
});

CreateFolderAsync(sName, sLockTokens, aProperties, fCallback){ITHit.WebDAV.Client.Request}

Creates a new folder with a specified name as child of this folder.
Name Type Description
sName string Name of the new folder.
sLockTokens string optional Lock token for ITHit.WebDAV.Client.Folder folder.
aProperties Array.<ITHit.WebDAV.Client.PropertyName> Additional properties requested from server. Default is empty array.
fCallback ITHit.WebDAV.Client.Folder~CreateFolderAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function (oAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oAsyncResult.Result;

    oFolder.CreateFolderAsync(sFolderName, null, null, function (oAsyncResult) {

        if (oAsyncResult.IsSuccess) {
            /** @typedef {ITHit.WebDAV.Client.Folder} oNewFolder */
            var oNewFolder = oAsyncResult.Result;

            console.log(oNewFolder.Href);
        } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.MethodNotAllowedException) {
            console.log('Folder already exists.');
        }

        fCallback(oAsyncResult);
    });
});

inherited DeleteAsync(oLockTokens, fCallback){ITHit.WebDAV.Client.Request}

Deletes this item.
Name Type Description
oLockTokens ITHit.WebDAV.Client.LockUriTokenPair Lock tokens for this item or any locked child item.
fCallback ITHit.WebDAV.Client.HierarchyItem~DeleteAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/my_folder/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oAsyncResult.Result;

    oFolder.DeleteAsync(null, function(oAsyncResult) {

        if (oAsyncResult.IsSuccess) {
            console.log('Folder successfully deleted.');
        } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.WebDavHttpException) {
            var sErrorText = oAsyncResult.Error.Message + ' ' + oAsyncResult.Error.Status.Code + ' ' +
                oAsyncResult.Error.Status.Description;

            // Find which items failed to delete.
            for(var i = 0, l = oAsyncResult.Error.Multistatus.Responses.length; i < l; i++) {
                var oResponse = oAsyncResult.Error.Multistatus.Responses[i];
                sErrorText += '\n' + oResponse.Href + ' ' + oResponse.Status.Code + ' ' +
                oResponse.Status.Description;
            }

            console.log('Delete error: ' + sErrorText);
        } else {
            console.log('Delete error: ' + String(oAsyncResult.Error));
        }

        fCallback(oAsyncResult);
    });
});

inherited GetAllPropertiesAsync(fCallback){ITHit.WebDAV.Client.Request}

Retrieves all custom properties exposed by the item.
Name Type Description
fCallback ITHit.WebDAV.Client.HierarchyItem~GetAllPropertiesAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    oFile.GetAllPropertiesAsync(function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Property[]} aProperties */
        var aProperties = oAsyncResult.Result;

        for (var i = 0, l = aProperties.length; i < l; i++) {
            console.log(aProperties[i].Name + ': ' + aProperties[i].StringValue());
        }

        fCallback(oAsyncResult);
    });
});

GetChildrenAsync(bRecursively, aProperties, fCallback){ITHit.WebDAV.Client.Request}

This method returns all items contained in the folder, which may be very large. To limit amount of items returned and get only a single results page use GetPageAsync function instead.
Name Type Description
bRecursively boolean Indicates if all subtree of children should be return. Default is false.
aProperties Array.<ITHit.WebDAV.Client.PropertyName> Additional properties requested from server. If null is specified, only default properties are returned.
fCallback ITHit.WebDAV.Client.Folder~GetChildrenAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

GetFileAsync(sName, fCallback){ITHit.WebDAV.Client.Request}

Gets the specified file from server.
Name Type Description
sName string Name of the file.
fCallback ITHit.WebDAV.Client.Folder~GetFileAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/Products/';
var sFileName = 'myfile.txt';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    oFolder.GetFileAsync(sFileName, function(oFileAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.File} oFile */
        var oFile = oFileAsyncResult.Result;

        console.log('File `' + oFile.DisplayName + '` successful loaded from folder `' + oFolder.DisplayName + '`.');

        fCallback(oFileAsyncResult);
    });
});

GetFolderAsync(sName, fCallback){ITHit.WebDAV.Client.Request}

Gets the specified folder from server.
Name Type Description
sName string Name of the folder.
fCallback ITHit.WebDAV.Client.Folder~GetFolderAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

GetItemAsync(sName, fCallback){ITHit.WebDAV.Client.Request}

Gets the specified item from server.
Name Type Description
sName string Name of the item.
fCallback ITHit.WebDAV.Client.Folder~GetItemAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

GetPageAsync(aProperties, nOffset, nResults, aOrderProperties, fCallback){ITHit.WebDAV.Client.Request}

Gets specified number of children of this folder that correspond to requested offset and sorting. Use GetSupportedFeaturesAsync() function to detect if paging is supported.
Name Type Description
aProperties Array.<ITHit.WebDAV.Client.PropertyName> optional Additional properties requested from server. If null is specified, only default properties are returned.
nOffset number optional The number of items to skip before returning the remaining items.
nResults number optional The number of items to return.
aOrderProperties Array.<ITHit.WebDAV.Client.OrderProperty> optional List of order properties.
fCallback ITHit.WebDAV.Client.Folder~GetPageAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var offset = 10;
var pageSize = 5;
var sortColumns = [new ITHit.WebDAV.Client.OrderProperty(new ITHit.WebDAV.Client.PropertyName('name', 'myNs'), true)];
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function (oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    oFolder.GetPageAsync(null, offset, pageSize, sortColumns, function (oPagingAsyncResult) {

        /** @type {ITHit.WebDAV.Client.HierarchyItem[]} aItems */
        var aItems = oPagingAsyncResult.Result.Page;                                // Items on the requested page.
        /** @type {number} totalPages */
        var totalPages = Math.ceil(oPagingAsyncResult.Result.TotalItems / pageSize); // Total number of pages.
    });
});

inherited GetParentAsync(aProperties, fCallback){ITHit.WebDAV.Client.Request}

Retrieves parent hierarchy item of this item.
Name Type Description
aProperties Array.<ITHit.WebDAV.Client.PropertyName> Additional properties requested from server. Default is empty array.
fCallback ITHit.WebDAV.Client.HierarchyItem~GetParentAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/my_folder/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    oFolder.GetParentAsync(null, function(oParentAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Folder} oParentFolder */
        var oParentFolder = oParentAsyncResult.Result;

        console.log('Parent folder: ' + oParentFolder.DisplayName);

        oParentFolder.GetParentAsync(null, function(oParentParentAsyncResult) {

            /** @typedef {ITHit.WebDAV.Client.Folder} oParentFolder */
            var oParentParentFolder = oParentParentAsyncResult.Result;

            if (oParentParentFolder === null) {
                console.log('Folder is root!');
            }

            fCallback(oParentAsyncResult, oParentParentAsyncResult);
        });
    });
});

inherited GetPropertyNamesAsync(fCallback){ITHit.WebDAV.Client.Request}

Returns names of all custom properties exposed by this item.
Name Type Description
fCallback ITHit.WebDAV.Client.HierarchyItem~GetPropertyNamesAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    oFile.GetPropertyNamesAsync(function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Property[]} aProperties */
        var aPropertyNames = oAsyncResult.Result;

        if (oAsyncResult.IsSuccess) {
            console.log('Properties: ' + aPropertyNames.join(', '));
        }

        fCallback(oAsyncResult);
    });
});

inherited GetPropertyValuesAsync(aNames, fCallback){ITHit.WebDAV.Client.Request}

Retrieves values of specific properties.
Name Type Description
aNames Array.<ITHit.WebDAV.Client.PropertyName>
fCallback ITHit.WebDAV.Client.HierarchyItem~GetPropertyValuesAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    var oPropertyName = new ITHit.WebDAV.Client.PropertyName('myname', 'mynamespace');

    oFile.GetPropertyValuesAsync([oPropertyName], function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Property[]} aProperties */
        var aProperties = oAsyncResult.Result;

        console.log('Value of `mynamespace:myname`: ' + aProperties[0].StringValue());

        fCallback(oAsyncResult);
    });
});

GetSearchPageAsync(sSearchQuery, aProperties, nOffset, nResults, fCallback){ITHit.WebDAV.Client.Request}

Searches folder by search string. Returns specified number of search result items that correspond to requested offset and sorting. Use GetSupportedFeaturesAsync() function to detect if paging is supported.
Name Type Description
sSearchQuery string String of search query.
aProperties Array.<ITHit.WebDAV.Client.PropertyName> optional Additional properties requested from server. If null is specified, only default properties are returned.
nOffset number optional The number of items to skip before returning the remaining items.
nResults number optional The number of items to return.
fCallback ITHit.WebDAV.Client.Folder~GetSearchPageAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var offset = 10;
var pageSize = 5;
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function (oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    oFolder.GetSearchPageAsync('my_file', null, offset, pageSize, function (oPagingAsyncResult) {

        /** @type {ITHit.WebDAV.Client.HierarchyItem[]} aItems */
        var aItems = oPagingAsyncResult.Result.Page;                                // Items on the requested page.
        /** @type {number} totalPages */
        var totalPages = Math.ceil(oPagingAsyncResult.Result.TotalItems / pageSize); // Total number of pages.

        fCallback(oAsyncResult);
    });
});

GetSearchPageByQueryAsync(oSearchQuery, nOffset, nResults, fCallback){ITHit.WebDAV.Client.Request}

Searches folder by query. Returns specified number of search result items that correspond to requested offset and sorting. Use GetSupportedFeaturesAsync() function to detect if paging is supported.
Name Type Description
oSearchQuery ITHit.WebDAV.Client.SearchQuery Object with search query conditions.
nOffset number optional The number of items to skip before returning the remaining items.
nResults number optional The number of items to return.
fCallback ITHit.WebDAV.Client.Folder~GetSearchPageByQueryAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/Products/';
var offset = 10;
var pageSize = 5;
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function (oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    // Build search query
    var oSearchQuery = new ITHit.WebDAV.Client.SearchQuery('my_%');

    // By default WebDAV Ajax Client search by DisplayName property.
    // You can add other properties to this list.
    oSearchQuery.LikeProperties.push(new ITHit.WebDAV.Client.PropertyName('creator-displayname', 'DAV:'));
    oSearchQuery.LikeProperties.push(new ITHit.WebDAV.Client.PropertyName('comment', 'DAV:'));

    // Disable search by file content
    oSearchQuery.EnableContains = false;

    oFolder.GetSearchPageByQueryAsync(oSearchQuery, offset, pageSize, function (oPagingAsyncResult) {

        /** @type {ITHit.WebDAV.Client.HierarchyItem[]} aItems */
        var aItems = oPagingAsyncResult.Result.Page;                                // Items on the requested page.
        /** @type {number} totalPages */
        var totalPages = Math.ceil(oPagingAsyncResult.Result.TotalItems / pageSize); // Total number of pages.

        fCallback(oAsyncResult);
    });
});

inherited GetSourceAsync(fCallback){ITHit.WebDAV.Client.Request}

Retrieves media type independent links.
Name Type Description
fCallback ITHit.WebDAV.Client.HierarchyItem~GetSourceAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

inherited GetSupportedFeaturesAsync(fCallback){ITHit.WebDAV.Client.Request}

Gets features supported by this item, such as WebDAV class support.
Name Type Description
fCallback ITHit.WebDAV.Client.HierarchyItem~GetSupportedFeaturesAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oAsyncResult.Result;

    oFolder.GetSupportedFeaturesAsync(function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.OptionsInfo} oOptionsInfo */
        var oOptionsInfo = oAsyncResult.Result;

        console.log('Locking support: ' + (oOptionsInfo.Features & ITHit.WebDAV.Client.Features.Class2 !== 0 ? 'yes' : 'no'));
        console.log('Resumable upload support: ' + (oOptionsInfo.Features & ITHit.WebDAV.Client.Features.ResumableUpload !== 0 ? 'yes' : 'no'));

        fCallback(oAsyncResult);
    });
});

ItemExistsAsync(sName, fCallback){ITHit.WebDAV.Client.Request}

Checks whether specified item exists in the folder.
Name Type Description
sName string Name of the item.
fCallback ITHit.WebDAV.Client.Folder~ItemExistsAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oAsyncResult.Result;

    oFolder.ItemExistsAsync('my_folder', function(oAsyncResult) {

        if (oAsyncResult.Result) {
            console.log('Item exists');
        } else {
            console.log('Item not found');
        }

        fCallback(oAsyncResult);
    });
});

inherited LockAsync(sLockScope, bDeep, sOwner, iTimeout, fCallback){ITHit.WebDAV.Client.Request}

Locks the item. If the lock was successfully applied, the server will return a lock token. You will pass this lock token back to the server when updating and unlocking the item. The actual lock time applied by the server may be different from the one requested by the client.
Name Type Description
sLockScope string Scope of the lock. See LockScope Enumeration ITHit.WebDAV.Client.LockScope
bDeep boolean Whether to lock entire subtree.
sOwner string Owner of the lock.
iTimeout number Timeout after which lock expires. Pass -1 to request an infinite timeout.
fCallback ITHit.WebDAV.Client.HierarchyItem~LockAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    if (oFile.SupportedLocks.length === 0) {
        console.log('Locks are not supported.');
        return;
    }

    oFile.LockAsync(ITHit.WebDAV.Client.LockScope.Shared, false, 'User 1', -1, function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.LockInfo} oLockInfo */
        var oLockInfo = oAsyncResult.Result;

        if (oAsyncResult.IsSuccess) {
            console.log('Locks token is: ' + oLockInfo.LockToken.LockToken);
        }

        fCallback(oAsyncResult);
    });
});

inherited MoveToAsync(oDestinationFolder, sDestinationName, bOverwrite, oLockTokens, fCallback){ITHit.WebDAV.Client.Request}

Moves this item to another location.
Name Type Description
oDestinationFolder ITHit.WebDAV.Client.Folder Folder to move to.
sDestinationName string Name to assign to moved item.
bOverwrite boolean Whether existing destination item shall be overwritten.
oLockTokens string | Array.<ITHit.WebDAV.Client.LockUriTokenPair> Lock tokens for item to be moved, for destination folder or file to be overwritten that are locked.
fCallback ITHit.WebDAV.Client.HierarchyItem~MoveToAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sDestinationFolderAbsolutePath = 'http://localhost:87654/Sales/';
var sSourceFolderAbsolutePath = 'http://localhost:87654/Products/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sSourceFolderAbsolutePath, null, function(oSourceFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oSourceFolder */
    var oSourceFolder = oSourceFolderAsyncResult.Result;

    webDavSession.OpenFolderAsync(sDestinationFolderAbsolutePath, null, function(oDestinationFolderAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Folder} oDestinationFolder */
        var oDestinationFolder = oDestinationFolderAsyncResult.Result;

        oSourceFolder.MoveToAsync(oDestinationFolder, oSourceFolder.DisplayName, false, null, function(oAsyncResult) {

            if (oAsyncResult.IsSuccess) {
                console.log('Move successfully completed.');
            } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.PreconditionFailedException) {
                console.log('The item with such name exists and `overwrite` was `false`.');
            } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.WebDavHttpException) {
                var sErrorText = oAsyncResult.Error.Message + ' ' + oAsyncResult.Error.Status.Code + ' ' +
                    oAsyncResult.Error.Status.Description;

                // Find which items failed to move.
                for(var i = 0, l = oAsyncResult.Error.Multistatus.Responses.length; i < l; i++) {
                    var oResponse = oAsyncResult.Error.Multistatus.Responses[i];
                    sErrorText += '\n' + oResponse.Href + ' ' + oResponse.Status.Code + ' ' +
                    oResponse.Status.Description;
                }

                console.log('Move error: ' + sErrorText);
            } else {
                console.log('Move error: ' + String(oAsyncResult.Error));
            }

            fCallback(oAsyncResult);
        });
    });
});

inherited RefreshAsync(fCallback){ITHit.WebDAV.Client.Request}

Refreshes item loading data from server.
Name Type Description
fCallback ITHit.WebDAV.Client.HierarchyItem~RefreshAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    // Return file content length
    console.log('Content length: ' + oFile.ContentLength);

    // Update file content
    oFile.WriteContentAsync('My updated content', null, null, function() {

        // Refresh item from server to read new content length
        oFile.RefreshAsync(function(oAsyncResult) {

            // Return file content length
            console.log('Content length: ' + oFile.ContentLength);

            fCallback(oAsyncResult, oFile);
        });
    });
});

inherited RefreshLockAsync(sLockToken, iTimeout, fCallback){ITHit.WebDAV.Client.Request}

Prolongs the lock.
Name Type Description
sLockToken string Identifies lock to be prolonged.
iTimeout number New timeout to set.
fCallback ITHit.WebDAV.Client.HierarchyItem~RefreshLockAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    oFile.LockAsync(ITHit.WebDAV.Client.LockScope.Shared, false, 'User 1', 60, function(oLockAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.LockInfo} oLockInfo */
        var oLockInfo = oLockAsyncResult.Result;

        if (oLockAsyncResult.IsSuccess) {
            console.log('Lock timeout is: ' + oLockInfo.TimeOut);
        }

        oFile.RefreshLockAsync(oLockInfo.LockToken.toString(), 300, function(oRefreshAsyncResult) {

            /** @typedef {ITHit.WebDAV.Client.LockInfo} oLockInfo */
            var oRefreshedLockInfo = oRefreshAsyncResult.Result;

            if (oRefreshAsyncResult.IsSuccess) {
                console.log('Lock timeout is: ' + oRefreshedLockInfo.TimeOut);
            }

            fCallback(oLockAsyncResult, oRefreshAsyncResult);
        });
    });
});

SearchAsync(sSearchQuery, aProperties, fCallback){ITHit.WebDAV.Client.Request}

Searches folder by search string. To limit amount of items returned and get only a single results page use GetSearchPageAsync function instead.
Name Type Description
sSearchQuery string String of search query.
aProperties Array.<ITHit.WebDAV.Client.PropertyName> optional Additional properties requested from server. If null is specified, only default properties are returned.
fCallback ITHit.WebDAV.Client.Folder~SearchAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    oFolder.SearchAsync('my_file', null, function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.HierarchyItems[]} aItems */
        var aItems = oAsyncResult.Result;

        for (var i = 0, l = aItems.length; i < l; i++) {
            console.log(aItems[i].DisplayName);
        }

        fCallback(oAsyncResult);
    });
});

SearchByQueryAsync(oSearchQuery, fCallback){ITHit.WebDAV.Client.Request}

This method returns all items found on the server, which may be very large. To limit amount of items returned and get only a single results page use GetSearchPageByQueryAsync function instead.
Name Type Description
oSearchQuery ITHit.WebDAV.Client.SearchQuery Object with search query conditions.
fCallback ITHit.WebDAV.Client.Folder~SearchByQueryAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/Products/';
var fCallback = function() {};

webDavSession.OpenFolderAsync(sFolderAbsolutePath, null, function(oFolderAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.Folder} oFolder */
    var oFolder = oFolderAsyncResult.Result;

    // Build search query
    var oSearchQuery = new ITHit.WebDAV.Client.SearchQuery('my_%');

    // By default WebDAV Ajax Client search by DisplayName property.
    // You can add other properties to this list.
    oSearchQuery.LikeProperties.push(new ITHit.WebDAV.Client.PropertyName('creator-displayname', 'DAV:'));
    oSearchQuery.LikeProperties.push(new ITHit.WebDAV.Client.PropertyName('comment', 'DAV:'));

    // Disable search by file content
    oSearchQuery.EnableContains = false;

    oFolder.SearchByQueryAsync(oSearchQuery, function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.HierarchyItems[]} aItems */
        var aItems = oAsyncResult.Result;

        for (var i = 0, l = aItems.length; i < l; i++) {
            console.log(aItems[i].DisplayName);
        }

        fCallback(oAsyncResult);
    });
});

inherited UnlockAsync(sLockToken, fCallback){ITHit.WebDAV.Client.Request}

Removes the lock.
Name Type Description
sLockToken string Identifies lock to be prolonged.
fCallback ITHit.WebDAV.Client.HierarchyItem~UnlockAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var sLockToken = 'f36726d1-0671-4f6f-8445-c7d10e42a08e';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    oFile.UnlockAsync(sLockToken, function(oAsyncResult) {

        if (oAsyncResult.IsSuccess) {
            console.log('File is unlocked');
        }

        fCallback(oAsyncResult);
    });
});

inherited UpdatePropertiesAsync(oPropertiesToAddOrUpdate, oPropertiesToDelete, sLockToken, fCallback){ITHit.WebDAV.Client.WebDavRequest|null}

Updates values of properties exposed by this item.
Name Type Description
oPropertiesToAddOrUpdate Array.<ITHit.WebDAV.Client.Property> Properties to be updated.
oPropertiesToDelete Array.<ITHit.WebDAV.Client.PropertyName> Names of properties to be removed from this item.
sLockToken string optional Lock token.
fCallback ITHit.WebDAV.Client.HierarchyItem~UpdatePropertiesAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.WebDavRequest | null WebDAV request
Examples
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    var oPropertyName = new ITHit.WebDAV.Client.PropertyName('myname', 'mynamespace');
    var oProperty = new ITHit.WebDAV.Client.Property(oPropertyName, 'Test value');

    oFile.UpdatePropertiesAsync([oProperty], null, null, function(oAsyncResult) {

        if (oAsyncResult.IsSuccess) {
            console.log('Property `mynamespace:myname` successfully added to file!');
        } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.PropertyException) {
            var sErrorText = oAsyncResult.Error.Message + ' ' + oAsyncResult.Error.Status.Code + ' ' +
                oAsyncResult.Error.Status.Description;

            // Find which properties failed to add/update/delete.
            for(var i = 0, l = oAsyncResult.Error.Multistatus.Responses.length; i < l; i++) {
                var oResponse = oAsyncResult.Error.Multistatus.Responses[i];
                sErrorText += '\n' + oResponse.PropertyName.NamespaceUri + ':' + oResponse.PropertyName.Name + ' ' +
                    oResponse.Status.Code + ' ' + oResponse.Status.Description;
            }

            console.log('Update properties error: ' + sErrorText);
        } else {
            console.log('Update properties error: ' + String(oAsyncResult.Error));
        }

        fCallback(oAsyncResult);
    });
});
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFileAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFileAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    var oPropertyName = new ITHit.WebDAV.Client.PropertyName('myname', 'mynamespace');

    oFile.UpdatePropertiesAsync(null, [oPropertyName], null, function(oAsyncResult) {

        if (oAsyncResult.IsSuccess) {
            console.log('Property `mynamespace:myname` successfully deleted from file!');
        } else if (oAsyncResult.Error instanceof ITHit.WebDAV.Client.Exceptions.PropertyException) {
            var sErrorText = oAsyncResult.Error.Message + ' ' + oAsyncResult.Error.Status.Code + ' ' +
                oAsyncResult.Error.Status.Description;

            // Find which properties failed to add/update/delete.
            for(var i = 0, l = oAsyncResult.Error.Multistatus.Responses.length; i < l; i++) {
                var oResponse = oAsyncResult.Error.Multistatus.Responses[i];
                sErrorText += '\n' + oResponse.PropertyName.NamespaceUri + ':' + oResponse.PropertyName.Name + ' ' +
                oResponse.Status.Code + ' ' + oResponse.Status.Description;
            }

            console.log('Update properties error: ' + sErrorText);
        } else {
            console.log('Update properties error: ' + String(oAsyncResult.Error));
        }

        fCallback(oAsyncResult);
    });
});

Type Definitions

CreateFileAsyncCallback(oResult)

Callback function to be called when a file is created on the server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.File Created file object.

CreateFolderAsyncCallback(oResult)

Callback function to be called when a folder is created on the server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.Folder Created folder object.

GetChildrenAsyncCallback(oResult)

Callback function to be called when children items loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result Array.<ITHit.WebDAV.Client.HierarchyItem> Array of file and folder objects.

GetFileAsyncCallback(oResult)

Callback function to be called when file loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.File File corresponding to requested path.

GetFolderAsyncCallback(oResult)

Callback function to be called when folder loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.Folder Folder object corresponding to requested path.

GetItemAsyncCallback(oResult)

Callback function to be called when item loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.HierarchyItem Item object corresponding to requested path.

GetPageAsyncCallback(oResult)

Callback function to be called when children items loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.PageResults sinle page results.

GetSearchPageAsyncCallback(oResult)

Callback function to be called when search is complete and items are loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.PageResults sinle page results.

GetSearchPageByQueryAsyncCallback(oResult)

Callback function to be called when search is complete and items are loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.PageResults sinle page results.

ItemExistsAsyncCallback(oResult)

Callback function to be called when check request is complete.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result boolean Returns true, if specified item exists; false, otherwise.

OpenItemAsyncCallback(oResult)

Callback function to be called when folder loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result ITHit.WebDAV.Client.Folder Loaded folder object.

SearchAsyncCallback(oResult)

Callback function to be called when search is complete and items are loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object.
Name Type Description
Result Array.<ITHit.WebDAV.Client.HierarchyItem> Array of file objects.

SearchByQueryAsyncCallback(oResult)

Callback function to be called when search is complete and items are loaded from server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object
Name Type Description
Result Array.<ITHit.WebDAV.Client.HierarchyItem> Array of file objects.