using System;
using System.IO;
using System.Web;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using Sphorium.WebDAV.Server.Framework.Classes;
using Sphorium.WebDAV.Server.Framework.Resources;
using Sphorium.WebDAV.Server.Framework.BaseClasses;
namespace Everest.CmsServices.Rfc.WebDAV{
public sealed class DavLock : DavLockBase
{
public DavLock()
{
this.ProcessDavRequest += new DavProcessEventHandler(DavLock_ProcessDavRequest);
//this.RefreshLockDavRequest += new DavRefreshLockEventHandler(DavLock_RefreshLockDavRequest);
}
private void DavLock_ProcessDavRequest(object sender, EventArgs e)
{
//TODO: allow collection locking
string _opaqueLock = System.Guid.NewGuid().ToString("D");
//Set the base properties
base.ResponseLock.LockOwner = WebDavHelper.GetUserName(HttpApplication);
base.ResponseLock.AddLockToken(_opaqueLock);
base.ResponseLock.LockTimeout = 10;
}
//private void DavLock_RefreshLockDavRequest(object sender, DavRefreshEventArgs e)
//{
// //Check to see if the lock exists
// DirectoryInfo _dirInfo = RequestWrapper.GetParentDirectory(base.RelativeRequestPath);
// FileInfo[] _lockFiles = _dirInfo.GetFiles("*." + e.LockToken + ".locked");
// if (_lockFiles.Length == 0)
// base.AbortRequest(DavLockResponseCode.PreconditionFailed);
// else
// {
// //Deserialize the lock information
// base.ResponseLock = RequestWrapper.GetLockInfo(_lockFiles[0].FullName);
// //Set the requested lockTimeout or overwrite
// base.ResponseLock.LockTimeout = 10;
// }
//}
}
}
|