Represents a lock-null item in a repository of class 2 WebDAV server.
For a list of all members of this type, see ILockNull Members.
Classes that implement this interface represent WebDAV class 2 server lock-null items. In addition to methods and properties provided by IHierarchyItem and ILock this interface also provides methods for converting a lock-null item to a folder or resource.
The lock-null items are created before folders and resources creation. WebDAV client creates lock-null item with a specified name and than converts it to a resource or folder. However client can also issue folder and resource creation requests without creating lock-null item.
Lock-null items are crated during a call to CreateLockNull method and converted to a resource or folder during a call to ConvertToResource or ConvertToFolder methods.
A lock-null item can not be moved, copied or deleted. It must return NotAllowedResponse from CopyTo, MoveTo, Delete and UpdateProperties implementations. If the item was not converted to a resource or folder and WebDAV client issues unlock request with appropriate lock token the item must be deleted.
A lock-null item must appear among Children items of the folder where it was created.
public class LockNull : HierarchyItem, ILockNull
{
public LockNull(int id, string name, string path, DateTime created, DateTime modified)
:base(id, name, path, created, modified)
{
}
public WebDAVResponse ConvertToResource()
{
if(!ClientHasToken)
return new LockedResponse();
SqlConnection conn = new SqlConnection(connStr);
SqlTransaction trans = null;
conn.Open();
try
{
trans = conn.BeginTransaction();
CreateItemFromLockNull(trans, ID, ItemType.Resource);
trans.Commit();
}
catch(Exception ex)
{
if(trans != null) trans.Rollback();
throw;
}
finally
{
conn.Close();
}
return new CreatedResponse();
}
public WebDAVResponse ConvertToFolder()
{
if(!ClientHasToken)
return new LockedResponse();
SqlConnection conn = new SqlConnection(connStr);
SqlTransaction trans = null;
conn.Open();
try
{
trans = conn.BeginTransaction();
CreateItemFromLockNull(trans, ID, ItemType.Folder);
trans.Commit();
}
catch(Exception ex)
{
if(trans != null) trans.Rollback();
throw;
}
finally
{
conn.Close();
}
return new CreatedResponse();
}
public override WebDAVResponse CopyTo(IFolder folder, string destName, bool deep)
{
return new NotAllowedResponse();
}
public override WebDAVResponse MoveTo(IFolder folder, string destName)
{
return new NotAllowedResponse();
}
public override WebDAVResponse Delete()
{
return new NotAllowedResponse();
}
public override WebDAVResponse UpdateProperties(Property[] setProps, Property[] delProps)
{
return new NotAllowedResponse();
}
private void CreateItemFromLockNull(SqlTransaction trans, int lockNullID, ItemType itemType)
{ // set item type
SqlCommand cmd = trans.Connection.CreateCommand();
cmd.Transaction = trans;
cmd.CommandText = "UPDATE Repository SET ItemType = @ItemType WHERE ID = @ID";
cmd.Parameters.Add("@ItemType", SqlDbType.Int).Value = itemType;
cmd.Parameters.Add("@ID", SqlDbType.Int).Value = lockNullID;
cmd.ExecuteNonQuery();
UpdateModified(trans);
}
}
Namespace: ITHit.WebDAV.Server
Assembly: ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll)
ILockNull Members | ITHit.WebDAV.Server Namespace