diff --git a/build/NuSpecs/UmbracoCms.nuspec b/build/NuSpecs/UmbracoCms.nuspec
index 3cb3d0d875..a188377c19 100644
--- a/build/NuSpecs/UmbracoCms.nuspec
+++ b/build/NuSpecs/UmbracoCms.nuspec
@@ -52,10 +52,8 @@
-
-
diff --git a/src/Umbraco.Core/Composing/Composers/ServicesComposer.cs b/src/Umbraco.Core/Composing/Composers/ServicesComposer.cs
index 8c9ccd1088..3f1bc1df5e 100644
--- a/src/Umbraco.Core/Composing/Composers/ServicesComposer.cs
+++ b/src/Umbraco.Core/Composing/Composers/ServicesComposer.cs
@@ -73,11 +73,6 @@ namespace Umbraco.Core.Composing.Composers
factory.GetInstance(), factory.GetInstance(),
new DirectoryInfo(IOHelper.GetRootDirectorySafe())));
- //TODO: These are replaced in the web project - we need to declare them so that
- // something is wired up, just not sure this is very nice but will work for now.
- composition.RegisterUnique();
- composition.RegisterUnique();
-
return composition;
}
@@ -88,7 +83,7 @@ namespace Umbraco.Core.Composing.Composers
///
///
private static PackagesRepository CreatePackageRepository(IFactory factory, string packageRepoFileName)
- => new PackagesRepository(
+ => new PackagesRepository(
factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(),
packageRepoFileName);
diff --git a/src/Umbraco.Core/Composing/TypeLoader.cs b/src/Umbraco.Core/Composing/TypeLoader.cs
index acb12ab575..4c4139848d 100644
--- a/src/Umbraco.Core/Composing/TypeLoader.cs
+++ b/src/Umbraco.Core/Composing/TypeLoader.cs
@@ -185,9 +185,7 @@ namespace Umbraco.Core.Composing
// the app code folder and everything in it
new Tuple(new DirectoryInfo(IOHelper.MapPath("~/App_Code")), false),
// global.asax (the app domain also monitors this, if it changes will do a full restart)
- new Tuple(new FileInfo(IOHelper.MapPath("~/global.asax")), false),
- // trees.config - use the contents to create the hash since this gets resaved on every app startup!
- new Tuple(new FileInfo(IOHelper.MapPath(SystemDirectories.Config + "/trees.config")), true)
+ new Tuple(new FileInfo(IOHelper.MapPath("~/global.asax")), false)
}, _logger);
return _currentAssembliesHash;
diff --git a/src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs b/src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs
new file mode 100644
index 0000000000..a1b89d9a01
--- /dev/null
+++ b/src/Umbraco.Core/Manifest/ManifestBackOfficeSection.cs
@@ -0,0 +1,15 @@
+using System.Runtime.Serialization;
+using Umbraco.Core.Models.Trees;
+
+namespace Umbraco.Core.Manifest
+{
+ [DataContract(Name = "section", Namespace = "")]
+ public class ManifestBackOfficeSection : IBackOfficeSection
+ {
+ [DataMember(Name = "alias")]
+ public string Alias { get; set; }
+
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+ }
+}
diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs
index 59753df66a..c471bbcf2e 100644
--- a/src/Umbraco.Core/Manifest/ManifestParser.cs
+++ b/src/Umbraco.Core/Manifest/ManifestParser.cs
@@ -9,6 +9,7 @@ using Umbraco.Core.Exceptions;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.ContentEditing;
+using Umbraco.Core.Models.Trees;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
@@ -101,6 +102,7 @@ namespace Umbraco.Core.Manifest
var gridEditors = new List();
var contentApps = new List();
var dashboards = new List();
+ var sections = new List();
foreach (var manifest in manifests)
{
@@ -111,6 +113,7 @@ namespace Umbraco.Core.Manifest
if (manifest.GridEditors != null) gridEditors.AddRange(manifest.GridEditors);
if (manifest.ContentApps != null) contentApps.AddRange(manifest.ContentApps);
if (manifest.Dashboards != null) dashboards.AddRange(manifest.Dashboards);
+ if (manifest.Sections != null) sections.AddRange(manifest.Sections.DistinctBy(x => x.Alias.ToLowerInvariant()));
}
return new PackageManifest
@@ -121,7 +124,8 @@ namespace Umbraco.Core.Manifest
ParameterEditors = parameterEditors.ToArray(),
GridEditors = gridEditors.ToArray(),
ContentApps = contentApps.ToArray(),
- Dashboards = dashboards.ToArray()
+ Dashboards = dashboards.ToArray(),
+ Sections = sections.ToArray()
};
}
diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs
index cd806ac847..b29a28ab06 100644
--- a/src/Umbraco.Core/Manifest/PackageManifest.cs
+++ b/src/Umbraco.Core/Manifest/PackageManifest.cs
@@ -1,6 +1,5 @@
using System;
using Newtonsoft.Json;
-using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
@@ -10,25 +9,52 @@ namespace Umbraco.Core.Manifest
///
public class PackageManifest
{
+ ///
+ /// Gets or sets the scripts listed in the manifest.
+ ///
[JsonProperty("javascript")]
public string[] Scripts { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the stylesheets listed in the manifest.
+ ///
[JsonProperty("css")]
- public string[] Stylesheets { get; set; }= Array.Empty();
+ public string[] Stylesheets { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the property editors listed in the manifest.
+ ///
[JsonProperty("propertyEditors")]
public IDataEditor[] PropertyEditors { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the parameter editors listed in the manifest.
+ ///
[JsonProperty("parameterEditors")]
public IDataEditor[] ParameterEditors { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the grid editors listed in the manifest.
+ ///
[JsonProperty("gridEditors")]
public GridEditor[] GridEditors { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the content apps listed in the manifest.
+ ///
[JsonProperty("contentApps")]
public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the dashboards listed in the manifest.
+ ///
[JsonProperty("dashboards")]
public ManifestDashboardDefinition[] Dashboards { get; set; } = Array.Empty();
+
+ ///
+ /// Gets or sets the sections listed in the manifest.
+ ///
+ [JsonProperty("sections")]
+ public ManifestBackOfficeSection[] Sections { get; set; } = Array.Empty();
}
}
diff --git a/src/Umbraco.Core/Models/ApplicationTree.cs b/src/Umbraco.Core/Models/ApplicationTree.cs
deleted file mode 100644
index ccdebea724..0000000000
--- a/src/Umbraco.Core/Models/ApplicationTree.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Diagnostics;
-using Umbraco.Core.Services;
-
-namespace Umbraco.Core.Models
-{
- [DebuggerDisplay("Tree - {Title} ({ApplicationAlias})")]
- public class ApplicationTree
- {
- private static readonly ConcurrentDictionary ResolvedTypes = new ConcurrentDictionary();
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ApplicationTree() { }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// if set to true [initialize].
- /// The sort order.
- /// The application alias.
- /// The tree alias.
- /// The tree title.
- /// The icon closed.
- /// The icon opened.
- /// The tree type.
- public ApplicationTree(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
- {
- Initialize = initialize;
- SortOrder = sortOrder;
- ApplicationAlias = applicationAlias;
- Alias = alias;
- Title = title;
- IconClosed = iconClosed;
- IconOpened = iconOpened;
- Type = type;
-
- }
-
- ///
- /// Gets or sets a value indicating whether this should initialize.
- ///
- /// true if initialize; otherwise, false.
- public bool Initialize { get; set; }
-
- ///
- /// Gets or sets the sort order.
- ///
- /// The sort order.
- public int SortOrder { get; set; }
-
- ///
- /// Gets the application alias.
- ///
- /// The application alias.
- public string ApplicationAlias { get; }
-
- ///
- /// Gets the tree alias.
- ///
- /// The alias.
- public string Alias { get; }
-
- ///
- /// Gets or sets the tree title.
- ///
- /// The title.
- public string Title { get; set; }
-
- ///
- /// Gets or sets the icon closed.
- ///
- /// The icon closed.
- public string IconClosed { get; set; }
-
- ///
- /// Gets or sets the icon opened.
- ///
- /// The icon opened.
- public string IconOpened { get; set; }
-
- ///
- /// Gets or sets the tree type assembly name.
- ///
- /// The type.
- public string Type { get; set; }
-
- ///
- /// Returns the localized root node display name
- ///
- ///
- ///
- public string GetRootNodeDisplayName(ILocalizedTextService textService)
- {
- var label = $"[{Alias}]";
-
- // try to look up a the localized tree header matching the tree alias
- var localizedLabel = textService.Localize("treeHeaders/" + Alias);
-
- // if the localizedLabel returns [alias] then return the title attribute from the trees.config file, if it's defined
- if (localizedLabel != null && localizedLabel.Equals(label, StringComparison.InvariantCultureIgnoreCase))
- {
- if (string.IsNullOrEmpty(Title) == false)
- label = Title;
- }
- else
- {
- // the localizedLabel translated into something that's not just [alias], so use the translation
- label = localizedLabel;
- }
-
- return label;
- }
-
- private Type _runtimeType;
-
- ///
- /// Returns the CLR type based on it's assembly name stored in the config
- ///
- ///
- public Type GetRuntimeType()
- {
- return _runtimeType ?? (_runtimeType = System.Type.GetType(Type));
- }
-
- ///
- /// Used to try to get and cache the tree type
- ///
- ///
- ///
- internal static Type TryGetType(string type)
- {
- try
- {
- return ResolvedTypes.GetOrAdd(type, s =>
- {
- var result = System.Type.GetType(type);
- if (result != null)
- {
- return result;
- }
-
- //we need to implement a bit of a hack here due to some trees being renamed and backwards compat
- var parts = type.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (parts.Length != 2)
- throw new InvalidOperationException("Could not resolve type");
- if (parts[1].Trim() != "Umbraco.Web" || parts[0].StartsWith("Umbraco.Web.Trees") == false || parts[0].EndsWith("Controller"))
- throw new InvalidOperationException("Could not resolve type");
-
- //if it's one of our controllers but it's not suffixed with "Controller" then add it and try again
- var tempType = parts[0] + "Controller, Umbraco.Web";
-
- result = System.Type.GetType(tempType);
- if (result != null)
- return result;
-
- throw new InvalidOperationException("Could not resolve type");
- });
- }
- catch (InvalidOperationException)
- {
- //swallow, this is our own exception, couldn't find the type
- // fixme bad use of exceptions here!
- return null;
- }
- }
- }
-}
diff --git a/src/Umbraco.Core/Models/Section.cs b/src/Umbraco.Core/Models/Section.cs
deleted file mode 100644
index 4b7f8309dd..0000000000
--- a/src/Umbraco.Core/Models/Section.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-namespace Umbraco.Core.Models
-{
- ///
- /// Represents a section defined in the app.config file.
- ///
- public class Section
- {
- public Section(string name, string @alias, int sortOrder)
- {
- Name = name;
- Alias = alias;
- SortOrder = sortOrder;
- }
-
- public Section()
- { }
-
- public string Name { get; set; }
- public string Alias { get; set; }
- public int SortOrder { get; set; }
- }
-}
diff --git a/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs b/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs
new file mode 100644
index 0000000000..86e2a18fd5
--- /dev/null
+++ b/src/Umbraco.Core/Models/Trees/IBackOfficeSection.cs
@@ -0,0 +1,18 @@
+namespace Umbraco.Core.Models.Trees
+{
+ ///
+ /// Defines a back office section.
+ ///
+ public interface IBackOfficeSection
+ {
+ ///
+ /// Gets the alias of the section.
+ ///
+ string Alias { get; }
+
+ ///
+ /// Gets the name of the section.
+ ///
+ string Name { get; }
+ }
+}
diff --git a/src/Umbraco.Core/Services/IApplicationTreeService.cs b/src/Umbraco.Core/Services/IApplicationTreeService.cs
deleted file mode 100644
index 691a3a0b63..0000000000
--- a/src/Umbraco.Core/Services/IApplicationTreeService.cs
+++ /dev/null
@@ -1,152 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Umbraco.Core.Models;
-
-namespace Umbraco.Core.Services
-{
- public interface IApplicationTreeService
- {
- ///
- /// Creates a new application tree.
- ///
- /// if set to true [initialize].
- /// The sort order.
- /// The application alias.
- /// The alias.
- /// The title.
- /// The icon closed.
- /// The icon opened.
- /// The type.
- void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type);
-
- ///
- /// Saves this instance.
- ///
- void SaveTree(ApplicationTree tree);
-
- ///
- /// Deletes this instance.
- ///
- void DeleteTree(ApplicationTree tree);
-
- ///
- /// Gets an ApplicationTree by it's tree alias.
- ///
- /// The tree alias.
- /// An ApplicationTree instance
- ApplicationTree GetByAlias(string treeAlias);
-
- ///
- /// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
- ///
- /// Returns a ApplicationTree Array
- IEnumerable GetAll();
-
- ///
- /// Gets the application tree for the applcation with the specified alias
- ///
- /// The application alias.
- /// Returns a ApplicationTree Array
- IEnumerable GetApplicationTrees(string applicationAlias);
-
- ///
- /// Gets the application tree for the applcation with the specified alias
- ///
- /// The application alias.
- ///
- /// Returns a ApplicationTree Array
- IEnumerable GetApplicationTrees(string applicationAlias, bool onlyInitialized);
-
- ///
- /// Gets the grouped application trees for the application with the specified alias
- ///
- ///
- ///
- ///
- IDictionary> GetGroupedApplicationTrees(string applicationAlias, bool onlyInitialized);
- }
-
- ///
- /// Purely used to allow a service context to create the default services
- ///
- internal class EmptyApplicationTreeService : IApplicationTreeService
- {
- ///
- /// Creates a new application tree.
- ///
- /// if set to true [initialize].
- /// The sort order.
- /// The application alias.
- /// The alias.
- /// The title.
- /// The icon closed.
- /// The icon opened.
- /// The type.
- public void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Saves this instance.
- ///
- public void SaveTree(ApplicationTree tree)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Deletes this instance.
- ///
- public void DeleteTree(ApplicationTree tree)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Gets an ApplicationTree by it's tree alias.
- ///
- /// The tree alias.
- /// An ApplicationTree instance
- public ApplicationTree GetByAlias(string treeAlias)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
- ///
- /// Returns a ApplicationTree Array
- public IEnumerable GetAll()
- {
- throw new System.NotImplementedException();
- }
-
- public IDictionary> GetGroupedApplicationTrees(string applicationAlias, bool onlyInitialized)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Gets the application tree for the applcation with the specified alias
- ///
- /// The application alias.
- /// Returns a ApplicationTree Array
- public IEnumerable GetApplicationTrees(string applicationAlias)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Gets the application tree for the applcation with the specified alias
- ///
- /// The application alias.
- ///
- /// Returns a ApplicationTree Array
- public IEnumerable GetApplicationTrees(string applicationAlias, bool onlyInitialized)
- {
- throw new System.NotImplementedException();
- }
- }
-}
diff --git a/src/Umbraco.Core/Services/ISectionService.cs b/src/Umbraco.Core/Services/ISectionService.cs
deleted file mode 100644
index 899ae78245..0000000000
--- a/src/Umbraco.Core/Services/ISectionService.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-using System.Collections.Generic;
-using Umbraco.Core.Models;
-
-namespace Umbraco.Core.Services
-{
- public interface ISectionService
- {
- ///
- /// The cache storage for all applications
- ///
- IEnumerable GetSections();
-
- ///
- /// Get the user group's allowed sections
- ///
- ///
- ///
- IEnumerable GetAllowedSections(int userId);
-
- ///
- /// Gets the application by its alias.
- ///
- /// The application alias.
- ///
- Section GetByAlias(string appAlias);
-
- ///
- /// Creates a new applcation if no application with the specified alias is found.
- ///
- /// The application name.
- /// The application alias.
- /// The application icon, which has to be located in umbraco/images/tray folder.
- void MakeNew(string name, string alias, string icon);
-
- ///
- /// Makes the new.
- ///
- /// The name.
- /// The alias.
- /// The icon.
- /// The sort order.
- void MakeNew(string name, string alias, string icon, int sortOrder);
-
- ///
- /// Deletes the section
- ///
- void DeleteSection(Section section);
- }
-
- ///
- /// Purely used to allow a service context to create the default services
- ///
- internal class EmptySectionService : ISectionService
- {
- ///
- /// The cache storage for all applications
- ///
- public IEnumerable GetSections()
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Get the user's allowed sections
- ///
- ///
- ///
- public IEnumerable GetAllowedSections(int userId)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Gets the application by its alias.
- ///
- /// The application alias.
- ///
- public Section GetByAlias(string appAlias)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Creates a new applcation if no application with the specified alias is found.
- ///
- /// The application name.
- /// The application alias.
- /// The application icon, which has to be located in umbraco/images/tray folder.
- public void MakeNew(string name, string alias, string icon)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Makes the new.
- ///
- /// The name.
- /// The alias.
- /// The icon.
- /// The sort order.
- public void MakeNew(string name, string alias, string icon, int sortOrder)
- {
- throw new System.NotImplementedException();
- }
-
- ///
- /// Deletes the section
- ///
- public void DeleteSection(Section section)
- {
- throw new System.NotImplementedException();
- }
- }
-}
diff --git a/src/Umbraco.Core/Services/ServiceContext.cs b/src/Umbraco.Core/Services/ServiceContext.cs
index 731d3a58c6..6d7ac8a5e7 100644
--- a/src/Umbraco.Core/Services/ServiceContext.cs
+++ b/src/Umbraco.Core/Services/ServiceContext.cs
@@ -25,8 +25,6 @@ namespace Umbraco.Core.Services
private readonly Lazy _serverRegistrationService;
private readonly Lazy _entityService;
private readonly Lazy _relationService;
- private readonly Lazy _treeService;
- private readonly Lazy _sectionService;
private readonly Lazy _macroService;
private readonly Lazy _memberTypeService;
private readonly Lazy _memberGroupService;
@@ -38,7 +36,7 @@ namespace Umbraco.Core.Services
///
/// Initializes a new instance of the class with lazy services.
///
- public ServiceContext(Lazy publicAccessService, Lazy domainService, Lazy auditService, Lazy localizedTextService, Lazy tagService, Lazy contentService, Lazy userService, Lazy memberService, Lazy mediaService, Lazy contentTypeService, Lazy mediaTypeService, Lazy dataTypeService, Lazy fileService, Lazy localizationService, Lazy packagingService, Lazy serverRegistrationService, Lazy entityService, Lazy relationService, Lazy treeService, Lazy sectionService, Lazy macroService, Lazy memberTypeService, Lazy memberGroupService, Lazy notificationService, Lazy externalLoginService, Lazy redirectUrlService, Lazy consentService)
+ public ServiceContext(Lazy publicAccessService, Lazy domainService, Lazy auditService, Lazy localizedTextService, Lazy tagService, Lazy contentService, Lazy userService, Lazy memberService, Lazy mediaService, Lazy contentTypeService, Lazy mediaTypeService, Lazy dataTypeService, Lazy fileService, Lazy localizationService, Lazy packagingService, Lazy serverRegistrationService, Lazy entityService, Lazy relationService, Lazy macroService, Lazy memberTypeService, Lazy memberGroupService, Lazy notificationService, Lazy externalLoginService, Lazy redirectUrlService, Lazy consentService)
{
_publicAccessService = publicAccessService;
_domainService = domainService;
@@ -58,8 +56,6 @@ namespace Umbraco.Core.Services
_serverRegistrationService = serverRegistrationService;
_entityService = entityService;
_relationService = relationService;
- _treeService = treeService;
- _sectionService = sectionService;
_macroService = macroService;
_memberTypeService = memberTypeService;
_memberGroupService = memberGroupService;
@@ -90,8 +86,6 @@ namespace Umbraco.Core.Services
IMemberTypeService memberTypeService = null,
IMemberService memberService = null,
IUserService userService = null,
- ISectionService sectionService = null,
- IApplicationTreeService treeService = null,
ITagService tagService = null,
INotificationService notificationService = null,
ILocalizedTextService localizedTextService = null,
@@ -125,8 +119,6 @@ namespace Umbraco.Core.Services
Lazy(serverRegistrationService),
Lazy(entityService),
Lazy(relationService),
- Lazy(treeService),
- Lazy(sectionService),
Lazy(macroService),
Lazy(memberTypeService),
Lazy(memberGroupService),
@@ -236,16 +228,6 @@ namespace Umbraco.Core.Services
///
public IMemberService MemberService => _memberService.Value;
- ///
- /// Gets the
- ///
- public ISectionService SectionService => _sectionService.Value;
-
- ///
- /// Gets the
- ///
- public IApplicationTreeService ApplicationTreeService => _treeService.Value;
-
///
/// Gets the MemberTypeService
///
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 81c5af104f..94f422e027 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -353,6 +353,7 @@
+
@@ -447,6 +448,7 @@
+
@@ -676,7 +678,6 @@
-
@@ -873,7 +874,6 @@
-
@@ -1388,7 +1388,6 @@
-
@@ -1418,7 +1417,6 @@
-
diff --git a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
index 50b27da89f..3532a11c63 100644
--- a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
+++ b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs
@@ -47,13 +47,6 @@ namespace Umbraco.Tests.Cache
//Permission.Deleted += PermissionDeleted;
//PermissionRepository.AssignedPermissions += CacheRefresherEventHandler_AssignedPermissions;
- new EventDefinition(null, serviceContext.ApplicationTreeService, new EventArgs(), "Deleted"),
- new EventDefinition(null, serviceContext.ApplicationTreeService, new EventArgs(), "Updated"),
- new EventDefinition(null, serviceContext.ApplicationTreeService, new EventArgs(), "New"),
-
- new EventDefinition(null, serviceContext.SectionService, new EventArgs(), "Deleted"),
- new EventDefinition(null, serviceContext.SectionService, new EventArgs(), "New"),
-
new EventDefinition>(null, serviceContext.UserService, new SaveEventArgs(Enumerable.Empty())),
new EventDefinition>(null, serviceContext.UserService, new DeleteEventArgs(Enumerable.Empty())),
new EventDefinition>(null, serviceContext.UserService, new SaveEventArgs(Enumerable.Empty())),
diff --git a/src/Umbraco.Tests/Composing/TypeFinderTests.cs b/src/Umbraco.Tests/Composing/TypeFinderTests.cs
index 49c807b19f..2b9474310b 100644
--- a/src/Umbraco.Tests/Composing/TypeFinderTests.cs
+++ b/src/Umbraco.Tests/Composing/TypeFinderTests.cs
@@ -90,7 +90,7 @@ namespace Umbraco.Tests.Composing
Assert.AreEqual(0, typesFound.Count()); // 0 classes in _assemblies are marked with [Tree]
typesFound = TypeFinder.FindClassesWithAttribute(new[] { typeof (UmbracoContext).Assembly });
- Assert.AreEqual(22, typesFound.Count()); // + classes in Umbraco.Web are marked with [Tree]
+ Assert.AreEqual(21, typesFound.Count()); // + classes in Umbraco.Web are marked with [Tree]
}
private static IProfilingLogger GetTestProfilingLogger()
diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
index ce3d1d705c..e77b9a6e10 100644
--- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
+++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
@@ -429,5 +429,21 @@ javascript: ['~/test.js',/*** some note about stuff asd09823-4**09234*/ '~/test2
Assert.AreEqual(1, db1.Sections.Length);
Assert.AreEqual("forms", db1.Sections[0]);
}
+
+ [Test]
+ public void CanParseManifest_Sections()
+ {
+ const string json = @"{'sections': [
+ { ""alias"": ""content"", ""name"": ""Content"" },
+ { ""alias"": ""hello"", ""name"": ""World"" }
+]}";
+
+ var manifest = _parser.ParseManifest(json);
+ Assert.AreEqual(2, manifest.Sections.Length);
+ Assert.AreEqual("content", manifest.Sections[0].Alias);
+ Assert.AreEqual("hello", manifest.Sections[1].Alias);
+ Assert.AreEqual("Content", manifest.Sections[0].Name);
+ Assert.AreEqual("World", manifest.Sections[1].Name);
+ }
}
}
diff --git a/src/Umbraco.Tests/Packaging/Packages/Document_Type_Picker_1.1.zip b/src/Umbraco.Tests/Packaging/Packages/Document_Type_Picker_1.1.zip
new file mode 100644
index 0000000000..18449bd373
Binary files /dev/null and b/src/Umbraco.Tests/Packaging/Packages/Document_Type_Picker_1.1.zip differ
diff --git a/src/Umbraco.Tests/Services/SectionServiceTests.cs b/src/Umbraco.Tests/Services/SectionServiceTests.cs
index ca5d755220..84eb0d1cbc 100644
--- a/src/Umbraco.Tests/Services/SectionServiceTests.cs
+++ b/src/Umbraco.Tests/Services/SectionServiceTests.cs
@@ -1,8 +1,10 @@
using NUnit.Framework;
using System.Linq;
using System.Threading;
+using Umbraco.Core.Composing;
using Umbraco.Core.Models.Membership;
using Umbraco.Tests.Testing;
+using Umbraco.Web.Services;
namespace Umbraco.Tests.Services
{
@@ -14,15 +16,7 @@ namespace Umbraco.Tests.Services
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, WithApplication = true)]
public class SectionServiceTests : TestWithSomeContentBase
{
- public override void CreateTestData()
- {
- base.CreateTestData();
-
- ServiceContext.SectionService.MakeNew("Content", "content", "icon-content");
- ServiceContext.SectionService.MakeNew("Media", "media", "icon-media");
- ServiceContext.SectionService.MakeNew("Settings", "settings", "icon-settings");
- ServiceContext.SectionService.MakeNew("Developer", "developer", "icon-developer");
- }
+ private ISectionService SectionService => Factory.GetInstance();
[Test]
public void SectionService_Can_Get_Allowed_Sections_For_User()
@@ -31,7 +25,7 @@ namespace Umbraco.Tests.Services
var user = CreateTestUser();
// Act
- var result = ServiceContext.SectionService.GetAllowedSections(user.Id).ToList();
+ var result = SectionService.GetAllowedSections(user.Id).ToList();
// Assert
Assert.AreEqual(3, result.Count);
@@ -63,7 +57,7 @@ namespace Umbraco.Tests.Services
Name = "Group B"
};
userGroupB.AddAllowedSection("settings");
- userGroupB.AddAllowedSection("developer");
+ userGroupB.AddAllowedSection("member");
ServiceContext.UserService.Save(userGroupB, new[] { user.Id }, false);
return ServiceContext.UserService.GetUserById(user.Id);
diff --git a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
index 9e2a2156ee..31ee34843d 100644
--- a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
+++ b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs
@@ -60,8 +60,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
memberTypeService: mockedMemberTypeService,
dataTypeService: mockedDataTypeService,
contentTypeService: mockedContentTypeService,
- localizedTextService:Mock.Of(),
- sectionService:Mock.Of());
+ localizedTextService:Mock.Of());
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
index 563d81da05..c56eae9cd8 100644
--- a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs
@@ -73,8 +73,6 @@ namespace Umbraco.Tests.TestHelpers
MockService(container),
MockService(container),
MockService(container),
- MockService(container),
- MockService(container),
MockService(container),
MockService(container),
MockService(container),
diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects.cs b/src/Umbraco.Tests/TestHelpers/TestObjects.cs
index 14ffeb743f..f7f0d26c0e 100644
--- a/src/Umbraco.Tests/TestHelpers/TestObjects.cs
+++ b/src/Umbraco.Tests/TestHelpers/TestObjects.cs
@@ -188,9 +188,7 @@ namespace Umbraco.Tests.TestHelpers
new DirectoryInfo(IOHelper.GetRootDirectorySafe())));
});
var relationService = GetLazyService(factory, c => new RelationService(scopeProvider, logger, eventMessagesFactory, entityService.Value, GetRepo(c), GetRepo(c)));
- var treeService = GetLazyService(factory, c => new ApplicationTreeService(logger, cache, typeLoader));
- var tagService = GetLazyService(factory, c => new TagService(scopeProvider, logger, eventMessagesFactory, GetRepo(c)));
- var sectionService = GetLazyService(factory, c => new SectionService(userService.Value, treeService.Value, scopeProvider, cache));
+ var tagService = GetLazyService(factory, c => new TagService(scopeProvider, logger, eventMessagesFactory, GetRepo(c)));
var redirectUrlService = GetLazyService(factory, c => new RedirectUrlService(scopeProvider, logger, eventMessagesFactory, GetRepo(c)));
var consentService = GetLazyService(factory, c => new ConsentService(scopeProvider, logger, eventMessagesFactory, GetRepo(c)));
@@ -213,8 +211,6 @@ namespace Umbraco.Tests.TestHelpers
serverRegistrationService,
entityService,
relationService,
- treeService,
- sectionService,
macroService,
memberTypeService,
memberGroupService,
diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
index 304a13f20c..f760903d41 100644
--- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
+++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs
@@ -40,6 +40,7 @@ using Umbraco.Web.Composing.Composers;
using Umbraco.Web.ContentApps;
using Current = Umbraco.Core.Composing.Current;
using Umbraco.Web.Routing;
+using Umbraco.Web.Trees;
namespace Umbraco.Tests.Testing
{
@@ -216,6 +217,16 @@ namespace Umbraco.Tests.Testing
Composition.WithCollectionBuilder();
Composition.RegisterUnique();
Composition.RegisterUnique();
+
+ // register back office sections in the order we want them rendered
+ Composition.WithCollectionBuilder().Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append();
+ Composition.RegisterUnique();
}
protected virtual void ComposeWtf()
@@ -341,7 +352,7 @@ namespace Umbraco.Tests.Testing
Composition.ComposeServices();
// composition root is doing weird things, fix
- Composition.RegisterUnique();
+ Composition.RegisterUnique();
Composition.RegisterUnique();
// somehow property editor ends up wanting this
diff --git a/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs b/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs
deleted file mode 100644
index 951246c535..0000000000
--- a/src/Umbraco.Tests/TreesAndSections/ApplicationTreeTest.cs
+++ /dev/null
@@ -1,397 +0,0 @@
-using System.IO;
-using NUnit.Framework;
-using Umbraco.Core.Services;
-using Umbraco.Tests.TestHelpers;
-using System;
-using System.Linq;
-using System.Threading;
-using Umbraco.Tests.Testing;
-using Umbraco.Web.Services;
-using Current = Umbraco.Web.Composing.Current;
-
-namespace Umbraco.Tests.TreesAndSections
-{
-
-
- ///
- ///This is a test class for ApplicationTreeTest and is intended
- ///to contain all ApplicationTreeTest Unit Tests
- ///
- [TestFixture]
- [Apartment(ApartmentState.STA)]
- [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
- public class ApplicationTreeTest : TestWithDatabaseBase
- {
- public override void SetUp()
- {
- base.SetUp();
-
- var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config");
- var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config");
- Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"));
- using (var writer = File.CreateText(treesConfig))
- {
- writer.Write(ResourceFiles.trees);
- }
- using (var writer = File.CreateText(appConfig))
- {
- writer.Write(ResourceFiles.applications);
- }
-
- ApplicationTreeService.TreeConfigFilePath = treesConfig;
- SectionService.AppConfigFilePath = appConfig;
- }
-
- public override void TearDown()
- {
- base.TearDown();
-
- if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")))
- {
- Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true);
- }
- ApplicationTreeService.TreeConfigFilePath = null;
- SectionService.AppConfigFilePath = null;
- }
-
- ///
- /// Creates a new app tree linked to an application, then delete the application and make sure the tree is gone as well
- ///
- [Test()]
- public void ApplicationTree_Make_New_Then_Delete_App()
- {
- //create new app
- var appName = Guid.NewGuid().ToString("N");
- var treeName = Guid.NewGuid().ToString("N");
- Current.Services.SectionService.MakeNew(appName, appName, "icon.jpg");
-
- //check if it exists
- var app = Current.Services.SectionService.GetByAlias(appName);
- Assert.IsNotNull(app);
-
- //create the new app tree assigned to the new app
- Current.Services.ApplicationTreeService.MakeNew(false, 0, app.Alias, treeName, treeName, "icon.jpg", "icon.jpg", "Umbraco.Web.Trees.ContentTreeController, Umbraco.Web");
- var tree = Current.Services.ApplicationTreeService.GetByAlias(treeName);
- Assert.IsNotNull(tree);
-
- //now delete the app
- Current.Services.SectionService.DeleteSection(app);
-
- //check that the tree is gone
- Assert.AreEqual(0, Current.Services.ApplicationTreeService.GetApplicationTrees(treeName).Count());
- }
-
-
- #region Tests to write
- /////
- /////A test for ApplicationTree Constructor
- /////
- //[TestMethod()]
- //public void ApplicationTreeConstructorTest()
- //{
- // bool silent = false; // TODO: Initialize to an appropriate value
- // bool initialize = false; // TODO: Initialize to an appropriate value
- // byte sortOrder = 0; // TODO: Initialize to an appropriate value
- // string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value
- // string alias = string.Empty; // TODO: Initialize to an appropriate value
- // string title = string.Empty; // TODO: Initialize to an appropriate value
- // string iconClosed = string.Empty; // TODO: Initialize to an appropriate value
- // string iconOpened = string.Empty; // TODO: Initialize to an appropriate value
- // string assemblyName = string.Empty; // TODO: Initialize to an appropriate value
- // string type = string.Empty; // TODO: Initialize to an appropriate value
- // string action = string.Empty; // TODO: Initialize to an appropriate value
- // ApplicationTree target = new ApplicationTree(silent, initialize, sortOrder, applicationAlias, alias, title, iconClosed, iconOpened, assemblyName, type, action);
- // Assert.Inconclusive("TODO: Implement code to verify target");
- //}
-
- /////
- /////A test for ApplicationTree Constructor
- /////
- //[TestMethod()]
- //public void ApplicationTreeConstructorTest1()
- //{
- // ApplicationTree target = new ApplicationTree();
- // Assert.Inconclusive("TODO: Implement code to verify target");
- //}
-
- /////
- /////A test for Delete
- /////
- //[TestMethod()]
- //public void DeleteTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // target.Delete();
- // Assert.Inconclusive("A method that does not return a value cannot be verified.");
- //}
-
-
- /////
- /////A test for Save
- /////
- //[TestMethod()]
- //public void SaveTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // target.Save();
- // Assert.Inconclusive("A method that does not return a value cannot be verified.");
- //}
-
- /////
- /////A test for getAll
- /////
- //[TestMethod()]
- //public void getAllTest()
- //{
- // ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value
- // ApplicationTree[] actual;
- // actual = ApplicationTree.getAll();
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for getApplicationTree
- /////
- //[TestMethod()]
- //public void getApplicationTreeTest()
- //{
- // string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value
- // ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value
- // ApplicationTree[] actual;
- // actual = ApplicationTree.getApplicationTree(applicationAlias);
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for getApplicationTree
- /////
- //[TestMethod()]
- //public void getApplicationTreeTest1()
- //{
- // string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value
- // bool onlyInitializedApplications = false; // TODO: Initialize to an appropriate value
- // ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value
- // ApplicationTree[] actual;
- // actual = ApplicationTree.getApplicationTree(applicationAlias, onlyInitializedApplications);
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for getByAlias
- /////
- //[TestMethod()]
- //public void getByAliasTest()
- //{
- // string treeAlias = string.Empty; // TODO: Initialize to an appropriate value
- // ApplicationTree expected = null; // TODO: Initialize to an appropriate value
- // ApplicationTree actual;
- // actual = ApplicationTree.getByAlias(treeAlias);
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for Action
- /////
- //[TestMethod()]
- //public void ActionTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.Action = expected;
- // actual = target.Action;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for Alias
- /////
- //[TestMethod()]
- //public void AliasTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string actual;
- // actual = target.Alias;
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for ApplicationAlias
- /////
- //[TestMethod()]
- //public void ApplicationAliasTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string actual;
- // actual = target.ApplicationAlias;
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for AssemblyName
- /////
- //[TestMethod()]
- //public void AssemblyNameTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.AssemblyName = expected;
- // actual = target.AssemblyName;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for IconClosed
- /////
- //[TestMethod()]
- //public void IconClosedTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.IconClosed = expected;
- // actual = target.IconClosed;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for IconOpened
- /////
- //[TestMethod()]
- //public void IconOpenedTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.IconOpened = expected;
- // actual = target.IconOpened;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for Initialize
- /////
- //[TestMethod()]
- //public void InitializeTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // bool expected = false; // TODO: Initialize to an appropriate value
- // bool actual;
- // target.Initialize = expected;
- // actual = target.Initialize;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for Silent
- /////
- //[TestMethod()]
- //public void SilentTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // bool expected = false; // TODO: Initialize to an appropriate value
- // bool actual;
- // target.Silent = expected;
- // actual = target.Silent;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for SortOrder
- /////
- //[TestMethod()]
- //public void SortOrderTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // byte expected = 0; // TODO: Initialize to an appropriate value
- // byte actual;
- // target.SortOrder = expected;
- // actual = target.SortOrder;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for SqlHelper
- /////
- //[TestMethod()]
- //public void SqlHelperTest()
- //{
- // ISqlHelper actual;
- // actual = ApplicationTree.SqlHelper;
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for Title
- /////
- //[TestMethod()]
- //public void TitleTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.Title = expected;
- // actual = target.Title;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for Type
- /////
- //[TestMethod()]
- //public void TypeTest()
- //{
- // ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.Type = expected;
- // actual = target.Type;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
- #endregion
-
- #region Additional test attributes
- //
- //You can use the following additional attributes as you write your tests:
- //
- //Use ClassInitialize to run code before running the first test in the class
- //[ClassInitialize()]
- //public static void MyClassInitialize(TestContext testContext)
- //{
- //}
- //
- //Use ClassCleanup to run code after all tests in a class have run
- //[ClassCleanup()]
- //public static void MyClassCleanup()
- //{
- //}
- //
- //Use TestInitialize to run code before running each test
- //[TestInitialize()]
- //public void MyTestInitialize()
- //{
- //}
- //
- //Use TestCleanup to run code after each test has run
- //[TestCleanup()]
- //public void MyTestCleanup()
- //{
- //}
- //
- #endregion
- }
-}
diff --git a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs b/src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs
deleted file mode 100644
index 02bc84649e..0000000000
--- a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.Designer.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Umbraco.Tests.TreesAndSections {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class ResourceFiles {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal ResourceFiles() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Tests.TreesAndSections.ResourceFiles", typeof(ResourceFiles).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
- ///<applications>
- /// <add alias="content" name="content" icon="file" sortOrder="0" />
- /// <add alias="0b486ac9c0f1456996192c6ed1f03e57" name="0b486ac9c0f1456996192c6ed1f03e57" icon="icon.jpg" sortOrder="1" />
- /// <add alias="1ffbc301744c4e75ae3054d741954c7b" name="1ffbc301744c4e75ae3054d741954c7b" icon="icon.jpg" sortOrder="2" />
- /// <add alias="1838c3e1591f4008bbafe59a06a00a31" name="1838c3e1591f4008bbafe59a06a00a31" icon="icon.jpg" sortOrder="3" />
- /// <add alias="e5badae2 [rest of string was truncated]";.
- ///
- internal static string applications {
- get {
- return ResourceManager.GetString("applications", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
- ///<trees>
- /// <add initialize="false" sortOrder="0" alias="1838c3e1591f4008bbafe59a06a00a31" application="1838c3e1591f4008bbafe59a06a00a31" title="1838c3e1591f4008bbafe59a06a00a31" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" />
- /// <add initialize="false" sortOrder="0" alias="e5badae2fc5e4cd7acb3700320e33b8b" application="e5badae2fc5e4cd7acb3700320e33b8b" title="e5badae2fc5e4cd7acb3700320e33b8b" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" />
- /// [rest of string was truncated]";.
- ///
- internal static string trees {
- get {
- return ResourceManager.GetString("trees", resourceCulture);
- }
- }
- }
-}
diff --git a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx b/src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx
deleted file mode 100644
index fac58dc842..0000000000
--- a/src/Umbraco.Tests/TreesAndSections/ResourceFiles.resx
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- applications.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
-
-
- trees.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
-
-
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TreesAndSections/SectionTests.cs b/src/Umbraco.Tests/TreesAndSections/SectionTests.cs
deleted file mode 100644
index 1f4a01fd3d..0000000000
--- a/src/Umbraco.Tests/TreesAndSections/SectionTests.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-using System.IO;
-using NUnit.Framework;
-using Umbraco.Core.Services;
-using Umbraco.Tests.TestHelpers;
-using System;
-using Umbraco.Core.Composing;
-using Umbraco.Tests.Testing;
-using Umbraco.Web.Services;
-
-namespace Umbraco.Tests.TreesAndSections
-{
- ///
- ///This is a test class for ApplicationTest and is intended
- ///to contain all ApplicationTest Unit Tests
- ///
- [TestFixture]
- [UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
- public class SectionTests : TestWithDatabaseBase
- {
- protected override void Compose()
- {
- base.Compose();
- Composition.RegisterUnique();
- }
-
- public override void SetUp()
- {
- base.SetUp();
-
- var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config");
- var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config");
- Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"));
- using (var writer = File.CreateText(treesConfig))
- {
- writer.Write(ResourceFiles.trees);
- }
- using (var writer = File.CreateText(appConfig))
- {
- writer.Write(ResourceFiles.applications);
- }
-
- ApplicationTreeService.TreeConfigFilePath = treesConfig;
- SectionService.AppConfigFilePath = appConfig;
- }
-
- public override void TearDown()
- {
- base.TearDown();
-
- if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")))
- {
- Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true);
- }
- ApplicationTreeService.TreeConfigFilePath = null;
- SectionService.AppConfigFilePath = null;
- }
-
- ///
- /// Create a new application and delete it
- ///
- [Test()]
- public void Application_Make_New()
- {
- var name = Guid.NewGuid().ToString("N");
- ServiceContext.SectionService.MakeNew(name, name, "icon.jpg");
-
- //check if it exists
- var app = ServiceContext.SectionService.GetByAlias(name);
- Assert.IsNotNull(app);
-
- //now remove it
- ServiceContext.SectionService.DeleteSection(app);
- Assert.IsNull(ServiceContext.SectionService.GetByAlias(name));
- }
-
- #region Tests to write
-
-
- /////
- /////A test for Application Constructor
- /////
- //[TestMethod()]
- //public void ApplicationConstructorTest()
- //{
- // string name = string.Empty; // TODO: Initialize to an appropriate value
- // string alias = string.Empty; // TODO: Initialize to an appropriate value
- // string icon = string.Empty; // TODO: Initialize to an appropriate value
- // Application target = new Application(name, alias, icon);
- // Assert.Inconclusive("TODO: Implement code to verify target");
- //}
-
- /////
- /////A test for Application Constructor
- /////
- //[TestMethod()]
- //public void ApplicationConstructorTest1()
- //{
- // Application target = new Application();
- // Assert.Inconclusive("TODO: Implement code to verify target");
- //}
-
- /////
- /////A test for Delete
- /////
- //[TestMethod()]
- //public void DeleteTest()
- //{
- // Application target = new Application(); // TODO: Initialize to an appropriate value
- // target.Delete();
- // Assert.Inconclusive("A method that does not return a value cannot be verified.");
- //}
-
-
-
- /////
- /////A test for MakeNew
- /////
- //[TestMethod()]
- //public void MakeNewTest1()
- //{
- // string name = string.Empty; // TODO: Initialize to an appropriate value
- // string alias = string.Empty; // TODO: Initialize to an appropriate value
- // string icon = string.Empty; // TODO: Initialize to an appropriate value
- // Application.MakeNew(name, alias, icon);
- // Assert.Inconclusive("A method that does not return a value cannot be verified.");
- //}
-
- /////
- /////A test for RegisterIApplications
- /////
- //[TestMethod()]
- //public void RegisterIApplicationsTest()
- //{
- // Application.RegisterIApplications();
- // Assert.Inconclusive("A method that does not return a value cannot be verified.");
- //}
-
- /////
- /////A test for getAll
- /////
- //[TestMethod()]
- //public void getAllTest()
- //{
- // List expected = null; // TODO: Initialize to an appropriate value
- // List actual;
- // actual = Application.getAll();
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for getByAlias
- /////
- //[TestMethod()]
- //public void getByAliasTest()
- //{
- // string appAlias = string.Empty; // TODO: Initialize to an appropriate value
- // Application expected = null; // TODO: Initialize to an appropriate value
- // Application actual;
- // actual = Application.getByAlias(appAlias);
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for SqlHelper
- /////
- //[TestMethod()]
- //public void SqlHelperTest()
- //{
- // ISqlHelper actual;
- // actual = Application.SqlHelper;
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for alias
- /////
- //[TestMethod()]
- //public void aliasTest()
- //{
- // Application target = new Application(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.alias = expected;
- // actual = target.alias;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for icon
- /////
- //[TestMethod()]
- //public void iconTest()
- //{
- // Application target = new Application(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.icon = expected;
- // actual = target.icon;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
-
- /////
- /////A test for name
- /////
- //[TestMethod()]
- //public void nameTest()
- //{
- // Application target = new Application(); // TODO: Initialize to an appropriate value
- // string expected = string.Empty; // TODO: Initialize to an appropriate value
- // string actual;
- // target.name = expected;
- // actual = target.name;
- // Assert.AreEqual(expected, actual);
- // Assert.Inconclusive("Verify the correctness of this test method.");
- //}
- #endregion
-
- #region Additional test attributes
- //
- //You can use the following additional attributes as you write your tests:
- //
- //Use ClassInitialize to run code before running the first test in the class
- //[ClassInitialize()]
- //public static void MyClassInitialize(TestContext testContext)
- //{
- //}
- //
- //Use ClassCleanup to run code after all tests in a class have run
- //[ClassCleanup()]
- //public static void MyClassCleanup()
- //{
- //}
- //
- //Use TestInitialize to run code before running each test
- //[TestInitialize()]
- //public void MyTestInitialize()
- //{
- //}
- //
- //Use TestCleanup to run code after each test has run
- //[TestCleanup()]
- //public void MyTestCleanup()
- //{
- //}
- //
- #endregion
- }
-}
diff --git a/src/Umbraco.Tests/TreesAndSections/applications.config b/src/Umbraco.Tests/TreesAndSections/applications.config
deleted file mode 100644
index aadd1c5407..0000000000
--- a/src/Umbraco.Tests/TreesAndSections/applications.config
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Umbraco.Tests/TreesAndSections/trees.config b/src/Umbraco.Tests/TreesAndSections/trees.config
deleted file mode 100644
index d21fea28a9..0000000000
--- a/src/Umbraco.Tests/TreesAndSections/trees.config
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index c22b765169..de1fc18249 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -420,13 +420,6 @@
-
- True
- True
- ResourceFiles.resx
-
-
-
@@ -521,8 +514,6 @@
Designer
Always
-
-
Designer
@@ -557,10 +548,6 @@
ImportResources.Designer.cs
Designer
-
- ResXFileCodeGenerator
- ResourceFiles.Designer.cs
-
ResXFileCodeGenerator
TestFiles.Designer.cs
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index c21bf7fef6..778ab188cd 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -241,9 +241,6 @@
umbracoSettings.config
Designer
-
- trees.config
-
tinyMceConfig.config
Designer
@@ -301,14 +298,6 @@
-
-
- Designer
-
-
- applications.config
- Designer
-
diff --git a/src/Umbraco.Web.UI/config/applications.Release.config b/src/Umbraco.Web.UI/config/applications.Release.config
deleted file mode 100644
index 5c8dee3b8a..0000000000
--- a/src/Umbraco.Web.UI/config/applications.Release.config
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Umbraco.Web.UI/config/applications.config b/src/Umbraco.Web.UI/config/applications.config
deleted file mode 100644
index 5c8dee3b8a..0000000000
--- a/src/Umbraco.Web.UI/config/applications.config
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Umbraco.Web.UI/config/trees.Release.config b/src/Umbraco.Web.UI/config/trees.Release.config
deleted file mode 100644
index bd75e97c38..0000000000
--- a/src/Umbraco.Web.UI/config/trees.Release.config
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Umbraco.Web.UI/config/trees.config b/src/Umbraco.Web.UI/config/trees.config
deleted file mode 100644
index 5892545682..0000000000
--- a/src/Umbraco.Web.UI/config/trees.config
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs b/src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs
deleted file mode 100644
index 247c33c361..0000000000
--- a/src/Umbraco.Web/Cache/ApplicationTreeCacheRefresher.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using System;
-using Umbraco.Core.Cache;
-
-namespace Umbraco.Web.Cache
-{
- public sealed class ApplicationTreeCacheRefresher : CacheRefresherBase
- {
- public ApplicationTreeCacheRefresher(CacheHelper cacheHelper)
- : base(cacheHelper)
- { }
-
- #region Define
-
- protected override ApplicationTreeCacheRefresher This => this;
-
- public static readonly Guid UniqueId = Guid.Parse("0AC6C028-9860-4EA4-958D-14D39F45886E");
-
- public override Guid RefresherUniqueId => UniqueId;
-
- public override string Name => "Application Tree Cache Refresher";
-
- #endregion
-
- #region Refresher
-
- public override void RefreshAll()
- {
- CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
- base.RefreshAll();
- }
-
- public override void Refresh(int id)
- {
- Remove(id);
- base.Refresh(id);
- }
-
- public override void Remove(int id)
- {
- CacheHelper.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
- base.Remove(id);
- }
-
- #endregion
- }
-}
diff --git a/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs b/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs
index d522e54de6..3a3eb1b8fb 100644
--- a/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs
+++ b/src/Umbraco.Web/Cache/DistributedCacheBinder_Handlers.cs
@@ -46,20 +46,6 @@ namespace Umbraco.Web.Cache
_logger.Info("Initializing Umbraco internal event handlers for cache refreshing.");
- // bind to application tree events
- Bind(() => ApplicationTreeService.Deleted += ApplicationTreeService_Deleted,
- () => ApplicationTreeService.Deleted -= ApplicationTreeService_Deleted);
- Bind(() => ApplicationTreeService.Updated += ApplicationTreeService_Updated,
- () => ApplicationTreeService.Updated -= ApplicationTreeService_Updated);
- Bind(() => ApplicationTreeService.New += ApplicationTreeService_New,
- () => ApplicationTreeService.New -= ApplicationTreeService_New);
-
- // bind to application events
- Bind(() => SectionService.Deleted += SectionService_Deleted,
- () => SectionService.Deleted -= SectionService_Deleted);
- Bind(() => SectionService.New += SectionService_New,
- () => SectionService.New -= SectionService_New);
-
// bind to user and user group events
Bind(() => UserService.SavedUserGroup += UserService_SavedUserGroup,
() => UserService.SavedUserGroup -= UserService_SavedUserGroup);
@@ -231,39 +217,6 @@ namespace Umbraco.Web.Cache
#endregion
- #region ApplicationTreeService
-
- private void ApplicationTreeService_New(ApplicationTree sender, EventArgs e)
- {
- _distributedCache.RefreshAllApplicationTreeCache();
- }
-
- private void ApplicationTreeService_Updated(ApplicationTree sender, EventArgs e)
- {
- _distributedCache.RefreshAllApplicationTreeCache();
- }
-
- private void ApplicationTreeService_Deleted(ApplicationTree sender, EventArgs e)
- {
- _distributedCache.RefreshAllApplicationTreeCache();
- }
-
- #endregion
-
- #region Application event handlers
-
- private void SectionService_New(ISectionService sender, EventArgs e)
- {
- _distributedCache.RefreshAllApplicationCache();
- }
-
- private void SectionService_Deleted(ISectionService sender, EventArgs e)
- {
- _distributedCache.RefreshAllApplicationCache();
- }
-
- #endregion
-
#region LocalizationService / Dictionary
private void LocalizationService_SavedDictionaryItem(ILocalizationService sender, SaveEventArgs e)
diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
index 68ac339a46..80c49e279c 100644
--- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
+++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs
@@ -18,24 +18,6 @@ namespace Umbraco.Web.Cache
#endregion
- #region ApplicationTreeCache
-
- public static void RefreshAllApplicationTreeCache(this DistributedCache dc)
- {
- dc.RefreshAll(ApplicationTreeCacheRefresher.UniqueId);
- }
-
- #endregion
-
- #region ApplicationCache
-
- public static void RefreshAllApplicationCache(this DistributedCache dc)
- {
- dc.RefreshAll(ApplicationCacheRefresher.UniqueId);
- }
-
- #endregion
-
#region User cache
public static void RemoveUserCache(this DistributedCache dc, int userId)
@@ -74,7 +56,6 @@ namespace Umbraco.Web.Cache
#endregion
-
#region TemplateCache
public static void RefreshTemplateCache(this DistributedCache dc, int templateId)
diff --git a/src/Umbraco.Web/Composing/Current.cs b/src/Umbraco.Web/Composing/Current.cs
index 1e8f3d17f7..d887720063 100644
--- a/src/Umbraco.Web/Composing/Current.cs
+++ b/src/Umbraco.Web/Composing/Current.cs
@@ -25,6 +25,7 @@ using Umbraco.Web.HealthCheck;
using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
+using Umbraco.Web.Services;
using Umbraco.Web.WebApi;
using CoreCurrent = Umbraco.Core.Composing.Current;
@@ -135,6 +136,12 @@ namespace Umbraco.Web.Composing
internal static IPublishedSnapshotService PublishedSnapshotService
=> Factory.GetInstance();
+ public static ITreeService TreeService
+ => Factory.GetInstance();
+
+ public static ISectionService SectionService
+ => Factory.GetInstance();
+
#endregion
#region Web Constants
diff --git a/src/Umbraco.Web/TagsController.cs b/src/Umbraco.Web/Controllers/TagsController.cs
similarity index 89%
rename from src/Umbraco.Web/TagsController.cs
rename to src/Umbraco.Web/Controllers/TagsController.cs
index 181b9f7da2..cb6a28be47 100644
--- a/src/Umbraco.Web/TagsController.cs
+++ b/src/Umbraco.Web/Controllers/TagsController.cs
@@ -8,7 +8,7 @@ using Umbraco.Core.Services;
using Umbraco.Web.Models;
using Umbraco.Web.WebApi;
-namespace Umbraco.Web.WebServices
+namespace Umbraco.Web.Controllers
{
///
/// A public web service for querying tags
@@ -29,8 +29,8 @@ namespace Umbraco.Web.WebServices
///
/// Initializes a new instance of the with all its dependencies.
///
- public TagsController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
- : base(globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ public TagsController(IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{ }
///
diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs
index 231ec9ba67..7ffc6e1207 100644
--- a/src/Umbraco.Web/Editors/AuthenticationController.cs
+++ b/src/Umbraco.Web/Editors/AuthenticationController.cs
@@ -52,8 +52,8 @@ namespace Umbraco.Web.Editors
///
/// Initializes a new instance of the class with all its dependencies.
///
- public AuthenticationController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
- : base(globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ public AuthenticationController(IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{ }
protected BackOfficeUserManager UserManager => _userManager
diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
index ee973a4b58..1525dd5808 100644
--- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs
@@ -14,13 +14,13 @@ using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
+using Umbraco.Web.Controllers;
using Umbraco.Web.Features;
using Umbraco.Web.HealthCheck;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Mvc;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web.Trees;
-using Umbraco.Web.WebServices;
using Constants = Umbraco.Core.Constants;
namespace Umbraco.Web.Editors
@@ -158,7 +158,7 @@ namespace Umbraco.Web.Editors
},
{
"treeApplicationApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetApplicationTrees(null, null, null, true))
+ controller => controller.GetApplicationTrees(null, null, null))
},
{
"contentTypeApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl(
@@ -408,7 +408,7 @@ namespace Umbraco.Web.Editors
let pluginAttr = p.attributes.OfType().Single()
select new Dictionary
{
- {"alias", treeAttr.Alias}, {"packageFolder", pluginAttr.AreaName}
+ {"alias", treeAttr.TreeAlias}, {"packageFolder", pluginAttr.AreaName}
}).ToArray();
}
diff --git a/src/Umbraco.Web/Editors/ContentTypeController.cs b/src/Umbraco.Web/Editors/ContentTypeController.cs
index 670d37e7a7..00a0cb90bc 100644
--- a/src/Umbraco.Web/Editors/ContentTypeController.cs
+++ b/src/Umbraco.Web/Editors/ContentTypeController.cs
@@ -54,11 +54,11 @@ namespace Umbraco.Web.Editors
public ContentTypeController(IEntityXmlSerializer serializer,
ICultureDictionaryFactory cultureDictionaryFactory,
IGlobalSettings globalSettings,
- IUmbracoContextAccessor umbracoContextAccessor,
+ UmbracoContext umbracoContext,
ISqlContext sqlContext, PropertyEditorCollection propertyEditors,
ServiceContext services, CacheHelper applicationCache,
IProfilingLogger logger, IRuntimeState runtimeState)
- : base(cultureDictionaryFactory, globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ : base(cultureDictionaryFactory, globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
_serializer = serializer;
_propertyEditors = propertyEditors;
diff --git a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs
index 898208319a..a11fcaa869 100644
--- a/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs
+++ b/src/Umbraco.Web/Editors/ContentTypeControllerBase.cs
@@ -33,7 +33,8 @@ namespace Umbraco.Web.Editors
private readonly ICultureDictionaryFactory _cultureDictionaryFactory;
private ICultureDictionary _cultureDictionary;
- protected ContentTypeControllerBase(ICultureDictionaryFactory cultureDictionaryFactory, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState) : base(globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ protected ContentTypeControllerBase(ICultureDictionaryFactory cultureDictionaryFactory, IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
_cultureDictionaryFactory = cultureDictionaryFactory;
}
diff --git a/src/Umbraco.Web/Editors/DashboardController.cs b/src/Umbraco.Web/Editors/DashboardController.cs
index 8960f110c3..0340926ce4 100644
--- a/src/Umbraco.Web/Editors/DashboardController.cs
+++ b/src/Umbraco.Web/Editors/DashboardController.cs
@@ -38,8 +38,8 @@ namespace Umbraco.Web.Editors
///
/// Initializes a new instance of the with all its dependencies.
///
- public DashboardController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState, Dashboards dashboards)
- : base(globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ public DashboardController(IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState, Dashboards dashboards)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
_dashboards = dashboards;
}
diff --git a/src/Umbraco.Web/Editors/DashboardSecurity.cs b/src/Umbraco.Web/Editors/DashboardSecurity.cs
index 1481606c7e..fdbf5af7d9 100644
--- a/src/Umbraco.Web/Editors/DashboardSecurity.cs
+++ b/src/Umbraco.Web/Editors/DashboardSecurity.cs
@@ -6,6 +6,7 @@ using Umbraco.Core;
using Umbraco.Core.Configuration.Dashboard;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
+using Umbraco.Web.Services;
namespace Umbraco.Web.Editors
{
diff --git a/src/Umbraco.Web/Editors/Dashboards.cs b/src/Umbraco.Web/Editors/Dashboards.cs
index 4bf2d81045..c837cbbf33 100644
--- a/src/Umbraco.Web/Editors/Dashboards.cs
+++ b/src/Umbraco.Web/Editors/Dashboards.cs
@@ -8,6 +8,7 @@ using Umbraco.Core.Manifest;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
+using Umbraco.Web.Services;
namespace Umbraco.Web.Editors
{
diff --git a/src/Umbraco.Web/Editors/EntityController.cs b/src/Umbraco.Web/Editors/EntityController.cs
index 993489855f..e376f9ad5b 100644
--- a/src/Umbraco.Web/Editors/EntityController.cs
+++ b/src/Umbraco.Web/Editors/EntityController.cs
@@ -16,11 +16,16 @@ using Constants = Umbraco.Core.Constants;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using System.Web.Http.Controllers;
using Examine;
+using Umbraco.Core.Cache;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
using Umbraco.Core.Models.Entities;
+using Umbraco.Core.Persistence;
using Umbraco.Core.Services;
using Umbraco.Core.Xml;
using Umbraco.Web.Models.Mapping;
using Umbraco.Web.Search;
+using Umbraco.Web.Services;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
@@ -37,6 +42,15 @@ namespace Umbraco.Web.Editors
[PluginController("UmbracoApi")]
public class EntityController : UmbracoAuthorizedJsonController
{
+ private readonly ITreeService _treeService;
+
+ public EntityController(IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState,
+ ITreeService treeService)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
+ {
+ _treeService = treeService;
+ }
+
///
/// Configures this controller with a custom action selector
///
@@ -129,12 +143,12 @@ namespace Umbraco.Web.Editors
{
if (allowedSections.Contains(searchableTree.Value.AppAlias))
{
- var tree = Services.ApplicationTreeService.GetByAlias(searchableTree.Key);
+ var tree = _treeService.GetByAlias(searchableTree.Key);
if (tree == null) continue; //shouldn't occur
var searchableTreeAttribute = searchableTree.Value.SearchableTree.GetType().GetCustomAttribute(false);
- result[tree.GetRootNodeDisplayName(Services.TextService)] = new TreeSearchResult
+ result[Tree.GetRootNodeDisplayName(tree, Services.TextService)] = new TreeSearchResult
{
Results = searchableTree.Value.SearchableTree.Search(query, 200, 0, out var total),
TreeAlias = searchableTree.Key,
diff --git a/src/Umbraco.Web/Editors/MediaTypeController.cs b/src/Umbraco.Web/Editors/MediaTypeController.cs
index f2b8fd3dda..e2fbe8c428 100644
--- a/src/Umbraco.Web/Editors/MediaTypeController.cs
+++ b/src/Umbraco.Web/Editors/MediaTypeController.cs
@@ -37,7 +37,8 @@ namespace Umbraco.Web.Editors
[MediaTypeControllerControllerConfiguration]
public class MediaTypeController : ContentTypeControllerBase
{
- public MediaTypeController(ICultureDictionaryFactory cultureDictionaryFactory, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState) : base(cultureDictionaryFactory, globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ public MediaTypeController(ICultureDictionaryFactory cultureDictionaryFactory, IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
+ : base(cultureDictionaryFactory, globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
}
diff --git a/src/Umbraco.Web/Editors/MemberTypeController.cs b/src/Umbraco.Web/Editors/MemberTypeController.cs
index 3abc0035d3..c59bf6d332 100644
--- a/src/Umbraco.Web/Editors/MemberTypeController.cs
+++ b/src/Umbraco.Web/Editors/MemberTypeController.cs
@@ -30,7 +30,8 @@ namespace Umbraco.Web.Editors
[UmbracoTreeAuthorize(new string[] { Constants.Trees.MemberTypes, Constants.Trees.Members})]
public class MemberTypeController : ContentTypeControllerBase
{
- public MemberTypeController(ICultureDictionaryFactory cultureDictionaryFactory, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState) : base(cultureDictionaryFactory, globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ public MemberTypeController(ICultureDictionaryFactory cultureDictionaryFactory, IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState)
+ : base(cultureDictionaryFactory, globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
}
diff --git a/src/Umbraco.Web/Editors/PackageInstallController.cs b/src/Umbraco.Web/Editors/PackageInstallController.cs
index 05d1e2a7a3..ec81b794a1 100644
--- a/src/Umbraco.Web/Editors/PackageInstallController.cs
+++ b/src/Umbraco.Web/Editors/PackageInstallController.cs
@@ -44,10 +44,10 @@ namespace Umbraco.Web.Editors
[UmbracoApplicationAuthorize(Core.Constants.Applications.Packages)]
public class PackageInstallController : UmbracoAuthorizedJsonController
{
- public PackageInstallController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor,
+ public PackageInstallController(IGlobalSettings globalSettings, UmbracoContext umbracoContext,
ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache,
IProfilingLogger logger, IRuntimeState runtimeState)
- : base(globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
}
diff --git a/src/Umbraco.Web/Editors/SectionController.cs b/src/Umbraco.Web/Editors/SectionController.cs
index f650c18fb3..d68f062f61 100644
--- a/src/Umbraco.Web/Editors/SectionController.cs
+++ b/src/Umbraco.Web/Editors/SectionController.cs
@@ -2,10 +2,17 @@
using AutoMapper;
using Umbraco.Web.Mvc;
using System.Linq;
+using Umbraco.Core;
+using Umbraco.Core.Cache;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
using Umbraco.Core.Models;
+using Umbraco.Core.Persistence;
+using Umbraco.Core.Services;
using Umbraco.Web.Trees;
using Section = Umbraco.Web.Models.ContentEditing.Section;
using Umbraco.Web.Models.Trees;
+using Umbraco.Web.Services;
namespace Umbraco.Web.Editors
{
@@ -16,21 +23,30 @@ namespace Umbraco.Web.Editors
public class SectionController : UmbracoAuthorizedJsonController
{
private readonly Dashboards _dashboards;
+ private readonly ISectionService _sectionService;
+ private readonly ITreeService _treeService;
- public SectionController(Dashboards dashboards)
+ public SectionController(IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState,
+ Dashboards dashboards, ISectionService sectionService, ITreeService treeService)
+ : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
_dashboards = dashboards;
+ _sectionService = sectionService;
+ _treeService = treeService;
}
public IEnumerable GetSections()
{
- var sections = Services.SectionService.GetAllowedSections(Security.GetUserId().ResultOr(0));
+ var sections = _sectionService.GetAllowedSections(Security.GetUserId().ResultOr(0));
- var sectionModels = sections.Select(Mapper.Map).ToArray();
+ var sectionModels = sections.Select(Mapper.Map).ToArray();
// this is a bit nasty since we'll be proxying via the app tree controller but we sort of have to do that
// since tree's by nature are controllers and require request contextual data
- var appTreeController = new ApplicationTreeController { ControllerContext = ControllerContext };
+ var appTreeController = new ApplicationTreeController(GlobalSettings, UmbracoContext, SqlContext, Services, ApplicationCache, Logger, RuntimeState, _treeService)
+ {
+ ControllerContext = ControllerContext
+ };
var dashboards = _dashboards.GetDashboards(Security.CurrentUser);
@@ -76,8 +92,8 @@ namespace Umbraco.Web.Editors
///
public IEnumerable GetAllSections()
{
- var sections = Services.SectionService.GetSections();
- var mapped = sections.Select(Mapper.Map);
+ var sections = _sectionService.GetSections();
+ var mapped = sections.Select(Mapper.Map);
if (Security.CurrentUser.IsAdmin())
return mapped;
diff --git a/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs b/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs
index 3baa5e85ff..4e430b833c 100644
--- a/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs
+++ b/src/Umbraco.Web/Editors/UmbracoAuthorizedJsonController.cs
@@ -31,13 +31,13 @@ namespace Umbraco.Web.Editors
/// Initializes a new instance of the class with all its dependencies.
///
///
- ///
+ ///
///
///
///
///
///
- protected UmbracoAuthorizedJsonController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState) : base(globalSettings, umbracoContextAccessor, sqlContext, services, applicationCache, logger, runtimeState)
+ protected UmbracoAuthorizedJsonController(IGlobalSettings globalSettings, UmbracoContext umbracoContext, ISqlContext sqlContext, ServiceContext services, CacheHelper applicationCache, IProfilingLogger logger, IRuntimeState runtimeState) : base(globalSettings, umbracoContext, sqlContext, services, applicationCache, logger, runtimeState)
{
}
}
diff --git a/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs
index ba7ff3c38d..7e727a3752 100644
--- a/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs
+++ b/src/Umbraco.Web/Models/Mapping/SectionMapperProfile.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using AutoMapper;
+using Umbraco.Core.Models.Trees;
using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
@@ -9,7 +10,7 @@ namespace Umbraco.Web.Models.Mapping
{
public SectionMapperProfile(ILocalizedTextService textService)
{
- CreateMap()
+ CreateMap()
.ForMember(dest => dest.RoutePath, opt => opt.Ignore())
.ForMember(dest => dest.Icon, opt => opt.Ignore())
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => textService.Localize("sections/" + src.Alias, (IDictionary)null)))
diff --git a/src/Umbraco.Web/Models/Mapping/UserMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/UserMapperProfile.cs
index 8261dda0d4..c975f3a106 100644
--- a/src/Umbraco.Web/Models/Mapping/UserMapperProfile.cs
+++ b/src/Umbraco.Web/Models/Mapping/UserMapperProfile.cs
@@ -12,6 +12,7 @@ using Umbraco.Core.Models.Entities;
using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web.Actions;
+using Umbraco.Web.Services;
namespace Umbraco.Web.Models.Mapping
diff --git a/src/Umbraco.Web/Models/Trees/ApplicationAttribute.cs b/src/Umbraco.Web/Models/Trees/ApplicationAttribute.cs
deleted file mode 100644
index 65fc4ed6f3..0000000000
--- a/src/Umbraco.Web/Models/Trees/ApplicationAttribute.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-
-namespace Umbraco.Web.Models.Trees
-{
- ///
- /// Identifies an application tree
- ///
- [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
- public class ApplicationAttribute : Attribute
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The alias.
- /// The name.
- /// The sort order.
- public ApplicationAttribute(string alias,
- string name,
- int sortOrder = 0)
- {
- Alias = alias;
- Name = name;
- SortOrder = sortOrder;
- }
-
- public string Alias { get; private set; }
- public string Name { get; private set; }
- public int SortOrder { get; private set; }
- }
-}
diff --git a/src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs b/src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs
deleted file mode 100644
index aa8e0cfda6..0000000000
--- a/src/Umbraco.Web/Models/Trees/ApplicationDefinitions.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Umbraco.Core;
-using Umbraco.Core.Models;
-
-namespace Umbraco.Web.Models.Trees
-{
- // The application definitions are intended as a means to auto populate
- // the application.config. On app startup, Umbraco will look for any
- // unregistered classes with an ApplicationAttribute and add them to the cache
-
- [Application(Constants.Applications.Content, "Content")]
- public class ContentApplicationDefinition : IApplication
- { }
-
- [Application(Constants.Applications.Media, "Media", sortOrder: 1)]
- public class MediaApplicationDefinition : IApplication
- { }
-
- [Application(Constants.Applications.Settings, "Settings", sortOrder: 2)]
- public class SettingsApplicationDefinition : IApplication
- { }
-
- [Application(Constants.Applications.Packages, "Packages", sortOrder: 3)]
- public class PackagesApplicationDefinition : IApplication
- { }
-
- [Application(Constants.Applications.Users, "Users", sortOrder: 4)]
- public class UsersApplicationDefinition : IApplication
- { }
-
- [Application(Constants.Applications.Members, "Members", sortOrder: 5)]
- public class MembersApplicationDefinition : IApplication
- { }
-
- [Application(Constants.Applications.Translation, "Translation", sortOrder: 6)]
- public class TranslationApplicationDefinition : IApplication
- { }
-}
diff --git a/src/Umbraco.Web/Models/Trees/IApplication.cs b/src/Umbraco.Web/Models/Trees/IApplication.cs
deleted file mode 100644
index 4e9cae43fd..0000000000
--- a/src/Umbraco.Web/Models/Trees/IApplication.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Umbraco.Core.Composing;
-
-namespace Umbraco.Web.Models.Trees
-{
- ///
- /// Marker interface for created applications in the umbraco backoffice
- ///
- public interface IApplication : IDiscoverable
- { }
-}
diff --git a/src/Umbraco.Web/Models/Trees/SectionRootNode.cs b/src/Umbraco.Web/Models/Trees/TreeRootNode.cs
similarity index 100%
rename from src/Umbraco.Web/Models/Trees/SectionRootNode.cs
rename to src/Umbraco.Web/Models/Trees/TreeRootNode.cs
diff --git a/src/Umbraco.Web/Mvc/SurfaceControllerTypeCollection.cs b/src/Umbraco.Web/Mvc/SurfaceControllerTypeCollection.cs
index 30c21fce96..d9577417cc 100644
--- a/src/Umbraco.Web/Mvc/SurfaceControllerTypeCollection.cs
+++ b/src/Umbraco.Web/Mvc/SurfaceControllerTypeCollection.cs
@@ -7,7 +7,7 @@ namespace Umbraco.Web.Mvc
// unless we want to modify the content of the collection
// which we are not doing at the moment
// we can inherit from BuilderCollectionBase and just be enumerable
-
+
public class SurfaceControllerTypeCollection : BuilderCollectionBase
{
public SurfaceControllerTypeCollection(IEnumerable items)
diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs
index 422b502f80..b7f4e13432 100644
--- a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs
+++ b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs
@@ -22,10 +22,12 @@ using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Profiling;
using Umbraco.Core.Services;
using Umbraco.Web.Install;
+using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.Routing;
using Umbraco.Web.Security;
+using Umbraco.Web.Trees;
using Umbraco.Web.UI.JavaScript;
using Umbraco.Web.WebApi;
diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs
index 51e4fbd008..1a0bf8d1b0 100644
--- a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs
+++ b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs
@@ -1,11 +1,11 @@
-using System.Web;
+using System.Linq;
+using System.Web;
using System.Web.Security;
using Examine;
using Microsoft.AspNet.SignalR;
using Umbraco.Core;
using Umbraco.Core.Components;
using Umbraco.Core.Composing;
-using Umbraco.Core.Configuration;
using Umbraco.Core.Dictionary;
using Umbraco.Core.Events;
using Umbraco.Core.Models.PublishedContent;
@@ -92,7 +92,7 @@ namespace Umbraco.Web.Runtime
// replace some services
composition.RegisterUnique();
composition.RegisterUnique();
- composition.RegisterUnique();
+ composition.RegisterUnique();
composition.RegisterUnique();
composition.RegisterUnique(factory => ExamineManager.Instance);
@@ -122,9 +122,11 @@ namespace Umbraco.Web.Runtime
composition.WithCollectionBuilder()
.Add(() => composition.TypeLoader.GetTypes());
+ //we need to eagerly scan controller types since they will need to be routed
var surfaceControllerTypes = new SurfaceControllerTypeCollection(composition.TypeLoader.GetSurfaceControllers());
composition.RegisterUnique(surfaceControllerTypes);
+ //we need to eagerly scan controller types since they will need to be routed
var umbracoApiControllerTypes = new UmbracoApiControllerTypeCollection(composition.TypeLoader.GetUmbracoApiControllers());
composition.RegisterUnique(umbracoApiControllerTypes);
@@ -189,6 +191,26 @@ namespace Umbraco.Web.Runtime
.Append()
.Append()
.Append();
+
+ // register back office sections in the order we want them rendered
+ composition.WithCollectionBuilder()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append()
+ .Append();
+
+ // register back office trees
+ foreach (var treeControllerType in umbracoApiControllerTypes
+ .Where(x => typeof(TreeControllerBase).IsAssignableFrom(x)))
+ {
+ var attribute = treeControllerType.GetCustomAttribute(false);
+ if (attribute == null) continue;
+ var tree = new Tree(attribute.SortOrder, attribute.ApplicationAlias, attribute.TreeAlias, attribute.TreeTitle, treeControllerType, attribute.IsSingleNodeTree);
+ composition.WithCollectionBuilder().Trees.Add(tree);
+ }
}
}
}
diff --git a/src/Umbraco.Web/Search/SearchableTreeCollection.cs b/src/Umbraco.Web/Search/SearchableTreeCollection.cs
index 38c329cafa..032782b466 100644
--- a/src/Umbraco.Web/Search/SearchableTreeCollection.cs
+++ b/src/Umbraco.Web/Search/SearchableTreeCollection.cs
@@ -5,6 +5,7 @@ using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Services;
+using Umbraco.Web.Services;
using Umbraco.Web.Trees;
namespace Umbraco.Web.Search
@@ -13,13 +14,13 @@ namespace Umbraco.Web.Search
{
private readonly Dictionary _dictionary;
- public SearchableTreeCollection(IEnumerable items, IApplicationTreeService treeService)
+ public SearchableTreeCollection(IEnumerable items, ITreeService treeService)
: base(items)
{
_dictionary = CreateDictionary(treeService);
}
- private Dictionary CreateDictionary(IApplicationTreeService treeService)
+ private Dictionary CreateDictionary(ITreeService treeService)
{
var appTrees = treeService.GetAll()
.OrderBy(x => x.SortOrder)
@@ -28,10 +29,10 @@ namespace Umbraco.Web.Search
var searchableTrees = this.ToArray();
foreach (var appTree in appTrees)
{
- var found = searchableTrees.FirstOrDefault(x => x.TreeAlias.InvariantEquals(appTree.Alias));
+ var found = searchableTrees.FirstOrDefault(x => x.TreeAlias.InvariantEquals(appTree.TreeAlias));
if (found != null)
{
- dictionary[found.TreeAlias] = new SearchableApplicationTree(appTree.ApplicationAlias, appTree.Alias, found);
+ dictionary[found.TreeAlias] = new SearchableApplicationTree(appTree.ApplicationAlias, appTree.TreeAlias, found);
}
}
return dictionary;
diff --git a/src/Umbraco.Web/Services/ApplicationTreeService.cs b/src/Umbraco.Web/Services/ApplicationTreeService.cs
deleted file mode 100644
index 86bfc5d0bb..0000000000
--- a/src/Umbraco.Web/Services/ApplicationTreeService.cs
+++ /dev/null
@@ -1,493 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Xml.Linq;
-using Umbraco.Core;
-using Umbraco.Core.Cache;
-using Umbraco.Core.Events;
-using Umbraco.Core.IO;
-using Umbraco.Core.Logging;
-using Umbraco.Core.Models;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Services;
-using Umbraco.Web.Trees;
-
-namespace Umbraco.Web.Services
-{
- internal class ApplicationTreeService : IApplicationTreeService
- {
- private readonly ILogger _logger;
- private readonly CacheHelper _cache;
- private readonly TypeLoader _typeLoader;
- private Lazy> _allAvailableTrees;
- internal const string TreeConfigFileName = "trees.config";
- private static string _treeConfig;
- private static readonly object Locker = new object();
- private readonly Lazy>> _groupedTrees;
-
- public ApplicationTreeService(ILogger logger, CacheHelper cache, TypeLoader typeLoader)
- {
- _logger = logger;
- _cache = cache;
- _typeLoader = typeLoader;
- _groupedTrees = new Lazy>>(InitGroupedTrees);
- }
-
- ///
- /// gets/sets the trees.config file path
- ///
- ///
- /// The setter is generally only going to be used in unit tests, otherwise it will attempt to resolve it using the IOHelper.MapPath
- ///
- internal static string TreeConfigFilePath
- {
- get
- {
- if (string.IsNullOrWhiteSpace(_treeConfig))
- {
- _treeConfig = IOHelper.MapPath(SystemDirectories.Config + "/" + TreeConfigFileName);
- }
- return _treeConfig;
- }
- set { _treeConfig = value; }
- }
-
- ///
- /// The main entry point to get application trees
- ///
- ///
- /// This lazily on first access will scan for plugin trees and ensure the trees.config is up-to-date with the plugins. If plugins
- /// haven't changed on disk then the file will not be saved. The trees are all then loaded from this config file into cache and returned.
- ///
- private List GetAppTrees()
- {
- return _cache.RuntimeCache.GetCacheItem>(
- CacheKeys.ApplicationTreeCacheKey,
- () =>
- {
- var list = ReadFromXmlAndSort();
-
- //now we can check the non-volatile flag
- if (_allAvailableTrees != null)
- {
- var hasChanges = false;
-
- LoadXml(doc =>
- {
- //Now, load in the xml structure and update it with anything that is not declared there and save the file.
-
- //NOTE: On the first iteration here, it will lazily scan all trees, etc... this is because this ienumerable is lazy
- // based on the ApplicationTreeRegistrar - and as noted there this is not an ideal way to do things but were stuck like this
- // currently because of the legacy assemblies and types not in the Core.
-
- //Get all the trees not registered in the config (those not matching by alias casing will be detected as "unregistered")
- var unregistered = _allAvailableTrees.Value
- .Where(x => list.Any(l => l.Alias == x.Alias) == false)
- .ToArray();
-
- hasChanges = unregistered.Any();
-
- if (hasChanges == false) return false;
-
- //add or edit the unregistered ones and re-save the file if any changes were found
- var count = 0;
- foreach (var tree in unregistered)
- {
- var existingElement = doc.Root.Elements("add").SingleOrDefault(x =>
- string.Equals(x.Attribute("alias").Value, tree.Alias,
- StringComparison.InvariantCultureIgnoreCase) &&
- string.Equals(x.Attribute("application").Value, tree.ApplicationAlias,
- StringComparison.InvariantCultureIgnoreCase));
- if (existingElement != null)
- {
- existingElement.SetAttributeValue("alias", tree.Alias);
- }
- else
- {
- if (tree.Title.IsNullOrWhiteSpace())
- {
- doc.Root.Add(new XElement("add",
- new XAttribute("initialize", tree.Initialize),
- new XAttribute("sortOrder", tree.SortOrder),
- new XAttribute("alias", tree.Alias),
- new XAttribute("application", tree.ApplicationAlias),
- new XAttribute("iconClosed", tree.IconClosed),
- new XAttribute("iconOpen", tree.IconOpened),
- new XAttribute("type", tree.Type)));
- }
- else
- {
- doc.Root.Add(new XElement("add",
- new XAttribute("initialize", tree.Initialize),
- new XAttribute("sortOrder", tree.SortOrder),
- new XAttribute("alias", tree.Alias),
- new XAttribute("application", tree.ApplicationAlias),
- new XAttribute("title", tree.Title),
- new XAttribute("iconClosed", tree.IconClosed),
- new XAttribute("iconOpen", tree.IconOpened),
- new XAttribute("type", tree.Type)));
- }
-
- }
- count++;
- }
-
- //don't save if there's no changes
- return count > 0;
- }, true);
-
- if (hasChanges)
- {
- //If there were changes, we need to re-read the structures from the XML
- list = ReadFromXmlAndSort();
- }
- }
-
- return list;
- }, new TimeSpan(0, 10, 0));
- }
-
- ///
- /// Creates a new application tree.
- ///
- /// if set to true [initialize].
- /// The sort order.
- /// The application alias.
- /// The alias.
- /// The title.
- /// The icon closed.
- /// The icon opened.
- /// The type.
- public void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
- {
- LoadXml(doc =>
- {
- var el = doc.Root.Elements("add").SingleOrDefault(x => x.Attribute("alias").Value == alias && x.Attribute("application").Value == applicationAlias);
-
- if (el == null)
- {
- doc.Root.Add(new XElement("add",
- new XAttribute("initialize", initialize),
- new XAttribute("sortOrder", sortOrder),
- new XAttribute("alias", alias),
- new XAttribute("application", applicationAlias),
- new XAttribute("title", title),
- new XAttribute("iconClosed", iconClosed),
- new XAttribute("iconOpen", iconOpened),
- new XAttribute("type", type)));
- }
-
- return true;
-
- }, true);
-
- OnNew(new ApplicationTree(initialize, sortOrder, applicationAlias, alias, title, iconClosed, iconOpened, type), new EventArgs());
- }
-
- ///
- /// Saves this instance.
- ///
- public void SaveTree(ApplicationTree tree)
- {
- LoadXml(doc =>
- {
- var el = doc.Root.Elements("add").SingleOrDefault(x => x.Attribute("alias").Value == tree.Alias && x.Attribute("application").Value == tree.ApplicationAlias);
-
- if (el != null)
- {
- el.RemoveAttributes();
-
- el.Add(new XAttribute("initialize", tree.Initialize));
- el.Add(new XAttribute("sortOrder", tree.SortOrder));
- el.Add(new XAttribute("alias", tree.Alias));
- el.Add(new XAttribute("application", tree.ApplicationAlias));
- el.Add(new XAttribute("title", tree.Title));
- el.Add(new XAttribute("iconClosed", tree.IconClosed));
- el.Add(new XAttribute("iconOpen", tree.IconOpened));
- el.Add(new XAttribute("type", tree.Type));
- }
-
- return true;
-
- }, true);
-
- OnUpdated(tree, new EventArgs());
- }
-
- ///
- /// Deletes this instance.
- ///
- public void DeleteTree(ApplicationTree tree)
- {
- LoadXml(doc =>
- {
- doc.Root.Elements("add")
- .Where(x => x.Attribute("application") != null
- && x.Attribute("application").Value == tree.ApplicationAlias
- && x.Attribute("alias") != null && x.Attribute("alias").Value == tree.Alias).Remove();
-
- return true;
-
- }, true);
-
- OnDeleted(tree, new EventArgs());
- }
-
- ///
- /// Gets an ApplicationTree by it's tree alias.
- ///
- /// The tree alias.
- /// An ApplicationTree instance
- public ApplicationTree GetByAlias(string treeAlias)
- {
- return GetAppTrees().Find(t => (t.Alias == treeAlias));
-
- }
-
- ///
- /// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
- ///
- /// Returns a ApplicationTree Array
- public IEnumerable GetAll()
- {
- return GetAppTrees().OrderBy(x => x.SortOrder);
- }
-
- ///
- /// Gets the application tree for the applcation with the specified alias
- ///
- /// The application alias.
- /// Returns a ApplicationTree Array
- public IEnumerable GetApplicationTrees(string applicationAlias)
- {
- return GetApplicationTrees(applicationAlias, false);
- }
-
- ///
- /// Gets the application tree for the applcation with the specified alias
- ///
- /// The application alias.
- ///
- /// Returns a ApplicationTree Array
- public IEnumerable GetApplicationTrees(string applicationAlias, bool onlyInitialized)
- {
- var list = GetAppTrees().FindAll(
- t =>
- {
- if (onlyInitialized)
- return (t.ApplicationAlias == applicationAlias && t.Initialize);
- return (t.ApplicationAlias == applicationAlias);
- }
- );
-
- return list.OrderBy(x => x.SortOrder).ToArray();
- }
-
- public IDictionary> GetGroupedApplicationTrees(string applicationAlias, bool onlyInitialized)
- {
- var result = new Dictionary>();
- var foundTrees = GetApplicationTrees(applicationAlias, onlyInitialized);
- foreach(var treeGroup in _groupedTrees.Value)
- {
- List resultGroup = null;
- foreach(var tree in foundTrees)
- {
- foreach(var treeAliasInGroup in treeGroup)
- {
- if (tree.Alias == treeAliasInGroup)
- {
- if (resultGroup == null) resultGroup = new List();
- resultGroup.Add(tree);
- }
- }
- }
- if (resultGroup != null)
- result[treeGroup.Key ?? string.Empty] = resultGroup; //key cannot be null so make empty string
- }
- return result;
- }
-
- ///
- /// Creates a group of all tree groups and their tree aliases
- ///
- ///
- ///
- /// Used to initialize the field
- ///
- private IReadOnlyCollection> InitGroupedTrees()
- {
- var result = GetAll()
- .Select(x => (treeAlias: x.Alias, treeGroup: x.GetRuntimeType().GetCustomAttribute(false)?.TreeGroup))
- .GroupBy(x => x.treeGroup, x => x.treeAlias)
- .ToList();
- return result;
- }
-
- ///
- /// Loads in the xml structure from disk if one is found, otherwise loads in an empty xml structure, calls the
- /// callback with the xml document and saves the structure back to disk if saveAfterCallback is true.
- ///
- ///
- ///
- internal void LoadXml(Func callback, bool saveAfterCallbackIfChanges)
- {
- lock (Locker)
- {
- var doc = System.IO.File.Exists(TreeConfigFilePath)
- ? XDocument.Load(TreeConfigFilePath)
- : XDocument.Parse("");
-
- if (doc.Root != null)
- {
- var hasChanges = callback.Invoke(doc);
-
- if (saveAfterCallbackIfChanges && hasChanges
- //Don't save it if it is empty, in some very rare cases if the app domain get's killed in the middle of this process
- // in some insane way the file saved will be empty. I'm pretty sure it's not actually anything to do with the xml doc and
- // more about the IO trying to save the XML doc, but it doesn't hurt to check.
- && doc.Root != null && doc.Root.Elements().Any())
- {
- //ensures the folder exists
- Directory.CreateDirectory(Path.GetDirectoryName(TreeConfigFilePath));
-
- //saves it
- doc.Save(TreeConfigFilePath);
-
- //remove the cache now that it has changed SD: I'm leaving this here even though it
- // is taken care of by events as well, I think unit tests may rely on it being cleared here.
- _cache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationTreeCacheKey);
- }
- }
- }
- }
-
- private List ReadFromXmlAndSort()
- {
- var list = new List();
-
- //read in the xml file containing trees and convert them all to ApplicationTree instances
- LoadXml(doc =>
- {
- foreach (var addElement in doc.Root.Elements("add").OrderBy(x =>
- {
- var sortOrderAttr = x.Attribute("sortOrder");
- return sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0;
- }))
- {
- var applicationAlias = (string)addElement.Attribute("application");
- var type = (string)addElement.Attribute("type");
- var assembly = (string)addElement.Attribute("assembly");
-
- var clrType = Type.GetType(type);
- if (clrType == null)
- {
- _logger.Warn("The tree definition: {AddElement} could not be resolved to a .Net object type", addElement);
- continue;
- }
-
- //check if the tree definition (applicationAlias + type + assembly) is already in the list
-
- if (list.Any(tree => tree.ApplicationAlias.InvariantEquals(applicationAlias) && tree.GetRuntimeType() == clrType) == false)
- {
- list.Add(new ApplicationTree(
- addElement.Attribute("initialize") == null || Convert.ToBoolean(addElement.Attribute("initialize").Value),
- addElement.Attribute("sortOrder") != null
- ? Convert.ToByte(addElement.Attribute("sortOrder").Value)
- : (byte)0,
- (string)addElement.Attribute("application"),
- (string)addElement.Attribute("alias"),
- (string)addElement.Attribute("title"),
- (string)addElement.Attribute("iconClosed"),
- (string)addElement.Attribute("iconOpen"),
- (string)addElement.Attribute("type")));
- }
- }
-
- return false;
-
- }, false);
-
- return list;
- }
-
-
- internal static event TypedEventHandler Deleted;
- private static void OnDeleted(ApplicationTree app, EventArgs args)
- {
- if (Deleted != null)
- {
- Deleted(app, args);
- }
- }
-
- internal static event TypedEventHandler New;
- private static void OnNew(ApplicationTree app, EventArgs args)
- {
- if (New != null)
- {
- New(app, args);
- }
- }
-
- internal static event TypedEventHandler Updated;
- private static void OnUpdated(ApplicationTree app, EventArgs args)
- {
- if (Updated != null)
- {
- Updated(app, args);
- }
- }
-
- ///
- /// This class is here so that we can provide lazy access to tree scanning for when it is needed
- ///
- private class LazyEnumerableTrees : IEnumerable
- {
- public LazyEnumerableTrees(TypeLoader typeLoader)
- {
- _lazyTrees = new Lazy>(() =>
- {
- var added = new List();
-
- // Load all Controller Trees by attribute
- var types = typeLoader.GetTypesWithAttribute(); // fixme inject
- //convert them to ApplicationTree instances
- var items = types
- .Select(x => (tree: x, treeAttribute: x.GetCustomAttributes(false).Single()))
- .Select(x => new ApplicationTree(x.treeAttribute.Initialize, x.treeAttribute.SortOrder, x.treeAttribute.ApplicationAlias, x.treeAttribute.Alias, x.treeAttribute.Title, x.treeAttribute.IconClosed, x.treeAttribute.IconOpen, x.tree.GetFullNameWithAssembly()))
- .ToArray();
-
- added.AddRange(items.Select(x => x.Alias));
-
- return items.ToArray();
- });
- }
-
- private readonly Lazy> _lazyTrees;
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- public IEnumerator GetEnumerator()
- {
- return _lazyTrees.Value.GetEnumerator();
- }
-
- ///
- /// Returns an enumerator that iterates through a collection.
- ///
- ///
- /// An object that can be used to iterate through the collection.
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
- }
-}
diff --git a/src/Umbraco.Web/Services/ISectionService.cs b/src/Umbraco.Web/Services/ISectionService.cs
new file mode 100644
index 0000000000..1cb8b6d450
--- /dev/null
+++ b/src/Umbraco.Web/Services/ISectionService.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Umbraco.Core.Models.Trees;
+
+namespace Umbraco.Web.Services
+{
+ public interface ISectionService
+ {
+ ///
+ /// The cache storage for all applications
+ ///
+ IEnumerable GetSections();
+
+ ///
+ /// Get the user group's allowed sections
+ ///
+ ///
+ ///
+ IEnumerable GetAllowedSections(int userId);
+
+ ///
+ /// Gets the application by its alias.
+ ///
+ /// The application alias.
+ ///
+ IBackOfficeSection GetByAlias(string appAlias);
+ }
+}
diff --git a/src/Umbraco.Web/Services/ITreeService.cs b/src/Umbraco.Web/Services/ITreeService.cs
new file mode 100644
index 0000000000..96787086c6
--- /dev/null
+++ b/src/Umbraco.Web/Services/ITreeService.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Umbraco.Core.Models;
+using Umbraco.Core.Models.ContentEditing;
+using Umbraco.Web.Models.ContentEditing;
+using Umbraco.Web.Trees;
+
+namespace Umbraco.Web.Services
+{
+ public interface ITreeService
+ {
+ ///
+ /// Gets an ApplicationTree by it's tree alias.
+ ///
+ /// The tree alias.
+ /// An ApplicationTree instance
+ Tree GetByAlias(string treeAlias);
+
+ ///
+ /// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
+ ///
+ /// Returns a ApplicationTree Array
+ IEnumerable GetAll();
+
+ ///
+ /// Gets the application tree for the applcation with the specified alias
+ ///
+ /// The application alias.
+ /// Returns a ApplicationTree Array
+ IEnumerable GetTrees(string sectionAlias);
+
+ ///
+ /// Gets the grouped application trees for the application with the specified alias
+ ///
+ ///
+ ///
+ IDictionary> GetGroupedTrees(string sectionAlias);
+ }
+
+}
diff --git a/src/Umbraco.Web/Services/SectionService.cs b/src/Umbraco.Web/Services/SectionService.cs
index 6337db67f9..0be28b0294 100644
--- a/src/Umbraco.Web/Services/SectionService.cs
+++ b/src/Umbraco.Web/Services/SectionService.cs
@@ -1,331 +1,43 @@
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
-using System.Xml.Linq;
-using Umbraco.Core;
-using Umbraco.Core.Cache;
-using Umbraco.Core.Events;
-using Umbraco.Core.IO;
-using Umbraco.Core.Models;
-using Umbraco.Core.Composing;
-using Umbraco.Core.Scoping;
+using Umbraco.Core.Models.Trees;
using Umbraco.Core.Services;
-using Umbraco.Web.Models.Trees;
-using File = System.IO.File;
+using Umbraco.Web.Trees;
namespace Umbraco.Web.Services
{
internal class SectionService : ISectionService
{
private readonly IUserService _userService;
- private readonly Lazy> _allAvailableSections;
- private readonly IApplicationTreeService _applicationTreeService;
- private readonly IScopeProvider _scopeProvider;
- private readonly CacheHelper _cache;
- internal const string AppConfigFileName = "applications.config";
- private static string _appConfig;
- private static readonly object Locker = new object();
+ private readonly BackOfficeSectionCollection _sectionCollection;
public SectionService(
IUserService userService,
- IApplicationTreeService applicationTreeService,
- IScopeProvider scopeProvider,
- CacheHelper cache)
+ BackOfficeSectionCollection sectionCollection)
{
- _applicationTreeService = applicationTreeService ?? throw new ArgumentNullException(nameof(applicationTreeService));
- _cache = cache ?? throw new ArgumentNullException(nameof(cache));
- _userService = userService;
- _scopeProvider = scopeProvider;
- _allAvailableSections = new Lazy>(() => new LazyEnumerableSections());
- }
-
-
- ///
- /// gets/sets the application.config file path
- ///
- ///
- /// The setter is generally only going to be used in unit tests, otherwise it will attempt to resolve it using the IOHelper.MapPath
- ///
- internal static string AppConfigFilePath
- {
- get
- {
- if (string.IsNullOrWhiteSpace(_appConfig))
- {
- _appConfig = IOHelper.MapPath(SystemDirectories.Config + "/" + AppConfigFileName);
- }
- return _appConfig;
- }
- set => _appConfig = value;
+ _userService = userService ?? throw new ArgumentNullException(nameof(userService));
+ _sectionCollection = sectionCollection ?? throw new ArgumentNullException(nameof(sectionCollection));
}
///
/// The cache storage for all applications
///
- public IEnumerable GetSections()
+ public IEnumerable GetSections()
+ => _sectionCollection;
+
+ ///
+ public IEnumerable GetAllowedSections(int userId)
{
- return _cache.RuntimeCache.GetCacheItem>(
- CacheKeys.ApplicationsCacheKey,
- () =>
- {
- var list = ReadFromXmlAndSort();
- var hasChanges = false;
- var localCopyList = list;
-
- LoadXml(doc =>
- {
- //Now, load in the xml structure and update it with anything that is not declared there and save the file.
- //NOTE: On the first iteration here, it will lazily scan all apps, etc... this is because this ienumerable is lazy
- //Get all the trees not registered in the config
-
- var unregistered = _allAvailableSections.Value
- .Where(x => localCopyList.Any(l => l.Alias == x.Alias) == false)
- .ToArray();
-
- hasChanges = unregistered.Any();
-
- var count = 0;
- foreach (var attr in unregistered)
- {
- doc.Root.Add(new XElement("add",
- new XAttribute("alias", attr.Alias),
- new XAttribute("name", attr.Name),
- new XAttribute("sortOrder", attr.SortOrder)));
- count++;
- }
-
- //don't save if there's no changes
- return count > 0;
- }, true);
-
- if (hasChanges)
- {
- //If there were changes, we need to re-read the structures from the XML
- list = ReadFromXmlAndSort();
- }
-
- return list;
-
- }, new TimeSpan(0, 10, 0));
- }
-
- internal void LoadXml(Func callback, bool saveAfterCallbackIfChanged)
- {
- lock (Locker)
- {
- var doc = File.Exists(AppConfigFilePath)
- ? XDocument.Load(AppConfigFilePath)
- : XDocument.Parse("");
-
- if (doc.Root != null)
- {
- var changed = callback.Invoke(doc);
-
- if (saveAfterCallbackIfChanged && changed)
- {
- //ensure the folder is created!
- Directory.CreateDirectory(Path.GetDirectoryName(AppConfigFilePath));
-
- doc.Save(AppConfigFilePath);
-
- //remove the cache so it gets re-read ... SD: I'm leaving this here even though it
- // is taken care of by events as well, I think unit tests may rely on it being cleared here.
- _cache.RuntimeCache.ClearCacheItem(CacheKeys.ApplicationsCacheKey);
- }
- }
- }
- }
-
- ///
- /// Get the user's allowed sections
- ///
- ///
- ///
- public IEnumerable GetAllowedSections(int userId)
- {
-
var user = _userService.GetUserById(userId);
if (user == null)
- {
throw new InvalidOperationException("No user found with id " + userId);
- }
return GetSections().Where(x => user.AllowedSections.Contains(x.Alias));
}
- ///
- /// Gets the application by its alias.
- ///
- /// The application alias.
- ///
- public Section GetByAlias(string appAlias)
- {
- return GetSections().FirstOrDefault(t => t.Alias == appAlias);
- }
-
- ///
- /// Creates a new applcation if no application with the specified alias is found.
- ///
- /// The application name.
- /// The application alias.
- /// The application icon, which has to be located in umbraco/images/tray folder.
- public void MakeNew(string name, string alias, string icon)
- {
- var sections = GetSections();
- var nextSortOrder = sections.Any() ? sections.Max(x => x.SortOrder) + 1 : 1;
- MakeNew(name, alias, icon, nextSortOrder);
- }
-
- ///
- /// Makes the new.
- ///
- /// The name.
- /// The alias.
- /// The icon.
- /// The sort order.
- public void MakeNew(string name, string alias, string icon, int sortOrder)
- {
- if (GetSections().All(x => x.Alias != alias))
- {
- LoadXml(doc =>
- {
- doc.Root.Add(new XElement("add",
- new XAttribute("alias", alias),
- new XAttribute("name", name),
- new XAttribute("icon", icon),
- new XAttribute("sortOrder", sortOrder)));
- return true;
- }, true);
-
- //raise event
- OnNew(this /*new Section(name, alias, sortOrder)*/, new EventArgs());
- }
- }
-
- ///
- /// Deletes the section
- ///
- public void DeleteSection(Section section)
- {
- lock (Locker)
- {
- //delete the assigned applications
- using (var scope = _scopeProvider.CreateScope())
- {
- scope.Database.Execute("delete from umbracoUserGroup2App where app = @appAlias",
- new { appAlias = section.Alias });
- scope.Complete();
- }
-
- //delete the assigned trees
- var trees = _applicationTreeService.GetApplicationTrees(section.Alias);
- foreach (var t in trees)
- {
- _applicationTreeService.DeleteTree(t);
- }
-
- LoadXml(doc =>
- {
- doc.Root.Elements("add").Where(x => x.Attribute("alias") != null && x.Attribute("alias").Value == section.Alias)
- .Remove();
-
- return true;
- }, true);
-
- //raise event
- OnDeleted(this, new EventArgs());
- }
- }
-
- private List ReadFromXmlAndSort()
- {
- var tmp = new List();
-
- LoadXml(doc =>
- {
- foreach (var addElement in doc.Root.Elements("add").OrderBy(x =>
- {
- var sortOrderAttr = x.Attribute("sortOrder");
- return sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0;
- }))
- {
- var sortOrderAttr = addElement.Attribute("sortOrder");
- tmp.Add(new Section(addElement.Attribute("name").Value,
- addElement.Attribute("alias").Value,
- sortOrderAttr != null ? Convert.ToInt32(sortOrderAttr.Value) : 0));
- }
- return false;
- }, false);
-
- return tmp;
- }
-
- internal static event TypedEventHandler Deleted;
- private static void OnDeleted(ISectionService app, EventArgs args)
- {
- if (Deleted != null)
- {
- Deleted(app, args);
- }
- }
-
- internal static event TypedEventHandler New;
- private static void OnNew(ISectionService app, EventArgs args)
- {
- if (New != null)
- {
- New(app, args);
- }
- }
-
- ///
- /// This class is here so that we can provide lazy access to tree scanning for when it is needed
- ///
- private class LazyEnumerableSections : IEnumerable
- {
- public LazyEnumerableSections()
- {
- _lazySections = new Lazy>(() =>
- {
- // Load all Applications by attribute and add them to the XML config
-
- //don't cache the result of this because it is only used once during app startup, caching will just add a bit more mem overhead for no reason
- var types = Current.TypeLoader.GetTypesWithAttribute(cache: false); // fixme - inject
-
- //since applications don't populate their metadata from the attribute and because it is an interface,
- //we need to interrogate the attributes for the data. Would be better to have a base class that contains
- //metadata populated by the attribute. Oh well i guess.
- var attrs = types.Select(x => x.GetCustomAttributes(false).Single());
- return attrs.Select(x => new Section(x.Name, x.Alias, x.SortOrder)).ToArray();
- });
- }
-
- private readonly Lazy> _lazySections;
-
- ///
- /// Returns an enumerator that iterates through the collection.
- ///
- ///
- /// A that can be used to iterate through the collection.
- ///
- public IEnumerator GetEnumerator()
- {
- return _lazySections.Value.GetEnumerator();
- }
-
- ///
- /// Returns an enumerator that iterates through a collection.
- ///
- ///
- /// An object that can be used to iterate through the collection.
- ///
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-
+ ///
+ public IBackOfficeSection GetByAlias(string appAlias)
+ => GetSections().FirstOrDefault(t => t.Alias == appAlias);
}
}
diff --git a/src/Umbraco.Web/Services/TreeService.cs b/src/Umbraco.Web/Services/TreeService.cs
new file mode 100644
index 0000000000..f58dce59bc
--- /dev/null
+++ b/src/Umbraco.Web/Services/TreeService.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Umbraco.Core;
+using Umbraco.Web.Trees;
+
+namespace Umbraco.Web.Services
+{
+ internal class TreeService : ITreeService
+ {
+ private readonly TreeCollection _treeCollection;
+ private readonly Lazy>> _groupedTrees;
+
+ public TreeService(TreeCollection treeCollection)
+ {
+ _treeCollection = treeCollection;
+ _groupedTrees = new Lazy>>(InitGroupedTrees);
+ }
+
+ ///