Click or drag to resize

ILockRefreshLock Method

IT Hit WebDAV Classes Reference
Updates lock timeout information on this item.

Namespace: ITHit.WebDAV.Server.Class2
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 4.5.3121.0
RefreshLockResult RefreshLock(
	string token,
	Nullable<TimeSpan> requestedTimeOut


Type: SystemString
Lock token.
Type: SystemNullableTimeSpan
Lock timeout which was requested by client. MaxValue means infinity lock that never expires. Note that your server can ignore this parameter and set timeout that is different from the one requested by client.

Return Value

Type: RefreshLockResult
Instance of RefreshLockResult that contains information about the lock including timeout that was actually set.
LockedExceptionThis folder was locked. Client did not provide the lock token.
NeedPrivilegesExceptionThe user doesn't have enough privileges.
InsufficientStorageExceptionQuota limit is reached.
MultistatusExceptionErrors has occurred during processing of the subtree.
DavExceptionIn other cases.
This method is called when WebDAV client wants to modify (usually prolong) timeout for the previously set lock. In this method implementation you can update the lock timeout. Note that you can ignore the requested timout and set timeout that is different from the one requested by client.

The code below is part of 'WebDAVServer.NtfsStorage' sample provided with the SDK.

public RefreshLockResult RefreshLock(string token, TimeSpan? requestedTimeOut)
    var explicitLocks = getExplicitLocks();
    DateLockInfo li = explicitLocks.SingleOrDefault(l => l.LockToken == token);

    if (li == null)
        throw new DavException("Lock can not be found.", DavStatus.PRECONDITION_FAILED);

    if (requestedTimeOut.HasValue && requestedTimeOut != TimeSpan.MaxValue)
        // Update timeout if it is specified and not Infinity.
        // Otherwise leave previous timeout.
        li.TimeOut = requestedTimeOut.Value;

    if (!requestedTimeOut.HasValue)
        li.TimeOut = TimeSpan.FromMinutes(5);

    li.Expiration = DateTime.UtcNow + li.TimeOut;


    return new RefreshLockResult(li.Level, li.IsDeep, li.TimeOut, li.ClientOwner);
See Also