using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Text;
using Everest.CmsServices.Models;
using Everest.CmsServices.Services;
using Everest.Library;
using Sphorium.WebDAV.Server.Framework;
using Sphorium.WebDAV.Server.Framework.BaseClasses;
using Everest.CmsServices.MvcHelper;
namespace Everest.CmsServices.Rfc.WebDAV{
/// <summary>
/// WebDav Put
/// PROPFIND /Koala.jpg
/// PUT /Koala.jpg HTTP/1.1
/// LOCK /Koala.jpg HTTP/1.1
/// HEAD /Koala.jpg HTTP/1.1
/// PUT /Koala.jpg HTTP/1.1 (if:(<opaquelocktoken:1f1787ba-d38a-458f-bfc3-142d1530d124>))
/// PROPPATCH /Koala.jpg HTTP/1.1 Response:<?xml version="1.0" encoding="utf-8"?><D:multistatus xmlns:D="DAV:"><D:response xmlns:n3="urn:schemas-microsoft-com:"><D:href>http://192.168.1.29:804/Koala.jpg</D:href><D:propstat><D:status>HTTP/1.1 424 Failed Dependency</D:status><D:prop><n3:Win32CreationTime/><n3:Win32LastAccessTime/><n3:Win32LastModifiedTime/><n3:Win32FileAttributes/></D:prop></D:propstat></D:response></D:multistatus>
/// PROPPATCH /Koala.jpg HTTP/1.1 Response:<?xml version="1.0" encoding="utf-8"?><D:multistatus xmlns:D="DAV:"><D:response xmlns:n3="urn:schemas-microsoft-com:"><D:href>http://192.168.1.29:804/Koala.jpg</D:href><D:propstat><D:status>HTTP/1.1 424 Failed Dependency</D:status><D:prop><n3:Win32CreationTime/><n3:Win32LastAccessTime/><n3:Win32LastModifiedTime/><n3:Win32FileAttributes/></D:prop></D:propstat></D:response></D:multistatus>
/// UNLOCK /Koala.jpg HTTP/1.1
/// </summary>
public class DavPut : DavPutBase
{
public DavPut()
{
this.ProcessDavRequest += new DavProcessEventHandler(DavPut_ProcessDavRequest);
}
private void DavPut_ProcessDavRequest(object sender, EventArgs e)
{
if (base.HttpApplication.Request.InputStream.Length != 0)
{
try
{
WebDavUrlData urlData = new WebDavUrlData(WebDavHelper.GetRawHostUrl(HttpApplication.Request), this.RelativeRequestPath);
BinaryContentService binaryContentService = UnityManager.Resolve<BinaryContentService>();
//ContentService contentService = new ContentService(urlData.Application);
//var content = contentService.SetQueryType(Everest.CmsServices.Providers.QueryType.All).GetBinaryContentByUserKey(urlData.ContentKey, null);
var userName = WebDavHelper.GetUserName(HttpApplication);
var folder = CachedData.GetFolder(urlData.Application, urlData.FolderName);
var fileName = Path.GetFileName(base.RelativeRequestPath);
NameValueCollection values = new NameValueCollection();
values["Title"] = Path.GetFileNameWithoutExtension(fileName);
values["folderUUID"] = folder.UUID.ToString();
values["Published"] = "true";
values["UserName"] = userName;
//if (content != null)
//{
// binaryContentService.UpdateBinaryContent((Guid)content["UUID"], values, userName, fileName, base.HttpApplication.Request.InputStream);
//}
//else
//{
binaryContentService.AddBinaryContent(values, userName, fileName, base.HttpApplication.Request.InputStream);
//}
}
catch (Exception ex)
{
base.AbortRequest(DavPutResponseCode.Forbidden);
}
}
}
}
}
|