diff --git a/src/Umbraco.Core/Persistence/Repositories/IPartialViewRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IPartialViewRepository.cs index b0eb7055ec..d1e322dd4c 100644 --- a/src/Umbraco.Core/Persistence/Repositories/IPartialViewRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/IPartialViewRepository.cs @@ -1,4 +1,3 @@ -using System.IO; using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Core.Persistence.Repositories @@ -7,9 +6,5 @@ namespace Umbraco.Cms.Core.Persistence.Repositories { void AddFolder(string folderPath); void DeleteFolder(string folderPath); - bool ValidatePartialView(IPartialView partialView); - Stream GetFileContentStream(string filepath); - void SetFileContent(string filepath, Stream content); - long GetFileSize(string filepath); } } diff --git a/src/Umbraco.Core/Services/IFileService.cs b/src/Umbraco.Core/Services/IFileService.cs index c2d99aceed..9fa4d9b8e6 100644 --- a/src/Umbraco.Core/Services/IFileService.cs +++ b/src/Umbraco.Core/Services/IFileService.cs @@ -17,15 +17,12 @@ namespace Umbraco.Cms.Core.Services void DeletePartialViewMacroFolder(string folderPath); IPartialView GetPartialView(string path); IPartialView GetPartialViewMacro(string path); - IEnumerable GetPartialViewMacros(params string[] names); Attempt CreatePartialView(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId); Attempt CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId); bool DeletePartialView(string path, int userId = Constants.Security.SuperUserId); bool DeletePartialViewMacro(string path, int userId = Constants.Security.SuperUserId); Attempt SavePartialView(IPartialView partialView, int userId = Constants.Security.SuperUserId); Attempt SavePartialViewMacro(IPartialView partialView, int userId = Constants.Security.SuperUserId); - bool ValidatePartialView(IPartialView partialView); - bool ValidatePartialViewMacro(IPartialView partialView); /// /// Gets a list of all objects @@ -203,48 +200,6 @@ namespace Umbraco.Cms.Core.Services /// The size of the stylesheet. long GetStylesheetFileSize(string filepath); - /// - /// Gets the content of a macro partial view as a stream. - /// - /// The filesystem path to the macro partial view. - /// The content of the macro partial view. - Stream GetPartialViewMacroFileContentStream(string filepath); - - /// - /// Sets the content of a macro partial view. - /// - /// The filesystem path to the macro partial view. - /// The content of the macro partial view. - void SetPartialViewMacroFileContent(string filepath, Stream content); - - /// - /// Gets the size of a macro partial view. - /// - /// The filesystem path to the macro partial view. - /// The size of the macro partial view. - long GetPartialViewMacroFileSize(string filepath); - - /// - /// Gets the content of a partial view as a stream. - /// - /// The filesystem path to the partial view. - /// The content of the partial view. - Stream GetPartialViewFileContentStream(string filepath); - - /// - /// Sets the content of a partial view. - /// - /// The filesystem path to the partial view. - /// The content of the partial view. - void SetPartialViewFileContent(string filepath, Stream content); - - /// - /// Gets the size of a partial view. - /// - /// The filesystem path to the partial view. - /// The size of the partial view. - long GetPartialViewFileSize(string filepath); - /// /// Gets the content of a macro partial view snippet as a string /// diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewMacroRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewMacroRepository.cs index 47123b790e..b4c8ce4f6c 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewMacroRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewMacroRepository.cs @@ -6,8 +6,8 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement { internal class PartialViewMacroRepository : PartialViewRepository, IPartialViewMacroRepository { - public PartialViewMacroRepository(FileSystems fileSystems, IIOHelper ioHelper) - : base(fileSystems.MacroPartialsFileSystem, ioHelper) + public PartialViewMacroRepository(FileSystems fileSystems) + : base(fileSystems.MacroPartialsFileSystem) { } protected override PartialViewType ViewType => PartialViewType.PartialViewMacro; diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewRepository.cs index a1d2b218c4..751c84ac56 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PartialViewRepository.cs @@ -11,18 +11,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement { internal class PartialViewRepository : FileRepository, IPartialViewRepository { - private readonly IIOHelper _ioHelper; - - public PartialViewRepository(FileSystems fileSystems, IIOHelper ioHelper) + public PartialViewRepository(FileSystems fileSystems) : base(fileSystems.PartialViewsFileSystem) { - _ioHelper = ioHelper; } - protected PartialViewRepository(IFileSystem fileSystem, IIOHelper ioHelper) + protected PartialViewRepository(IFileSystem fileSystem) : base(fileSystem) { - _ioHelper = ioHelper; } protected virtual PartialViewType ViewType => PartialViewType.PartialView; @@ -93,29 +89,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement } } - private static readonly List ValidExtensions = new List { "cshtml" }; - - public virtual bool ValidatePartialView(IPartialView partialView) - { - // get full path - string fullPath; - try - { - // may throw for security reasons - fullPath = FileSystem.GetFullPath(partialView.Path); - } - catch - { - return false; - } - - // validate path & extension - var validDir = Cms.Core.Constants.SystemDirectories.MvcViews; - var isValidPath = _ioHelper.VerifyEditPath(fullPath, validDir); - var isValidExtension = _ioHelper.VerifyFileExtension(fullPath, ValidExtensions); - return isValidPath && isValidExtension; - } - public Stream GetFileContentStream(string filepath) { if (FileSystem.FileExists(filepath) == false) return null; diff --git a/src/Umbraco.Infrastructure/Services/Implement/FileService.cs b/src/Umbraco.Infrastructure/Services/Implement/FileService.cs index d946863781..b515e3d0a8 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/FileService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/FileService.cs @@ -600,14 +600,6 @@ namespace Umbraco.Cms.Core.Services.Implement } } - public IEnumerable GetPartialViewMacros(params string[] names) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewMacroRepository.GetMany(names).OrderBy(x => x.Name); - } - } - public Attempt CreatePartialView(IPartialView partialView, string snippetName = null, int userId = Cms.Core.Constants.Security.SuperUserId) { return CreatePartialViewMacro(partialView, PartialViewType.PartialView, snippetName, userId); @@ -762,22 +754,6 @@ namespace Umbraco.Cms.Core.Services.Implement return Attempt.Succeed(partialView); } - public bool ValidatePartialView(IPartialView partialView) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewRepository.ValidatePartialView(partialView); - } - } - - public bool ValidatePartialViewMacro(IPartialView partialView) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewMacroRepository.ValidatePartialView(partialView); - } - } - internal string StripPartialViewHeader(string contents) { var headerMatch = new Regex("^@inherits\\s+?.*$", RegexOptions.Multiline); @@ -797,40 +773,6 @@ namespace Umbraco.Cms.Core.Services.Implement : Attempt.Fail(); } - public Stream GetPartialViewMacroFileContentStream(string filepath) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewMacroRepository.GetFileContentStream(filepath); - } - } - - public void SetPartialViewMacroFileContent(string filepath, Stream content) - { - using (var scope = ScopeProvider.CreateScope()) - { - _partialViewMacroRepository.SetFileContent(filepath, content); - scope.Complete(); - } - } - - public Stream GetPartialViewFileContentStream(string filepath) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewRepository.GetFileContentStream(filepath); - } - } - - public void SetPartialViewFileContent(string filepath, Stream content) - { - using (var scope = ScopeProvider.CreateScope()) - { - _partialViewRepository.SetFileContent(filepath, content); - scope.Complete(); - } - } - public void CreatePartialViewFolder(string folderPath) { using (var scope = ScopeProvider.CreateScope()) @@ -849,22 +791,6 @@ namespace Umbraco.Cms.Core.Services.Implement } } - public long GetPartialViewMacroFileSize(string filepath) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewMacroRepository.GetFileSize(filepath); - } - } - - public long GetPartialViewFileSize(string filepath) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _partialViewRepository.GetFileSize(filepath); - } - } - private IPartialViewRepository GetPartialViewRepository(PartialViewType partialViewType) { switch (partialViewType) diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs index b0769f68ed..02709f7f84 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs @@ -51,7 +51,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.Repos IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { - var repository = new PartialViewRepository(fileSystems, IOHelper); + var repository = new PartialViewRepository(fileSystems); var partialView = new PartialView(PartialViewType.PartialView, "test-path-1.cshtml") { Content = "// partialView" }; repository.Save(partialView);