webdav portal add owa put relative support
This commit is contained in:
parent
a6b57486bd
commit
2968fbb967
16 changed files with 199 additions and 20 deletions
|
@ -29,8 +29,13 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
public bool SupportsUpdate { get; set; }
|
||||
[DataMember]
|
||||
public bool UserCanWrite { get; set; }
|
||||
[DataMember]
|
||||
public string DownloadUrl { get; set; }
|
||||
[DataMember]
|
||||
public bool ReadOnly { get; set; }
|
||||
//[DataMember]
|
||||
//public bool ReadOnly { get; set; }
|
||||
//public bool UserCanNotWriteRelative { get; set; }
|
||||
|
||||
|
||||
//[DataMember]
|
||||
//public string SHA256 { get; set; }
|
||||
|
@ -61,8 +66,6 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
//[DataMember]
|
||||
//public bool DisableTranslation { get; set; }
|
||||
//[DataMember]
|
||||
//public string DownloadUrl { get; set; }
|
||||
//[DataMember]
|
||||
//public string FileSharingUrl { get; set; }
|
||||
//[DataMember]
|
||||
//public string FileUrl { get; set; }
|
||||
|
@ -112,8 +115,7 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
//public string TimeZone { get; set; }
|
||||
//[DataMember]
|
||||
//public bool UserCanAttend { get; set; }
|
||||
//[DataMember]
|
||||
//public bool UserCanNotWriteRelative { get; set; }
|
||||
|
||||
//[DataMember]
|
||||
//public bool UserCanPresent { get; set; }
|
||||
//[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);
|
||||
bool IsFile(string path);
|
||||
bool FileExist(string path);
|
||||
byte[] GetFileBytes(string path);
|
||||
void UploadFile(string path, HttpPostedFileBase file);
|
||||
void UploadFile(string path, byte[] bytes);
|
||||
|
|
|
@ -226,6 +226,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)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -4,27 +4,38 @@ using System.Linq;
|
|||
using System.Net.Mime;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Entities.Owa;
|
||||
using WebsitePanel.WebDav.Core.Interfaces.Managers;
|
||||
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
|
||||
{
|
||||
public class WopiServer : IWopiServer
|
||||
{
|
||||
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;
|
||||
_tokenManager = tokenManager;
|
||||
_webDavAuthorizationService = webDavAuthorizationService;
|
||||
}
|
||||
|
||||
public CheckFileInfo GetCheckFileInfo(string path)
|
||||
{
|
||||
var resource = _webDavManager.GetResource(path);
|
||||
|
||||
var readOnly = _webDavAuthorizationService.GetPermissions(WspContext.User, path).HasFlag(WebDavPermissions.Write) == false;
|
||||
|
||||
var cFileInfo = new CheckFileInfo
|
||||
{
|
||||
BaseFileName = resource.DisplayName,
|
||||
|
@ -38,7 +49,8 @@ namespace WebsitePanel.WebDav.Core.Owa
|
|||
SupportsScenarioLinks = false,
|
||||
SupportsSecureStore = false,
|
||||
SupportsUpdate = true,
|
||||
UserCanWrite = true
|
||||
UserCanWrite = !readOnly,
|
||||
ReadOnly = readOnly
|
||||
};
|
||||
|
||||
return cFileInfo;
|
||||
|
|
|
@ -64,8 +64,8 @@ namespace WebsitePanel.WebDav.Core.Security.Authorization
|
|||
|
||||
private IEnumerable<ESPermission> GetFolderEsPermissions(WspPrincipal principal, string rootFolderName)
|
||||
{
|
||||
var dictionary = HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavRootFoldersPermissions] as
|
||||
Dictionary<string, IEnumerable<ESPermission>>;
|
||||
var dictionary = HttpContext.Current.Session != null ?HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.WebDavRootFoldersPermissions] as
|
||||
Dictionary<string, IEnumerable<ESPermission>> : null;
|
||||
|
||||
if (dictionary == null)
|
||||
{
|
||||
|
@ -80,7 +80,10 @@ namespace WebsitePanel.WebDav.Core.Security.Authorization
|
|||
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];
|
||||
|
@ -88,14 +91,16 @@ namespace WebsitePanel.WebDav.Core.Security.Authorization
|
|||
|
||||
private IEnumerable<ExchangeAccount> GetUserSecurityGroups(WspPrincipal principal)
|
||||
{
|
||||
var groups = HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.UserGroupsKey] as
|
||||
IEnumerable<ExchangeAccount>;
|
||||
var groups = HttpContext.Current.Session != null ? HttpContext.Current.Session[WebDavAppConfigManager.Instance.SessionKeys.UserGroupsKey] as IEnumerable<ExchangeAccount> : null;
|
||||
|
||||
if (groups == null)
|
||||
{
|
||||
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];
|
||||
|
|
|
@ -125,11 +125,13 @@
|
|||
<Compile Include="Config\WebConfigSections\WebsitePanelConstantUserElement.cs" />
|
||||
<Compile Include="Config\WebDavAppConfigManager.cs" />
|
||||
<Compile Include="Entities\Owa\CheckFileInfo.cs" />
|
||||
<Compile Include="Entities\Owa\PutRelativeFile.cs" />
|
||||
<Compile Include="Exceptions\ConnectToWebDavServerException.cs" />
|
||||
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
|
||||
<Compile Include="Exceptions\UnauthorizedException.cs" />
|
||||
<Compile Include="Exceptions\WebDavException.cs" />
|
||||
<Compile Include="Exceptions\WebDavHttpException.cs" />
|
||||
<Compile Include="Extensions\StringExtensions.cs" />
|
||||
<Compile Include="Extensions\UriExtensions.cs" />
|
||||
<Compile Include="IConnectionSettings.cs" />
|
||||
<Compile Include="IFolder.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue