webdav portal owa editing alpha
This commit is contained in:
parent
7aa68cd775
commit
aedc7ec08e
33 changed files with 969 additions and 153 deletions
|
@ -13,11 +13,13 @@ namespace WebsitePanel.WebDav.Core.Config.Entities
|
|||
{
|
||||
IsEnabled = ConfigSection.OfficeOnline.IsEnabled;
|
||||
Url = ConfigSection.OfficeOnline.Url;
|
||||
CobaltFileTtl = ConfigSection.OfficeOnline.CobaltFileTtl;
|
||||
_officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().ToList();
|
||||
}
|
||||
|
||||
public bool IsEnabled { get; private set; }
|
||||
public string Url { get; private set; }
|
||||
public int CobaltFileTtl { get; private set; }
|
||||
|
||||
public IEnumerator<OfficeOnlineElement> GetEnumerator()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,8 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
public class OfficeOnlineElement : ConfigurationElement
|
||||
{
|
||||
private const string ExtensionKey = "extension";
|
||||
private const string OwaOpenerKey = "owaOpener";
|
||||
private const string OwaViewKey = "OwaView";
|
||||
private const string OwaEditorKey = "OwaEditor";
|
||||
|
||||
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
|
||||
public string Extension
|
||||
|
@ -14,11 +15,18 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
set { this[ExtensionKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(OwaOpenerKey, IsKey = true, IsRequired = true)]
|
||||
public string OwaOpener
|
||||
[ConfigurationProperty(OwaViewKey, IsKey = true, IsRequired = true)]
|
||||
public string OwaView
|
||||
{
|
||||
get { return this[OwaOpenerKey].ToString(); }
|
||||
set { this[OwaOpenerKey] = value; }
|
||||
get { return this[OwaViewKey].ToString(); }
|
||||
set { this[OwaViewKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(OwaEditorKey, IsKey = true, IsRequired = true)]
|
||||
public string OwaEditor
|
||||
{
|
||||
get { return this[OwaEditorKey].ToString(); }
|
||||
set { this[OwaEditorKey] = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
{
|
||||
private const string UrlKey = "url";
|
||||
private const string IsEnabledKey = "isEnabled";
|
||||
private const string CobaltFileTtlKey = "cobaltFileTtl";
|
||||
|
||||
[ConfigurationProperty(UrlKey, IsKey = true, IsRequired = true)]
|
||||
public string Url
|
||||
|
@ -23,6 +24,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
set { this[IsEnabledKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(CobaltFileTtlKey, IsKey = true, IsRequired = true)]
|
||||
public int CobaltFileTtl
|
||||
{
|
||||
get { return int.Parse(this[CobaltFileTtlKey].ToString()); }
|
||||
set { this[CobaltFileTtlKey] = value; }
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new OfficeOnlineElement();
|
||||
|
|
|
@ -13,6 +13,24 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
public long Size { get; set; }
|
||||
[DataMember]
|
||||
public string Version { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsCoauth { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsCobalt { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsFolders { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsLocks { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsScenarioLinks { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsSecureStore { get; set; }
|
||||
[DataMember]
|
||||
public bool SupportsUpdate { get; set; }
|
||||
[DataMember]
|
||||
public bool UserCanWrite { get; set; }
|
||||
//[DataMember]
|
||||
//public bool ReadOnly { get; set; }
|
||||
|
||||
//[DataMember]
|
||||
//public string SHA256 { get; set; }
|
||||
|
@ -85,20 +103,7 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
//[DataMember]
|
||||
//public string SignoutUrl { get; set; }
|
||||
|
||||
//[DataMember]
|
||||
//public bool SupportsCoauth { get; set; }
|
||||
//[DataMember]
|
||||
//public bool SupportsCobalt { get; set; }
|
||||
//[DataMember]
|
||||
//public bool SupportsFolders { get; set; }
|
||||
//[DataMember]
|
||||
//public bool SupportsLocks { get; set; }
|
||||
//[DataMember]
|
||||
//public bool SupportsScenarioLinks { get; set; }
|
||||
//[DataMember]
|
||||
//public bool SupportsSecureStore { get; set; }
|
||||
//[DataMember]
|
||||
//public bool SupportsUpdate { get; set; }
|
||||
|
||||
//[DataMember]
|
||||
//public string TenantId { get; set; }
|
||||
//[DataMember]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
|
||||
|
@ -10,6 +11,8 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Managers
|
|||
bool IsFile(string path);
|
||||
byte[] GetFileBytes(string path);
|
||||
void UploadFile(string path, HttpPostedFileBase file);
|
||||
void UploadFile(string path, byte[] bytes);
|
||||
void UploadFile(string path, Stream stream);
|
||||
IResource GetResource(string path);
|
||||
string GetFileUrl(string path);
|
||||
void DeleteResource(string path);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using System.IO;
|
||||
using Cobalt;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Interfaces.Owa
|
||||
{
|
||||
public interface ICobaltManager
|
||||
{
|
||||
Atom ProcessRequest(int accessTokenId, Stream requestStream);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
using Cobalt;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Interfaces.Owa
|
||||
{
|
||||
public interface IWopiFileManager
|
||||
{
|
||||
CobaltFile Create(int accessTokenId);
|
||||
CobaltFile Get(int accessTokenId);
|
||||
bool Add(int accessTokenId, CobaltFile file);
|
||||
bool Delete(int accessTokenId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace WebsitePanel.WebDav.Core.Interfaces.Storages
|
||||
{
|
||||
public interface IKeyValueStorage
|
||||
{
|
||||
TV Get<TV>(string id);
|
||||
bool Add<TV>(string id, TV value);
|
||||
bool Delete(string id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using WebsitePanel.Ecommerce.EnterpriseServer;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Interfaces.Storages
|
||||
{
|
||||
public interface ITtlStorage : IKeyValueStorage
|
||||
{
|
||||
void SetTtl<TV>(string id, TV value);
|
||||
}
|
||||
}
|
|
@ -143,6 +143,36 @@ namespace WebsitePanel.WebDav.Core.Managers
|
|||
resource.Upload(bytes);
|
||||
}
|
||||
|
||||
public void UploadFile(string path, byte[] bytes)
|
||||
{
|
||||
var resource = new WebDavResource();
|
||||
|
||||
var fileUrl = new Uri(WebDavAppConfigManager.Instance.WebdavRoot)
|
||||
.Append(WspContext.User.OrganizationId)
|
||||
.Append(path);
|
||||
|
||||
resource.SetHref(fileUrl);
|
||||
resource.SetCredentials(new NetworkCredential(WspContext.User.Login, _cryptography.Decrypt(WspContext.User.EncryptedPassword)));
|
||||
|
||||
resource.Upload(bytes);
|
||||
}
|
||||
|
||||
public void UploadFile(string path, Stream stream)
|
||||
{
|
||||
var resource = new WebDavResource();
|
||||
|
||||
var fileUrl = new Uri(WebDavAppConfigManager.Instance.WebdavRoot)
|
||||
.Append(WspContext.User.OrganizationId)
|
||||
.Append(path);
|
||||
|
||||
resource.SetHref(fileUrl);
|
||||
resource.SetCredentials(new NetworkCredential(WspContext.User.Login, _cryptography.Decrypt(WspContext.User.EncryptedPassword)));
|
||||
|
||||
var bytes = ReadFully(stream);
|
||||
|
||||
resource.Upload(bytes);
|
||||
}
|
||||
|
||||
public void DeleteResource(string path)
|
||||
{
|
||||
path = RemoveLeadingFromPath(path, "office365");
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.Caching;
|
||||
using Cobalt;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Storages;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Owa
|
||||
{
|
||||
public class CobaltFileManager : IWopiFileManager
|
||||
{
|
||||
private readonly IWebDavManager _webDavManager;
|
||||
private readonly IAccessTokenManager _tokenManager;
|
||||
private readonly ITtlStorage _storage;
|
||||
|
||||
public CobaltFileManager(IWebDavManager webDavManager, IAccessTokenManager tokenManager, ITtlStorage storage)
|
||||
{
|
||||
_webDavManager = webDavManager;
|
||||
|
||||
_tokenManager = tokenManager;
|
||||
_storage = storage;
|
||||
}
|
||||
|
||||
public CobaltFile Create(int accessTokenId)
|
||||
{
|
||||
var disposal = new DisposalEscrow(accessTokenId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
var content = new CobaltFilePartitionConfig
|
||||
{
|
||||
IsNewFile = true,
|
||||
HostBlobStore = new TemporaryHostBlobStore(new TemporaryHostBlobStore.Config(), disposal, accessTokenId + @".Content"),
|
||||
cellSchemaIsGenericFda = true,
|
||||
CellStorageConfig = new CellStorageConfig(),
|
||||
Schema = CobaltFilePartition.Schema.ShreddedCobalt,
|
||||
PartitionId = FilePartitionId.Content
|
||||
};
|
||||
|
||||
var coauth = new CobaltFilePartitionConfig
|
||||
{
|
||||
IsNewFile = true,
|
||||
HostBlobStore = new TemporaryHostBlobStore(new TemporaryHostBlobStore.Config(), disposal, accessTokenId + @".CoauthMetadata"),
|
||||
cellSchemaIsGenericFda = false,
|
||||
CellStorageConfig = new CellStorageConfig(),
|
||||
Schema = CobaltFilePartition.Schema.ShreddedCobalt,
|
||||
PartitionId = FilePartitionId.CoauthMetadata
|
||||
};
|
||||
|
||||
var wacupdate = new CobaltFilePartitionConfig
|
||||
{
|
||||
IsNewFile = true,
|
||||
HostBlobStore = new TemporaryHostBlobStore(new TemporaryHostBlobStore.Config(), disposal, accessTokenId + @".WordWacUpdate"),
|
||||
cellSchemaIsGenericFda = false,
|
||||
CellStorageConfig = new CellStorageConfig(),
|
||||
Schema = CobaltFilePartition.Schema.ShreddedCobalt,
|
||||
PartitionId = FilePartitionId.WordWacUpdate
|
||||
};
|
||||
|
||||
var partitionConfs = new Dictionary<FilePartitionId, CobaltFilePartitionConfig>
|
||||
{
|
||||
{FilePartitionId.Content, content},
|
||||
{FilePartitionId.WordWacUpdate, wacupdate},
|
||||
{FilePartitionId.CoauthMetadata, coauth}
|
||||
};
|
||||
|
||||
var cobaltFile = new CobaltFile(disposal, partitionConfs, new CobaltHostLockingStore(), null);
|
||||
|
||||
var token = _tokenManager.GetToken(accessTokenId);
|
||||
|
||||
var fileBytes = _webDavManager.GetFileBytes(token.FilePath);
|
||||
|
||||
var atom = new AtomFromByteArray(fileBytes);
|
||||
|
||||
Cobalt.Metrics o1;
|
||||
cobaltFile.GetCobaltFilePartition(FilePartitionId.Content).SetStream(RootId.Default.Value, atom, out o1);
|
||||
cobaltFile.GetCobaltFilePartition(FilePartitionId.Content).GetStream(RootId.Default.Value).Flush();
|
||||
|
||||
Add(accessTokenId, cobaltFile);
|
||||
|
||||
return cobaltFile;
|
||||
}
|
||||
|
||||
public CobaltFile Get(int accessTokenId)
|
||||
{
|
||||
return _storage.Get<CobaltFile>(GetFileKey(accessTokenId));
|
||||
}
|
||||
|
||||
public bool Add(int accessTokenId, CobaltFile file)
|
||||
{
|
||||
return _storage.Add(GetFileKey(accessTokenId), file);
|
||||
}
|
||||
|
||||
public bool Delete(int accessTokenId)
|
||||
{
|
||||
return _storage.Delete(GetFileKey(accessTokenId));
|
||||
}
|
||||
|
||||
private string GetFileKey(int accessTokenId)
|
||||
{
|
||||
return string.Format("{0}", accessTokenId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,245 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Cobalt;
|
||||
using WebsitePanel.WebDav.Core;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Owa
|
||||
{
|
||||
public class CobaltHostLockingStore : HostLockingStore
|
||||
{
|
||||
public override WhoAmIRequest.OutputType HandleWhoAmI(WhoAmIRequest.InputType input)
|
||||
{
|
||||
WhoAmIRequest.OutputType result = new WhoAmIRequest.OutputType();
|
||||
result.UserIsAnonymous = WspContext.User == null;
|
||||
if (WspContext.User != null)
|
||||
{
|
||||
result.UserEmailAddress = WspContext.User.Login;
|
||||
result.UserLogin = WspContext.User.Login;
|
||||
result.UserName = WspContext.User.DisplayName;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ServerTimeRequest.OutputType HandleServerTime(ServerTimeRequest.InputType input)
|
||||
{
|
||||
ServerTimeRequest.OutputType result = new ServerTimeRequest.OutputType();
|
||||
result.ServerTime = DateTime.UtcNow;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override LockAndCheckOutStatusRequest.OutputType HandleLockAndCheckOutStatus(LockAndCheckOutStatusRequest.InputType input)
|
||||
{
|
||||
LockAndCheckOutStatusRequest.OutputType result = new LockAndCheckOutStatusRequest.OutputType();
|
||||
result.LockType = 1U;
|
||||
result.CheckOutType = 0U;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override GetExclusiveLockRequest.OutputType HandleGetExclusiveLock(GetExclusiveLockRequest.InputType input)
|
||||
{
|
||||
GetExclusiveLockRequest.OutputType result = new GetExclusiveLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override RefreshExclusiveLockRequest.OutputType HandleRefreshExclusiveLock(RefreshExclusiveLockRequest.InputType input)
|
||||
{
|
||||
RefreshExclusiveLockRequest.OutputType result = new RefreshExclusiveLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override CheckExclusiveLockAvailabilityRequest.OutputType HandleCheckExclusiveLockAvailability(CheckExclusiveLockAvailabilityRequest.InputType input)
|
||||
{
|
||||
CheckExclusiveLockAvailabilityRequest.OutputType result = new CheckExclusiveLockAvailabilityRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ConvertExclusiveLockToSchemaLockRequest.OutputType HandleConvertExclusiveLockToSchemaLock(ConvertExclusiveLockToSchemaLockRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
ConvertExclusiveLockToSchemaLockRequest.OutputType result = new ConvertExclusiveLockToSchemaLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ConvertExclusiveLockWithCoauthTransitionRequest.OutputType HandleConvertExclusiveLockWithCoauthTransition(ConvertExclusiveLockWithCoauthTransitionRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
ConvertExclusiveLockWithCoauthTransitionRequest.OutputType result = new ConvertExclusiveLockWithCoauthTransitionRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override GetSchemaLockRequest.OutputType HandleGetSchemaLock(GetSchemaLockRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
GetSchemaLockRequest.OutputType result = new GetSchemaLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public override ReleaseExclusiveLockRequest.OutputType HandleReleaseExclusiveLock(ReleaseExclusiveLockRequest.InputType input)
|
||||
{
|
||||
ReleaseExclusiveLockRequest.OutputType result = new ReleaseExclusiveLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ReleaseSchemaLockRequest.OutputType HandleReleaseSchemaLock(ReleaseSchemaLockRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
ReleaseSchemaLockRequest.OutputType result = new ReleaseSchemaLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override RefreshSchemaLockRequest.OutputType HandleRefreshSchemaLock(RefreshSchemaLockRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
RefreshSchemaLockRequest.OutputType result = new RefreshSchemaLockRequest.OutputType();
|
||||
result.Lock = LockType.SchemaLock;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ConvertSchemaLockToExclusiveLockRequest.OutputType HandleConvertSchemaLockToExclusiveLock(ConvertSchemaLockToExclusiveLockRequest.InputType input)
|
||||
{
|
||||
ConvertSchemaLockToExclusiveLockRequest.OutputType result = new ConvertSchemaLockToExclusiveLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override CheckSchemaLockAvailabilityRequest.OutputType HandleCheckSchemaLockAvailability(CheckSchemaLockAvailabilityRequest.InputType input)
|
||||
{
|
||||
CheckSchemaLockAvailabilityRequest.OutputType result = new CheckSchemaLockAvailabilityRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override JoinCoauthoringRequest.OutputType HandleJoinCoauthoring(JoinCoauthoringRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
JoinCoauthoringRequest.OutputType result = new JoinCoauthoringRequest.OutputType();
|
||||
result.Lock = LockType.SchemaLock;
|
||||
result.CoauthStatus = CoauthStatusType.Alone;
|
||||
result.TransitionId = Guid.NewGuid();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ExitCoauthoringRequest.OutputType HandleExitCoauthoring(ExitCoauthoringRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
ExitCoauthoringRequest.OutputType result = new ExitCoauthoringRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override RefreshCoauthoringSessionRequest.OutputType HandleRefreshCoauthoring(RefreshCoauthoringSessionRequest.InputType input, int protocolMajorVersion, int protocolMinorVersion)
|
||||
{
|
||||
RefreshCoauthoringSessionRequest.OutputType result = new RefreshCoauthoringSessionRequest.OutputType();
|
||||
result.Lock = LockType.SchemaLock;
|
||||
result.CoauthStatus = CoauthStatusType.Alone;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ConvertCoauthLockToExclusiveLockRequest.OutputType HandleConvertCoauthLockToExclusiveLock(ConvertCoauthLockToExclusiveLockRequest.InputType input)
|
||||
{
|
||||
ConvertCoauthLockToExclusiveLockRequest.OutputType result = new ConvertCoauthLockToExclusiveLockRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override CheckCoauthLockAvailabilityRequest.OutputType HandleCheckCoauthLockAvailability(CheckCoauthLockAvailabilityRequest.InputType input)
|
||||
{
|
||||
CheckCoauthLockAvailabilityRequest.OutputType result = new CheckCoauthLockAvailabilityRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override MarkCoauthTransitionCompleteRequest.OutputType HandleMarkCoauthTransitionComplete(MarkCoauthTransitionCompleteRequest.InputType input)
|
||||
{
|
||||
MarkCoauthTransitionCompleteRequest.OutputType result = new MarkCoauthTransitionCompleteRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override GetCoauthoringStatusRequest.OutputType HandleGetCoauthoringStatus(GetCoauthoringStatusRequest.InputType input)
|
||||
{
|
||||
GetCoauthoringStatusRequest.OutputType result = new GetCoauthoringStatusRequest.OutputType();
|
||||
result.CoauthStatus = CoauthStatusType.Alone;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override Dictionary<string, EditorsTableEntry> QueryEditorsTable()
|
||||
{
|
||||
return new Dictionary<string, EditorsTableEntry>();
|
||||
}
|
||||
|
||||
public override JoinEditingSessionRequest.OutputType HandleJoinEditingSession(JoinEditingSessionRequest.InputType input)
|
||||
{
|
||||
JoinEditingSessionRequest.OutputType result = new JoinEditingSessionRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override RefreshEditingSessionRequest.OutputType HandleRefreshEditingSession(RefreshEditingSessionRequest.InputType input)
|
||||
{
|
||||
RefreshEditingSessionRequest.OutputType result = new RefreshEditingSessionRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override LeaveEditingSessionRequest.OutputType HandleLeaveEditingSession(LeaveEditingSessionRequest.InputType input)
|
||||
{
|
||||
LeaveEditingSessionRequest.OutputType result = new LeaveEditingSessionRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override UpdateEditorMetadataRequest.OutputType HandleUpdateEditorMetadata(UpdateEditorMetadataRequest.InputType input)
|
||||
{
|
||||
UpdateEditorMetadataRequest.OutputType result = new UpdateEditorMetadataRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override RemoveEditorMetadataRequest.OutputType HandleRemoveEditorMetadata(RemoveEditorMetadataRequest.InputType input)
|
||||
{
|
||||
RemoveEditorMetadataRequest.OutputType result = new RemoveEditorMetadataRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override ulong GetEditorsTableWaterline()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override AmIAloneRequest.OutputType HandleAmIAlone(AmIAloneRequest.InputType input)
|
||||
{
|
||||
AmIAloneRequest.OutputType result = new AmIAloneRequest.OutputType();
|
||||
result.AmIAlone = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override DocMetaInfoRequest.OutputType HandleDocMetaInfo(DocMetaInfoRequest.InputType input)
|
||||
{
|
||||
DocMetaInfoRequest.OutputType result = new DocMetaInfoRequest.OutputType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override VersionsRequest.OutputType HandleVersions(VersionsRequest.InputType input)
|
||||
{
|
||||
VersionsRequest.OutputType result = new VersionsRequest.OutputType();
|
||||
result.Enabled = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Cobalt;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Owa
|
||||
{
|
||||
public class CobaltManager : ICobaltManager
|
||||
{
|
||||
private readonly IWebDavManager _webDavManager;
|
||||
private readonly IWopiFileManager _fileManager;
|
||||
private readonly IAccessTokenManager _tokenManager;
|
||||
|
||||
public CobaltManager(IWebDavManager webDavManager, IWopiFileManager fileManager, IAccessTokenManager tokenManager)
|
||||
{
|
||||
_webDavManager = webDavManager;
|
||||
_fileManager = fileManager;
|
||||
_tokenManager = tokenManager;
|
||||
}
|
||||
|
||||
public Atom ProcessRequest(int accessTokenId, Stream requestStream)
|
||||
{
|
||||
var token = _tokenManager.GetToken(accessTokenId);
|
||||
|
||||
var atomRequest = new AtomFromStream(requestStream);
|
||||
|
||||
var requestBatch = new RequestBatch();
|
||||
|
||||
var cobaltFile = _fileManager.Get(accessTokenId) ?? _fileManager.Create(accessTokenId);
|
||||
|
||||
Object ctx;
|
||||
ProtocolVersion protocolVersion;
|
||||
|
||||
requestBatch.DeserializeInputFromProtocol(atomRequest, out ctx, out protocolVersion);
|
||||
|
||||
cobaltFile.CobaltEndpoint.ExecuteRequestBatch(requestBatch);
|
||||
|
||||
foreach (var request in requestBatch.Requests)
|
||||
{
|
||||
if (request.GetType() == typeof(PutChangesRequest) && request.PartitionId == FilePartitionId.Content && request.CompletedSuccessfully)
|
||||
{
|
||||
using (var saveStream = new MemoryStream())
|
||||
{
|
||||
GenericFdaStream myCobaltStream = new GenericFda(cobaltFile.CobaltEndpoint, null).GetContentStream();
|
||||
myCobaltStream.CopyTo(saveStream);
|
||||
|
||||
_webDavManager.UploadFile(token.FilePath, saveStream.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requestBatch.SerializeOutputToProtocol(protocolVersion);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,9 +28,17 @@ namespace WebsitePanel.WebDav.Core.Owa
|
|||
var cFileInfo = new CheckFileInfo
|
||||
{
|
||||
BaseFileName = resource.DisplayName,
|
||||
OwnerId = @"4257508bfe174aa28b461536d8b6b648",
|
||||
OwnerId = @"4257508bfe174aa28b461536d8b6b648",// WspContext.User.Login,
|
||||
Size = resource.ContentLength,
|
||||
Version = @"%22%7B59CCD75F%2D0687%2D4F86%2DBBCF%2D059126640640%7D%2C1%22"
|
||||
Version = DateTime.Now.ToString("s"),
|
||||
SupportsCoauth = false,
|
||||
SupportsCobalt = true,
|
||||
SupportsFolders = true,
|
||||
SupportsLocks = false,
|
||||
SupportsScenarioLinks = false,
|
||||
SupportsSecureStore = false,
|
||||
SupportsUpdate = true,
|
||||
UserCanWrite = true
|
||||
};
|
||||
|
||||
return cFileInfo;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Caching;
|
||||
using Microsoft.Web.Services3.Design;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Storages;
|
||||
|
||||
namespace WebsitePanel.WebDav.Core.Storages
|
||||
{
|
||||
public class CacheTtlStorage : ITtlStorage
|
||||
{
|
||||
private static readonly ObjectCache Cache;
|
||||
|
||||
static CacheTtlStorage()
|
||||
{
|
||||
Cache = MemoryCache.Default;
|
||||
}
|
||||
|
||||
public TV Get<TV>(string id)
|
||||
{
|
||||
var value = (TV)Cache[id];
|
||||
|
||||
if (!EqualityComparer<TV>.Default.Equals(value, default(TV)))
|
||||
{
|
||||
SetTtl(id, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public bool Add<TV>(string id, TV value)
|
||||
{
|
||||
return Cache.Add(id, value, DateTime.Now.AddMinutes(WebDavAppConfigManager.Instance.OfficeOnline.CobaltFileTtl));
|
||||
}
|
||||
|
||||
public bool Delete(string id)
|
||||
{
|
||||
if (Cache.Any(x => x.Key == id))
|
||||
{
|
||||
Cache.Remove(id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetTtl<TV>(string id, TV value)
|
||||
{
|
||||
Cache.Set(id, value, DateTime.Now.AddMinutes(WebDavAppConfigManager.Instance.OfficeOnline.CobaltFileTtl));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,9 @@
|
|||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CobaltCore">
|
||||
<HintPath>..\..\Lib\References\Microsoft\Microsoft.CobaltCore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
|
@ -49,6 +52,7 @@
|
|||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.DirectoryServices.AccountManagement" />
|
||||
<Reference Include="System.Runtime.Caching" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Web">
|
||||
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll</HintPath>
|
||||
|
@ -128,6 +132,11 @@
|
|||
<Compile Include="IFolder.cs" />
|
||||
<Compile Include="IHierarchyItem.cs" />
|
||||
<Compile Include="IItemContent.cs" />
|
||||
<Compile Include="Interfaces\Storages\IKeyValueStorage.cs" />
|
||||
<Compile Include="Interfaces\Storages\ITtlStorage.cs" />
|
||||
<Compile Include="Owa\CobaltManager.cs" />
|
||||
<Compile Include="Interfaces\Owa\ICobaltManager.cs" />
|
||||
<Compile Include="Interfaces\Owa\IWopiFileManager.cs" />
|
||||
<Compile Include="Interfaces\Security\IWebDavAuthorizationService.cs" />
|
||||
<Compile Include="Managers\AccessTokenManager.cs" />
|
||||
<Compile Include="Interfaces\Managers\IAccessTokenManager.cs" />
|
||||
|
@ -139,6 +148,8 @@
|
|||
<Compile Include="ItemType.cs" />
|
||||
<Compile Include="LockUriTokenPair.cs" />
|
||||
<Compile Include="Managers\WebDavManager.cs" />
|
||||
<Compile Include="Owa\CobaltFileManager.cs" />
|
||||
<Compile Include="Owa\CobaltHostLockingStore.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Property.cs" />
|
||||
<Compile Include="PropertyName.cs" />
|
||||
|
@ -159,6 +170,7 @@
|
|||
<Compile Include="Security\Authentication\FormsAuthenticationService.cs" />
|
||||
<Compile Include="Security\Authentication\Principals\WspPrincipal.cs" />
|
||||
<Compile Include="Owa\WopiServer.cs" />
|
||||
<Compile Include="Storages\CacheTtlStorage.cs" />
|
||||
<Compile Include="WebDavSession.cs" />
|
||||
<Compile Include="WspContext.cs" />
|
||||
<Compile Include="Wsp\Framework\WSP.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue