Merge
This commit is contained in:
commit
9426c58bef
30 changed files with 479 additions and 50 deletions
|
@ -0,0 +1,57 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using WebsitePanel.WebDav.Core.Config.WebConfigSections;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Config.Entities
|
||||||
|
{
|
||||||
|
public class OwaSupportedBrowsersCollection : AbstractConfigCollection, IReadOnlyDictionary<string, int>
|
||||||
|
{
|
||||||
|
private readonly IDictionary<string, int> _browsers;
|
||||||
|
|
||||||
|
public OwaSupportedBrowsersCollection()
|
||||||
|
{
|
||||||
|
_browsers = ConfigSection.OwaSupportedBrowsers.Cast<OwaSupportedBrowsersElement>().ToDictionary(x => x.Browser, y => y.Version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<KeyValuePair<string, int>> GetEnumerator()
|
||||||
|
{
|
||||||
|
return _browsers.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get { return _browsers.Count; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey(string browser)
|
||||||
|
{
|
||||||
|
return _browsers.ContainsKey(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetValue(string browser, out int version)
|
||||||
|
{
|
||||||
|
return _browsers.TryGetValue(browser, out version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int this[string browser]
|
||||||
|
{
|
||||||
|
get { return ContainsKey(browser) ? _browsers[browser] : 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<string> Keys
|
||||||
|
{
|
||||||
|
get { return _browsers.Keys; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<int> Values
|
||||||
|
{
|
||||||
|
get { return _browsers.Values; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,5 +12,6 @@ namespace WebsitePanel.WebDav.Core.Config
|
||||||
FileIconsDictionary FileIcons { get; }
|
FileIconsDictionary FileIcons { get; }
|
||||||
HttpErrorsCollection HttpErrors { get; }
|
HttpErrorsCollection HttpErrors { get; }
|
||||||
OfficeOnlineCollection OfficeOnline { get; }
|
OfficeOnlineCollection OfficeOnline { get; }
|
||||||
|
OwaSupportedBrowsersCollection OwaSupportedBrowsers { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||||
|
{
|
||||||
|
public class OwaSupportedBrowsersElement : ConfigurationElement
|
||||||
|
{
|
||||||
|
private const string BrowserKey = "browser";
|
||||||
|
private const string VersionKey = "version";
|
||||||
|
|
||||||
|
[ConfigurationProperty(BrowserKey, IsKey = true, IsRequired = true)]
|
||||||
|
public string Browser
|
||||||
|
{
|
||||||
|
get { return (string)this[BrowserKey]; }
|
||||||
|
set { this[BrowserKey] = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[ConfigurationProperty(VersionKey, IsKey = true, IsRequired = true)]
|
||||||
|
public int Version
|
||||||
|
{
|
||||||
|
get { return (int)this[VersionKey]; }
|
||||||
|
set { this[VersionKey] = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDav.Core.Config.WebConfigSections
|
||||||
|
{
|
||||||
|
[ConfigurationCollection(typeof(OwaSupportedBrowsersElement))]
|
||||||
|
public class OwaSupportedBrowsersElementCollection : ConfigurationElementCollection
|
||||||
|
{
|
||||||
|
protected override ConfigurationElement CreateNewElement()
|
||||||
|
{
|
||||||
|
return new OwaSupportedBrowsersElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override object GetElementKey(ConfigurationElement element)
|
||||||
|
{
|
||||||
|
return ((OwaSupportedBrowsersElement)element).Browser;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
private const string ConnectionStringsKey = "appConnectionStrings";
|
private const string ConnectionStringsKey = "appConnectionStrings";
|
||||||
private const string SessionKeysKey = "sessionKeys";
|
private const string SessionKeysKey = "sessionKeys";
|
||||||
private const string FileIconsKey = "fileIcons";
|
private const string FileIconsKey = "fileIcons";
|
||||||
|
private const string OwaSupportedBrowsersKey = "owaSupportedBrowsers";
|
||||||
private const string OfficeOnlineKey = "officeOnline";
|
private const string OfficeOnlineKey = "officeOnline";
|
||||||
|
|
||||||
public const string SectionName = "webDavExplorerConfigurationSettings";
|
public const string SectionName = "webDavExplorerConfigurationSettings";
|
||||||
|
@ -75,6 +76,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
||||||
set { this[FileIconsKey] = value; }
|
set { this[FileIconsKey] = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConfigurationProperty(OwaSupportedBrowsersKey, IsDefaultCollection = false)]
|
||||||
|
public OwaSupportedBrowsersElementCollection OwaSupportedBrowsers
|
||||||
|
{
|
||||||
|
get { return (OwaSupportedBrowsersElementCollection)this[OwaSupportedBrowsersKey]; }
|
||||||
|
set { this[OwaSupportedBrowsersKey] = value; }
|
||||||
|
}
|
||||||
|
|
||||||
[ConfigurationProperty(OfficeOnlineKey, IsDefaultCollection = false)]
|
[ConfigurationProperty(OfficeOnlineKey, IsDefaultCollection = false)]
|
||||||
public OfficeOnlineElementCollection OfficeOnline
|
public OfficeOnlineElementCollection OfficeOnline
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace WebsitePanel.WebDav.Core.Config
|
||||||
FileIcons = new FileIconsDictionary();
|
FileIcons = new FileIconsDictionary();
|
||||||
HttpErrors = new HttpErrorsCollection();
|
HttpErrors = new HttpErrorsCollection();
|
||||||
OfficeOnline = new OfficeOnlineCollection();
|
OfficeOnline = new OfficeOnlineCollection();
|
||||||
|
OwaSupportedBrowsers = new OwaSupportedBrowsersCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WebDavAppConfigManager Instance
|
public static WebDavAppConfigManager Instance
|
||||||
|
@ -51,5 +52,6 @@ namespace WebsitePanel.WebDav.Core.Config
|
||||||
public FileIconsDictionary FileIcons { get; private set; }
|
public FileIconsDictionary FileIcons { get; private set; }
|
||||||
public HttpErrorsCollection HttpErrors { get; private set; }
|
public HttpErrorsCollection HttpErrors { get; private set; }
|
||||||
public OfficeOnlineCollection OfficeOnline { get; private set; }
|
public OfficeOnlineCollection OfficeOnline { get; private set; }
|
||||||
|
public OwaSupportedBrowsersCollection OwaSupportedBrowsers { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,8 +29,13 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
||||||
public bool SupportsUpdate { get; set; }
|
public bool SupportsUpdate { get; set; }
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public bool UserCanWrite { get; set; }
|
public bool UserCanWrite { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public string DownloadUrl { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public bool ReadOnly { get; set; }
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public bool ReadOnly { get; set; }
|
//public bool UserCanNotWriteRelative { get; set; }
|
||||||
|
|
||||||
|
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public string SHA256 { get; set; }
|
//public string SHA256 { get; set; }
|
||||||
|
@ -61,8 +66,6 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public bool DisableTranslation { get; set; }
|
//public bool DisableTranslation { get; set; }
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public string DownloadUrl { get; set; }
|
|
||||||
//[DataMember]
|
|
||||||
//public string FileSharingUrl { get; set; }
|
//public string FileSharingUrl { get; set; }
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public string FileUrl { get; set; }
|
//public string FileUrl { get; set; }
|
||||||
|
@ -112,8 +115,7 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
||||||
//public string TimeZone { get; set; }
|
//public string TimeZone { get; set; }
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public bool UserCanAttend { get; set; }
|
//public bool UserCanAttend { get; set; }
|
||||||
//[DataMember]
|
|
||||||
//public bool UserCanNotWriteRelative { get; set; }
|
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
//public bool UserCanPresent { get; set; }
|
//public bool UserCanPresent { get; set; }
|
||||||
//[DataMember]
|
//[DataMember]
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace WebsitePanel.WebDav.Core.Entities.Owa
|
||||||
|
{
|
||||||
|
public class PutRelativeFile
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string HostViewUrl { get; set; }
|
||||||
|
public string HostEditUrl { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
namespace WebsitePanel.WebDav.Core.Extensions
|
||||||
|
{
|
||||||
|
public static class StringExtensions
|
||||||
|
{
|
||||||
|
public static string ReplaceLast(this string source, string target, string newValue)
|
||||||
|
{
|
||||||
|
int index = source.LastIndexOf(target);
|
||||||
|
string result = source.Remove(index, target.Length).Insert(index, newValue);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Managers
|
||||||
{
|
{
|
||||||
IEnumerable<IHierarchyItem> OpenFolder(string path);
|
IEnumerable<IHierarchyItem> OpenFolder(string path);
|
||||||
bool IsFile(string path);
|
bool IsFile(string path);
|
||||||
|
bool FileExist(string path);
|
||||||
byte[] GetFileBytes(string path);
|
byte[] GetFileBytes(string path);
|
||||||
void UploadFile(string path, HttpPostedFileBase file);
|
void UploadFile(string path, HttpPostedFileBase file);
|
||||||
void UploadFile(string path, byte[] bytes);
|
void UploadFile(string path, byte[] bytes);
|
||||||
|
|
|
@ -190,6 +190,8 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
public void DeleteResource(string path)
|
public void DeleteResource(string path)
|
||||||
{
|
{
|
||||||
path = RemoveLeadingFromPath(path, "office365");
|
path = RemoveLeadingFromPath(path, "office365");
|
||||||
|
path = RemoveLeadingFromPath(path, "view");
|
||||||
|
path = RemoveLeadingFromPath(path, "edit");
|
||||||
path = RemoveLeadingFromPath(path, WspContext.User.OrganizationId);
|
path = RemoveLeadingFromPath(path, WspContext.User.OrganizationId);
|
||||||
|
|
||||||
string folderPath = GetFileFolder(path);
|
string folderPath = GetFileFolder(path);
|
||||||
|
@ -226,6 +228,26 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FileExist(string path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string folder = GetFileFolder(path);
|
||||||
|
|
||||||
|
var resourceName = GetResourceName(path);
|
||||||
|
|
||||||
|
OpenFolder(folder);
|
||||||
|
|
||||||
|
var resource = _currentFolder.GetResource(resourceName);
|
||||||
|
|
||||||
|
return resource != null;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GetFileUrl(string path)
|
public string GetFileUrl(string path)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using Cobalt;
|
using Cobalt;
|
||||||
|
using log4net;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||||
|
|
||||||
|
@ -11,12 +13,16 @@ namespace WebsitePanel.WebDav.Core.Owa
|
||||||
private readonly IWebDavManager _webDavManager;
|
private readonly IWebDavManager _webDavManager;
|
||||||
private readonly IWopiFileManager _fileManager;
|
private readonly IWopiFileManager _fileManager;
|
||||||
private readonly IAccessTokenManager _tokenManager;
|
private readonly IAccessTokenManager _tokenManager;
|
||||||
|
private readonly ILog Log;
|
||||||
|
|
||||||
public CobaltManager(IWebDavManager webDavManager, IWopiFileManager fileManager, IAccessTokenManager tokenManager)
|
public CobaltManager(IWebDavManager webDavManager, IWopiFileManager fileManager,
|
||||||
|
IAccessTokenManager tokenManager)
|
||||||
{
|
{
|
||||||
_webDavManager = webDavManager;
|
_webDavManager = webDavManager;
|
||||||
_fileManager = fileManager;
|
_fileManager = fileManager;
|
||||||
_tokenManager = tokenManager;
|
_tokenManager = tokenManager;
|
||||||
|
|
||||||
|
Log = LogManager.GetLogger(this.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Atom ProcessRequest(int accessTokenId, Stream requestStream)
|
public Atom ProcessRequest(int accessTokenId, Stream requestStream)
|
||||||
|
@ -27,30 +33,69 @@ namespace WebsitePanel.WebDav.Core.Owa
|
||||||
|
|
||||||
var requestBatch = new RequestBatch();
|
var requestBatch = new RequestBatch();
|
||||||
|
|
||||||
var cobaltFile = _fileManager.Get(token.FilePath) ?? _fileManager.Create(accessTokenId);
|
try
|
||||||
|
|
||||||
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)
|
var cobaltFile = _fileManager.Get(token.FilePath) ?? _fileManager.Create(accessTokenId);
|
||||||
{
|
|
||||||
using (var saveStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
GenericFdaStream myCobaltStream = new GenericFda(cobaltFile.CobaltEndpoint, null).GetContentStream();
|
|
||||||
myCobaltStream.CopyTo(saveStream);
|
|
||||||
|
|
||||||
_webDavManager.UploadFile(token.FilePath, saveStream.ToArray());
|
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())
|
||||||
|
{
|
||||||
|
CopyStream(cobaltFile, saveStream);
|
||||||
|
_webDavManager.UploadFile(token.FilePath, saveStream.ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return requestBatch.SerializeOutputToProtocol(protocolVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestBatch.SerializeOutputToProtocol(protocolVersion);
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error("Cobalt manager Process request", e);
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopyStream(CobaltFile file, Stream stream)
|
||||||
|
{
|
||||||
|
var tries = 3;
|
||||||
|
|
||||||
|
for (int i = 0; i < tries; i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GenericFdaStream myCobaltStream = new GenericFda(file.CobaltEndpoint, null).GetContentStream();
|
||||||
|
|
||||||
|
myCobaltStream.CopyTo(stream);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//unable to read update - save failed
|
||||||
|
if (i == tries - 1)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
//waiting for cobalt completion
|
||||||
|
Thread.Sleep(50);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,27 +4,38 @@ using System.Linq;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Runtime.Serialization.Json;
|
using System.Runtime.Serialization.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using WebsitePanel.WebDav.Core.Client;
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
using WebsitePanel.WebDav.Core.Entities.Owa;
|
using WebsitePanel.WebDav.Core.Entities.Owa;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||||
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
using WebsitePanel.WebDav.Core.Interfaces.Owa;
|
||||||
|
using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
|
using WebsitePanel.WebDav.Core.Security.Authentication.Principals;
|
||||||
|
using WebsitePanel.WebDav.Core.Security.Authorization.Enums;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDav.Core.Owa
|
namespace WebsitePanel.WebDav.Core.Owa
|
||||||
{
|
{
|
||||||
public class WopiServer : IWopiServer
|
public class WopiServer : IWopiServer
|
||||||
{
|
{
|
||||||
private readonly IWebDavManager _webDavManager;
|
private readonly IWebDavManager _webDavManager;
|
||||||
|
private readonly IAccessTokenManager _tokenManager;
|
||||||
|
private readonly IWebDavAuthorizationService _webDavAuthorizationService;
|
||||||
|
|
||||||
public WopiServer(IWebDavManager webDavManager)
|
public WopiServer(IWebDavManager webDavManager, IAccessTokenManager tokenManager, IWebDavAuthorizationService webDavAuthorizationService)
|
||||||
{
|
{
|
||||||
_webDavManager = webDavManager;
|
_webDavManager = webDavManager;
|
||||||
|
_tokenManager = tokenManager;
|
||||||
|
_webDavAuthorizationService = webDavAuthorizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckFileInfo GetCheckFileInfo(string path)
|
public CheckFileInfo GetCheckFileInfo(string path)
|
||||||
{
|
{
|
||||||
var resource = _webDavManager.GetResource(path);
|
var resource = _webDavManager.GetResource(path);
|
||||||
|
|
||||||
|
var readOnly = _webDavAuthorizationService.GetPermissions(WspContext.User, path).HasFlag(WebDavPermissions.Write) == false;
|
||||||
|
|
||||||
var cFileInfo = new CheckFileInfo
|
var cFileInfo = new CheckFileInfo
|
||||||
{
|
{
|
||||||
BaseFileName = resource.DisplayName,
|
BaseFileName = resource.DisplayName,
|
||||||
|
@ -38,7 +49,8 @@ namespace WebsitePanel.WebDav.Core.Owa
|
||||||
SupportsScenarioLinks = false,
|
SupportsScenarioLinks = false,
|
||||||
SupportsSecureStore = false,
|
SupportsSecureStore = false,
|
||||||
SupportsUpdate = true,
|
SupportsUpdate = true,
|
||||||
UserCanWrite = true
|
UserCanWrite = !readOnly,
|
||||||
|
ReadOnly = readOnly
|
||||||
};
|
};
|
||||||
|
|
||||||
return cFileInfo;
|
return cFileInfo;
|
||||||
|
|
|
@ -64,8 +64,8 @@ namespace WebsitePanel.WebDav.Core.Security.Authorization
|
||||||
|
|
||||||
private IEnumerable<ESPermission> GetFolderEsPermissions(WspPrincipal principal, string rootFolderName)
|
private IEnumerable<ESPermission> GetFolderEsPermissions(WspPrincipal principal, string rootFolderName)
|
||||||
{
|
{
|
||||||
var dictionary = HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavRootFoldersPermissions] as
|
var dictionary = HttpContext.Current.Session != null ?HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavRootFoldersPermissions] as
|
||||||
Dictionary<string, IEnumerable<ESPermission>>;
|
Dictionary<string, IEnumerable<ESPermission>> : null;
|
||||||
|
|
||||||
if (dictionary == null)
|
if (dictionary == null)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,10 @@ namespace WebsitePanel.WebDav.Core.Security.Authorization
|
||||||
dictionary.Add(rootFolder.Name, permissions);
|
dictionary.Add(rootFolder.Name, permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavRootFoldersPermissions] = dictionary;
|
if (HttpContext.Current.Session != null)
|
||||||
|
{
|
||||||
|
HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavRootFoldersPermissions] = dictionary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dictionary.ContainsKey(rootFolderName) ? dictionary[rootFolderName] : new ESPermission[0];
|
return dictionary.ContainsKey(rootFolderName) ? dictionary[rootFolderName] : new ESPermission[0];
|
||||||
|
@ -88,14 +91,16 @@ namespace WebsitePanel.WebDav.Core.Security.Authorization
|
||||||
|
|
||||||
private IEnumerable<ExchangeAccount> GetUserSecurityGroups(WspPrincipal principal)
|
private IEnumerable<ExchangeAccount> GetUserSecurityGroups(WspPrincipal principal)
|
||||||
{
|
{
|
||||||
var groups = HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.UserGroupsKey] as
|
var groups = HttpContext.Current.Session != null ? HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.UserGroupsKey] as IEnumerable<ExchangeAccount> : null;
|
||||||
IEnumerable<ExchangeAccount>;
|
|
||||||
|
|
||||||
if (groups == null)
|
if (groups == null)
|
||||||
{
|
{
|
||||||
groups = WSP.Services.Organizations.GetSecurityGroupsByMember(principal.ItemId, principal.AccountId);
|
groups = WSP.Services.Organizations.GetSecurityGroupsByMember(principal.ItemId, principal.AccountId);
|
||||||
|
|
||||||
HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.UserGroupsKey] = groups;
|
if (HttpContext.Current.Session != null)
|
||||||
|
{
|
||||||
|
HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.UserGroupsKey] = groups;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups ?? new ExchangeAccount[0];
|
return groups ?? new ExchangeAccount[0];
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
|
<Compile Include="Config\Entities\FileIconsDictionary.cs" />
|
||||||
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
|
<Compile Include="Config\Entities\HttpErrorsCollection.cs" />
|
||||||
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
|
<Compile Include="Config\Entities\OfficeOnlineCollection.cs" />
|
||||||
|
<Compile Include="Config\Entities\OwaSupportedBrowsersCollection.cs" />
|
||||||
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
<Compile Include="Config\Entities\SessionKeysCollection.cs" />
|
||||||
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
<Compile Include="Config\Entities\WebsitePanelConstantUserParameters.cs" />
|
||||||
<Compile Include="Config\IWebDavAppConfig.cs" />
|
<Compile Include="Config\IWebDavAppConfig.cs" />
|
||||||
|
@ -114,6 +115,8 @@
|
||||||
<Compile Include="Config\WebConfigSections\FileIconsElementCollection.cs" />
|
<Compile Include="Config\WebConfigSections\FileIconsElementCollection.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\OfficeOnlineElement.cs" />
|
<Compile Include="Config\WebConfigSections\OfficeOnlineElement.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\OfficeOnlineElementCollection.cs" />
|
<Compile Include="Config\WebConfigSections\OfficeOnlineElementCollection.cs" />
|
||||||
|
<Compile Include="Config\WebConfigSections\OwaSupportedBrowsersElement.cs" />
|
||||||
|
<Compile Include="Config\WebConfigSections\OwaSupportedBrowsersElementCollection.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\SessionKeysElement.cs" />
|
<Compile Include="Config\WebConfigSections\SessionKeysElement.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
|
<Compile Include="Config\WebConfigSections\SessionKeysElementCollection.cs" />
|
||||||
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
|
<Compile Include="Config\WebConfigSections\UserDomainElement.cs" />
|
||||||
|
@ -122,11 +125,13 @@
|
||||||
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
||||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||||
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
|
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
|
||||||
|
<Compile Include="Entities\Owa\PutRelativeFile.cs" />
|
||||||
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
||||||
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
||||||
<Compile Include="Exceptions\UnauthorizedException.cs" />
|
<Compile Include="Exceptions\UnauthorizedException.cs" />
|
||||||
<Compile Include="Exceptions\WebDavException.cs" />
|
<Compile Include="Exceptions\WebDavException.cs" />
|
||||||
<Compile Include="Exceptions\WebDavHttpException.cs" />
|
<Compile Include="Exceptions\WebDavHttpException.cs" />
|
||||||
|
<Compile Include="Extensions\StringExtensions.cs" />
|
||||||
<Compile Include="Extensions\UriExtensions.cs" />
|
<Compile Include="Extensions\UriExtensions.cs" />
|
||||||
<Compile Include="IConnectionSettings.cs" />
|
<Compile Include="IConnectionSettings.cs" />
|
||||||
<Compile Include="IFolder.cs" />
|
<Compile Include="IFolder.cs" />
|
||||||
|
|
|
@ -39,11 +39,29 @@ namespace WebsitePanel.WebDavPortal
|
||||||
);
|
);
|
||||||
|
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: FileSystemRouteNames.ShowOfficeOnlinePath,
|
name: FileSystemRouteNames.DownloadFile,
|
||||||
url: "office365/{org}/{*pathPart}",
|
url: "download-file/{org}/{*pathPart}",
|
||||||
defaults: new { controller = "FileSystem", action = "ShowOfficeDocument", pathPart = UrlParameter.Optional }
|
defaults: new { controller = "FileSystem", action = "DownloadFile" }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
routes.MapRoute(
|
||||||
|
name: FileSystemRouteNames.ViewOfficeOnline,
|
||||||
|
url: "office365/view/{org}/{*pathPart}",
|
||||||
|
defaults: new { controller = "FileSystem", action = "ViewOfficeDocument", pathPart = UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
|
||||||
|
routes.MapRoute(
|
||||||
|
name: FileSystemRouteNames.EditOfficeOnline,
|
||||||
|
url: "office365/edit/{org}/{*pathPart}",
|
||||||
|
defaults: new { controller = "FileSystem", action = "EditOfficeDocument", pathPart = UrlParameter.Optional }
|
||||||
|
);
|
||||||
|
|
||||||
|
//routes.MapRoute(
|
||||||
|
// name: FileSystemRouteNames.ShowOfficeOnlinePath,
|
||||||
|
// url: "office365/{org}/{*pathPart}",
|
||||||
|
// defaults: new { controller = "FileSystem", action = "ShowOfficeDocument", pathPart = UrlParameter.Optional }
|
||||||
|
// );
|
||||||
|
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: FileSystemRouteNames.ShowAdditionalContent,
|
name: FileSystemRouteNames.ShowAdditionalContent,
|
||||||
url: "show-additional-content/{*path}",
|
url: "show-additional-content/{*path}",
|
||||||
|
|
|
@ -67,6 +67,7 @@ textarea {
|
||||||
#logout {
|
#logout {
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
color: #9d9d9d;
|
color: #9d9d9d;
|
||||||
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#logout :hover {
|
#logout :hover {
|
||||||
|
@ -125,6 +126,10 @@ input,div{border-radius:0px!important;}
|
||||||
border-color: #2e8bcc;
|
border-color: #2e8bcc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.navbar-collapse, .navbar-header {
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.navbar-inverse .navbar-brand, .navbar-text, #logout{
|
.navbar-inverse .navbar-brand, .navbar-text, #logout{
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
|
@ -152,6 +157,7 @@ div#breadcrumb_wrapper a:last-child {
|
||||||
float: none;
|
float: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-portal-title {
|
.header-portal-title {
|
||||||
|
|
|
@ -22,6 +22,9 @@ using WebsitePanel.WebDav.Core.Interfaces.Security;
|
||||||
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
using WebsitePanel.WebDav.Core.Security.Cryptography;
|
||||||
using WebsitePanel.WebDav.Core.Wsp.Framework;
|
using WebsitePanel.WebDav.Core.Wsp.Framework;
|
||||||
using WebsitePanel.WebDavPortal.Configurations.ControllerConfigurations;
|
using WebsitePanel.WebDavPortal.Configurations.ControllerConfigurations;
|
||||||
|
using WebsitePanel.WebDavPortal.Extensions;
|
||||||
|
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
|
using WebsitePanel.WebDav.Core.Extensions;
|
||||||
|
|
||||||
namespace WebsitePanel.WebDavPortal.Controllers.Api
|
namespace WebsitePanel.WebDavPortal.Controllers.Api
|
||||||
{
|
{
|
||||||
|
@ -53,6 +56,11 @@ namespace WebsitePanel.WebDavPortal.Controllers.Api
|
||||||
|
|
||||||
var fileInfo = _wopiServer.GetCheckFileInfo(token.FilePath);
|
var fileInfo = _wopiServer.GetCheckFileInfo(token.FilePath);
|
||||||
|
|
||||||
|
var urlPart = Url.Route(FileSystemRouteNames.ShowContentPath, new { org = WspContext.User.OrganizationId, pathPart = token.FilePath });
|
||||||
|
var url = new Uri(Request.RequestUri, urlPart).ToString();
|
||||||
|
|
||||||
|
fileInfo.DownloadUrl = url;
|
||||||
|
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +113,12 @@ namespace WebsitePanel.WebDavPortal.Controllers.Api
|
||||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public HttpResponseMessage Refresh_Lock(int accessTokenId)
|
||||||
|
{
|
||||||
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public HttpResponseMessage UnLock(int accessTokenId)
|
public HttpResponseMessage UnLock(int accessTokenId)
|
||||||
{
|
{
|
||||||
|
@ -122,5 +136,56 @@ namespace WebsitePanel.WebDavPortal.Controllers.Api
|
||||||
|
|
||||||
return new HttpResponseMessage(HttpStatusCode.OK);
|
return new HttpResponseMessage(HttpStatusCode.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public PutRelativeFile Put_Relative(int accessTokenId)
|
||||||
|
{
|
||||||
|
var result = new PutRelativeFile();
|
||||||
|
|
||||||
|
var token = _tokenManager.GetToken(accessTokenId);
|
||||||
|
|
||||||
|
var newFilePath = string.Empty;
|
||||||
|
|
||||||
|
var target = Request.Headers.Contains("X-WOPI-RelativeTarget") ? Request.Headers.GetValues("X-WOPI-RelativeTarget").First() : Request.Headers.GetValues("X-WOPI-SuggestedTarget").First();
|
||||||
|
|
||||||
|
bool overwrite = Request.Headers.Contains("X-WOPI-RelativeTarget") && Convert.ToBoolean(Request.Headers.GetValues("X-WOPI-OverwriteRelativeTarget").First());
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(target))
|
||||||
|
{
|
||||||
|
throw new HttpResponseException(HttpStatusCode.BadRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Count() > 1)
|
||||||
|
{
|
||||||
|
var fileName = Path.GetFileName(token.FilePath);
|
||||||
|
|
||||||
|
newFilePath = token.FilePath.ReplaceLast(fileName, target);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newFilePath = Path.ChangeExtension(token.FilePath, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overwrite == false && _webDavManager.FileExist(newFilePath))
|
||||||
|
{
|
||||||
|
throw new HttpResponseException(HttpStatusCode.Conflict);
|
||||||
|
}
|
||||||
|
|
||||||
|
var bytes = Request.Content.ReadAsByteArrayAsync().Result;
|
||||||
|
|
||||||
|
_webDavManager.UploadFile(newFilePath, bytes);
|
||||||
|
|
||||||
|
var newToken = _tokenManager.CreateToken(WspContext.User,newFilePath);
|
||||||
|
|
||||||
|
var readUrlPart = Url.Route(FileSystemRouteNames.ViewOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = newFilePath});
|
||||||
|
var writeUrlPart = Url.Route(FileSystemRouteNames.EditOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = newFilePath });
|
||||||
|
|
||||||
|
result.HostEditUrl = new Uri(Request.RequestUri, writeUrlPart).ToString();
|
||||||
|
result.HostViewUrl = new Uri(Request.RequestUri, readUrlPart).ToString(); ;
|
||||||
|
result.Name = Path.GetFileName(newFilePath);
|
||||||
|
result.Url = Url.GenerateWopiUrl(newToken, newFilePath);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
|
using System.Security.Policy;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
|
@ -83,12 +84,8 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult ShowOfficeDocument(string org, string pathPart = "")
|
public ActionResult ShowOfficeDocument(string org, string pathPart, string owaOpenerUri)
|
||||||
{
|
{
|
||||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
|
||||||
|
|
||||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
|
||||||
|
|
||||||
string fileUrl = WebDavAppConfigManager.Instance.WebdavRoot+ org + "/" + pathPart.TrimStart('/');
|
string fileUrl = WebDavAppConfigManager.Instance.WebdavRoot+ org + "/" + pathPart.TrimStart('/');
|
||||||
var accessToken = _tokenManager.CreateToken(WspContext.User, pathPart);
|
var accessToken = _tokenManager.CreateToken(WspContext.User, pathPart);
|
||||||
|
|
||||||
|
@ -97,11 +94,32 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
|
|
||||||
string wopiSrc = Server.UrlDecode(url);
|
string wopiSrc = Server.UrlDecode(url);
|
||||||
|
|
||||||
string owaOpenerUri = permissions.HasFlag(WebDavPermissions.Write) ? owaOpener.OwaEditor : owaOpener.OwaView;
|
|
||||||
|
|
||||||
var uri = string.Format("{0}/{1}WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpenerUri, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken.AccessToken.ToString("N")));
|
var uri = string.Format("{0}/{1}WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpenerUri, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken.AccessToken.ToString("N")));
|
||||||
|
|
||||||
return View(new OfficeOnlineModel(uri, new Uri(fileUrl).Segments.Last()));
|
string fileName = fileUrl.Split('/').Last();
|
||||||
|
|
||||||
|
return View("ShowOfficeDocument", new OfficeOnlineModel(uri, fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult ViewOfficeDocument(string org, string pathPart)
|
||||||
|
{
|
||||||
|
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||||
|
|
||||||
|
return ShowOfficeDocument(org, pathPart, owaOpener.OwaView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionResult EditOfficeDocument(string org, string pathPart)
|
||||||
|
{
|
||||||
|
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
||||||
|
|
||||||
|
if (permissions.HasFlag(WebDavPermissions.Write) == false)
|
||||||
|
{
|
||||||
|
return new RedirectToRouteResult(FileSystemRouteNames.ViewOfficeOnline, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||||
|
|
||||||
|
return ShowOfficeDocument(org, pathPart, owaOpener.OwaEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
@ -116,6 +134,26 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
return PartialView("_ResourseCollectionPartial", result);
|
return PartialView("_ResourseCollectionPartial", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult DownloadFile(string org, string pathPart)
|
||||||
|
{
|
||||||
|
if (org != WspContext.User.OrganizationId)
|
||||||
|
{
|
||||||
|
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
string fileName = pathPart.Split('/').Last();
|
||||||
|
|
||||||
|
if (_webdavManager.IsFile(pathPart) == false)
|
||||||
|
{
|
||||||
|
throw new Exception(Resources.NotAFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileBytes = _webdavManager.GetFileBytes(pathPart);
|
||||||
|
|
||||||
|
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult UploadFile(string org, string pathPart)
|
public ActionResult UploadFile(string org, string pathPart)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Http.Routing;
|
||||||
|
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||||
|
using WebsitePanel.WebDav.Core;
|
||||||
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
|
using WebsitePanel.WebDavPortal.UI.Routes;
|
||||||
|
|
||||||
|
namespace WebsitePanel.WebDavPortal.Extensions
|
||||||
|
{
|
||||||
|
public static class UrlHelperExtensions
|
||||||
|
{
|
||||||
|
public static String GenerateWopiUrl(this System.Web.Mvc.UrlHelper urlHelper, WebDavAccessToken token, string path)
|
||||||
|
{
|
||||||
|
var urlPart = urlHelper.HttpRouteUrl(OwaRouteNames.CheckFileInfo, new { accessTokenId = token.Id });
|
||||||
|
|
||||||
|
return GenerateWopiUrl(token, urlPart, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GenerateWopiUrl(this UrlHelper urlHelper, WebDavAccessToken token, string path)
|
||||||
|
{
|
||||||
|
var urlPart = urlHelper.Route(OwaRouteNames.CheckFileInfo, new { accessTokenId = token.Id });
|
||||||
|
|
||||||
|
return GenerateWopiUrl(token, urlPart, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GenerateWopiUrl(WebDavAccessToken token, string urlPart, string path)
|
||||||
|
{
|
||||||
|
var url = new Uri(HttpContext.Current.Request.Url, urlPart).ToString();
|
||||||
|
|
||||||
|
string wopiSrc = HttpUtility.UrlDecode(url);
|
||||||
|
|
||||||
|
return string.Format("{0}&access_token={1}", wopiSrc, token.AccessToken.ToString("N"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
using WebsitePanel.WebDavPortal.Extensions;
|
using WebsitePanel.WebDavPortal.Extensions;
|
||||||
|
|
||||||
|
@ -20,10 +22,23 @@ namespace WebsitePanel.WebDavPortal.FileOperations
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
FileOpenerType result;
|
FileOpenerType result;
|
||||||
if (_operationTypes.TryGetValue(fileExtension, out result))
|
if (_operationTypes.TryGetValue(fileExtension, out result) && CheckBrowserSupport())
|
||||||
return result;
|
return result;
|
||||||
return FileOpenerType.Download;
|
return FileOpenerType.Download;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool CheckBrowserSupport()
|
||||||
|
{
|
||||||
|
var request = HttpContext.Current.Request;
|
||||||
|
int supportedVersion;
|
||||||
|
|
||||||
|
if (WebDavAppConfigManager.Instance.OwaSupportedBrowsers.TryGetValue(request.Browser.Browser, out supportedVersion) == false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return supportedVersion <= request.Browser.MajorVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -159,6 +159,15 @@ namespace WebsitePanel.WebDavPortal.UI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Not a file..
|
||||||
|
/// </summary>
|
||||||
|
public static string NotAFile {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("NotAFile", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Processing.
|
/// Looks up a localized string similar to Processing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -150,6 +150,9 @@
|
||||||
<data name="NoFilesAreSelected" xml:space="preserve">
|
<data name="NoFilesAreSelected" xml:space="preserve">
|
||||||
<value>No files are selected.</value>
|
<value>No files are selected.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="NotAFile" xml:space="preserve">
|
||||||
|
<value>Not a file.</value>
|
||||||
|
</data>
|
||||||
<data name="Processing" xml:space="preserve">
|
<data name="Processing" xml:space="preserve">
|
||||||
<value>Processing</value>
|
<value>Processing</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -8,11 +8,16 @@ namespace WebsitePanel.WebDavPortal.UI.Routes
|
||||||
public class FileSystemRouteNames
|
public class FileSystemRouteNames
|
||||||
{
|
{
|
||||||
public const string ShowContentPath = "ShowContentRoute";
|
public const string ShowContentPath = "ShowContentRoute";
|
||||||
public const string ShowOfficeOnlinePath = "ShowOfficeOnlineRoute";
|
public const string ShowOfficeOnlinePath_ = "ShowOfficeOnlineRoute";
|
||||||
|
public const string ViewOfficeOnline = "ViewOfficeOnlineRoute";
|
||||||
|
public const string EditOfficeOnline = "EditOfficeOnlineRoute";
|
||||||
|
|
||||||
public const string ShowAdditionalContent = "ShowAdditionalContentRoute";
|
public const string ShowAdditionalContent = "ShowAdditionalContentRoute";
|
||||||
|
|
||||||
public const string UploadFile = "UplaodFIleRoute";
|
public const string UploadFile = "UplaodFIleRoute";
|
||||||
|
|
||||||
public const string DeleteFiles = "DeleteFilesRoute";
|
public const string DeleteFiles = "DeleteFilesRoute";
|
||||||
|
|
||||||
|
public const string DownloadFile = "DownloadFileRoute";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
|
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
|
||||||
@{
|
@{
|
||||||
var webDavManager = DependencyResolver.Current.GetService<IWebDavManager>();
|
|
||||||
ViewBag.Title = WebDavAppConfigManager.Instance.ApplicationName;
|
ViewBag.Title = WebDavAppConfigManager.Instance.ApplicationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<title>@Model.FileName</title>
|
<title>@Html.Raw(Model.FileName)</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<iframe src='@Model.Url' width="100%" height="100%" frameborder='0' style="bottom: 0px; left: 0px; position: fixed; right: 0px; top: 0px;">
|
<iframe src='@Model.Url' width="100%" height="100%" frameborder='0' style="bottom: 0px; left: 0px; position: fixed; right: 0px; top: 0px;">
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
case FileOpenerType.OfficeOnline:
|
case FileOpenerType.OfficeOnline:
|
||||||
isTargetBlank = true;
|
isTargetBlank = true;
|
||||||
var pathPart = Model.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/');
|
var pathPart = Model.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/');
|
||||||
href = string.Concat(Url.RouteUrl(FileSystemRouteNames.ShowOfficeOnlinePath, new { org = WspContext.User.OrganizationId, pathPart = "" }), pathPart);
|
href = string.Concat(Url.RouteUrl(FileSystemRouteNames.EditOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = "" }), pathPart);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
isTargetBlank = false;
|
isTargetBlank = false;
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<img class="header-logo" src="@Url.Content("~/Content/Images/logo.png")" />
|
<a href="@Url.RouteUrl(FileSystemRouteNames.ShowContentPath, new { pathPart = string.Empty })">
|
||||||
@Html.RouteLink(WebDavAppConfigManager.Instance.ApplicationName, FileSystemRouteNames.ShowContentPath, new { pathPart = string.Empty }, new { @class = "navbar-brand header-portal-title" })
|
<img class="header-logo" src="@Url.Content("~/Content/Images/logo.png")" />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-collapse collapse">
|
<div class="navbar-collapse collapse">
|
||||||
@{
|
@{
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
</root>
|
</root>
|
||||||
</log4net>
|
</log4net>
|
||||||
|
|
||||||
|
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="webpages:Version" value="3.0.0.0" />
|
<add key="webpages:Version" value="3.0.0.0" />
|
||||||
<add key="webpages:Enabled" value="false" />
|
<add key="webpages:Enabled" value="false" />
|
||||||
|
@ -72,6 +73,12 @@
|
||||||
<add extension=".csv" path="~/Content/Images/csv-icon.png" />
|
<add extension=".csv" path="~/Content/Images/csv-icon.png" />
|
||||||
<add extension=".zip" path="~/Content/Images/zip-icon.png" />
|
<add extension=".zip" path="~/Content/Images/zip-icon.png" />
|
||||||
</fileIcons>
|
</fileIcons>
|
||||||
|
<owaSupportedBrowsers>
|
||||||
|
<add browser="Chrome" version="20" />
|
||||||
|
<add browser="Firefox" version="6" />
|
||||||
|
<add browser="InternetExplorer" version="8" />
|
||||||
|
<add browser="Safari" version="4" />
|
||||||
|
</owaSupportedBrowsers>
|
||||||
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net" cobaltFileTtl="1">
|
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net" cobaltFileTtl="1">
|
||||||
<add extension=".doc" OwaView="wv/wordviewerframe.aspx?" OwaEditor="wv/wordviewerframe.aspx?" />
|
<add extension=".doc" OwaView="wv/wordviewerframe.aspx?" OwaEditor="wv/wordviewerframe.aspx?" />
|
||||||
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.aspx?" />
|
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.aspx?" />
|
||||||
|
|
|
@ -171,6 +171,7 @@
|
||||||
<Compile Include="DependencyInjection\Providers\WebDavManagerProvider.cs" />
|
<Compile Include="DependencyInjection\Providers\WebDavManagerProvider.cs" />
|
||||||
<Compile Include="Extensions\DictionaryExtensions.cs" />
|
<Compile Include="Extensions\DictionaryExtensions.cs" />
|
||||||
<Compile Include="Extensions\UriExtensions.cs" />
|
<Compile Include="Extensions\UriExtensions.cs" />
|
||||||
|
<Compile Include="Extensions\UrlHelperExtensions.cs" />
|
||||||
<Compile Include="FileOperations\FileOpenerManager.cs" />
|
<Compile Include="FileOperations\FileOpenerManager.cs" />
|
||||||
<Compile Include="FileOperations\FileOpenerType.cs" />
|
<Compile Include="FileOperations\FileOpenerType.cs" />
|
||||||
<Compile Include="Global.asax.cs">
|
<Compile Include="Global.asax.cs">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue