Reserves new item name for future use.
CreateLockNull method can be called before creating new folders and resources. This method reserves name of a resource or folder. In your CreateLockNull you must create a new lock-null item.
WebDAV engine passes LockInfo structure to this method by reference. All fields of the structure are provided by WebDAV client except Token field. In your CreateLockNull implementation you must create lock token and set Token member. You must also associate generated token with the new lock-null item in the repository during this call. The token is sent to the WebDAV client.
public WebDAVResponse CreateLockNull(string newItemName, ref LockInfo lockInfo)
{
LockInfo[] locks = ActiveLocks;
if(locks.Length > 0)
{
for(int i=0;i<locks.Length;i++)
if(locks[i].Deep && (!lockInfo.Shared || !locks[i].Shared))
return new LockedResponse();
if(!ClientHasToken)
return new LockedResponse();
}
SqlConnection conn = new SqlConnection(connStr);
SqlTransaction trans = null;
conn.Open();
HierarchyItem newItem;
try
{
trans = conn.BeginTransaction();
newItem = CreateChild(trans, newItemName, ItemType.LockNull);
trans.Commit();
}
catch(Exception ex)
{
if(trans != null) trans.Rollback();
throw;
}
finally
{
conn.Close();
}
newItem.Lock(ref lockInfo);
return new CreatedResponse();
}
public WebDAVResponse Lock(ref LockInfo lockInfo)
{
...
lockInfo.Token = Guid.NewGuid().ToString();
...
}
IFolderLock Interface | ITHit.WebDAV.Server Namespace