From 171fce2ecb0870f1c4a6a38a6425f803e3ddba29 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Thu, 30 Jan 2020 20:05:16 +0100 Subject: [PATCH 01/15] Moved PublishedCache from Umbraco.Web into .Net standard project. Returned to compiling state with a number of things to check and some temporarily commented out functionality. --- .../PublishedContent}/PublishedContentBase.cs | 2 +- .../IPublishedSnapshotService.cs | 4 ++ .../CompositionExtensions.cs | 41 ++++++++++++++ .../DefaultCultureAccessor.cs | 0 .../NuCache/CacheKeys.cs | 0 .../NuCache/ContentCache.cs | 0 .../NuCache/ContentNode.cs | 0 .../NuCache/ContentNodeKit.cs | 0 .../NuCache/ContentStore.cs | 0 .../DataSource/BTree.ContentDataSerializer.cs | 0 .../BTree.ContentNodeKitSerializer.cs | 0 ....DictionaryOfCultureVariationSerializer.cs | 0 ...Tree.DictionaryOfPropertyDataSerializer.cs | 0 .../NuCache/DataSource/BTree.cs | 0 .../NuCache/DataSource/ContentData.cs | 0 .../NuCache/DataSource/ContentNestedData.cs | 0 .../NuCache/DataSource/ContentSourceDto.cs | 0 .../NuCache/DataSource/CultureVariation.cs | 0 .../NuCache/DataSource/DatabaseDataSource.cs | 14 +++-- .../NuCache/DataSource/IDataSource.cs | 0 .../NuCache/DataSource/PropertyData.cs | 0 .../NuCache/DataSource/SerializerBase.cs | 0 .../NuCache/DomainCache.cs | 0 .../NuCache/MediaCache.cs | 0 .../NuCache/MemberCache.cs | 2 - .../NuCache/Navigable/INavigableData.cs | 0 .../NuCache/Navigable/NavigableContent.cs | 0 .../NuCache/Navigable/NavigableContentType.cs | 0 .../Navigable/NavigablePropertyType.cs | 0 .../NuCache/Navigable/RootContent.cs | 0 .../NuCache/Navigable/Source.cs | 0 .../NuCache/NuCacheComponent.cs | 0 .../NuCache/NuCacheComposer.cs | 1 + .../NuCache/Property.cs | 0 .../NuCache/PublishedContent.cs | 29 ++-------- .../NuCache/PublishedMember.cs | 0 .../NuCache/PublishedSnapshot.cs | 0 .../NuCache/PublishedSnapshotService.cs | 6 +-- .../PublishedSnapshotServiceOptions.cs | 0 .../NuCache/Snap/GenObj.cs | 0 .../NuCache/Snap/GenRef.cs | 0 .../NuCache/Snap/LinkedNode.cs | 0 .../NuCache/SnapDictionary.cs | 0 .../NuCache/readme.md | 0 .../PublishedCacheBase.cs | 9 ++-- .../PublishedContentTypeCache.cs | 0 .../PublishedElement.cs | 2 +- .../PublishedElementPropertyBase.cs | 0 .../PublishedMember.cs | 0 .../PublishedSnapshotServiceBase.cs | 6 +++ ...braco.Infrastructure.PublishedCache.csproj | 26 +++++++++ .../Umbraco.ModelsBuilder.Embedded.csproj | 4 ++ .../XmlPublishedSnapshotService.cs | 5 ++ .../Scoping/ScopedNuCacheTests.cs | 2 +- .../ContentTypeServiceVariantsTests.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 4 ++ src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 2 + src/Umbraco.Web/CompositionExtensions.cs | 31 ----------- .../Editors/NuCacheStatusController.cs | 16 +++--- .../Editors/PublishedStatusController.cs | 10 ++-- src/Umbraco.Web/Umbraco.Web.csproj | 54 ++----------------- src/umbraco.sln | 17 ++++-- 62 files changed, 148 insertions(+), 141 deletions(-) rename src/{Umbraco.Web/Models => Umbraco.Abstractions/Models/PublishedContent}/PublishedContentBase.cs (97%) create mode 100644 src/Umbraco.Infrastructure.PublishedCache/CompositionExtensions.cs rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/DefaultCultureAccessor.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/CacheKeys.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/ContentCache.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/ContentNode.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/ContentNodeKit.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/ContentStore.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/BTree.ContentDataSerializer.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/BTree.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/ContentData.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/ContentNestedData.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/ContentSourceDto.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/CultureVariation.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/DatabaseDataSource.cs (96%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/IDataSource.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/PropertyData.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DataSource/SerializerBase.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/DomainCache.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/MediaCache.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/MemberCache.cs (99%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Navigable/INavigableData.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Navigable/NavigableContent.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Navigable/NavigableContentType.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Navigable/NavigablePropertyType.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Navigable/RootContent.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Navigable/Source.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/NuCacheComponent.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/NuCacheComposer.cs (97%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Property.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/PublishedContent.cs (93%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/PublishedMember.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/PublishedSnapshot.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/PublishedSnapshotService.cs (99%) mode change 100755 => 100644 rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/PublishedSnapshotServiceOptions.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Snap/GenObj.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Snap/GenRef.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/Snap/LinkedNode.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/SnapDictionary.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/NuCache/readme.md (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/PublishedCacheBase.cs (92%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/PublishedContentTypeCache.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/PublishedElement.cs (98%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/PublishedElementPropertyBase.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/PublishedMember.cs (100%) rename src/{Umbraco.Web/PublishedCache => Umbraco.Infrastructure.PublishedCache}/PublishedSnapshotServiceBase.cs (95%) create mode 100644 src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs similarity index 97% rename from src/Umbraco.Web/Models/PublishedContentBase.cs rename to src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs index 23fef7959e..6c6c9c4cc7 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs @@ -76,7 +76,7 @@ namespace Umbraco.Web.Models public abstract DateTime UpdateDate { get; } /// - public virtual string Url => this.Url(); + public virtual string Url => string.Empty; // TODO: get from this.Url(); /// public abstract IReadOnlyDictionary Cultures { get; } diff --git a/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs b/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs index 9949b4b3f8..96831e3112 100644 --- a/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs +++ b/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs @@ -160,5 +160,9 @@ namespace Umbraco.Web.PublishedCache void Notify(DomainCacheRefresher.JsonPayload[] payloads); #endregion + + string GetStatus(); + + void Collect(); } } diff --git a/src/Umbraco.Infrastructure.PublishedCache/CompositionExtensions.cs b/src/Umbraco.Infrastructure.PublishedCache/CompositionExtensions.cs new file mode 100644 index 0000000000..262c2a903c --- /dev/null +++ b/src/Umbraco.Infrastructure.PublishedCache/CompositionExtensions.cs @@ -0,0 +1,41 @@ +using System; +using Umbraco.Core; +using Umbraco.Core.Composing; +using Umbraco.Web.PublishedCache; + +namespace Umbraco.Infrastructure.PublishedCache +{ + public static class CompositionExtensions + { + /// + /// Sets the published snapshot service. + /// + /// The composition. + /// A function creating a published snapshot service. + public static void SetPublishedSnapshotService(this Composition composition, Func factory) + { + composition.RegisterUnique(factory); + } + + /// + /// Sets the published snapshot service. + /// + /// The type of the published snapshot service. + /// The composition. + public static void SetPublishedSnapshotService(this Composition composition) + where T : IPublishedSnapshotService + { + composition.RegisterUnique(); + } + + /// + /// Sets the published snapshot service. + /// + /// The composition. + /// A published snapshot service. + public static void SetPublishedSnapshotService(this Composition composition, IPublishedSnapshotService service) + { + composition.RegisterUnique(_ => service); + } + } +} diff --git a/src/Umbraco.Web/PublishedCache/DefaultCultureAccessor.cs b/src/Umbraco.Infrastructure.PublishedCache/DefaultCultureAccessor.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/DefaultCultureAccessor.cs rename to src/Umbraco.Infrastructure.PublishedCache/DefaultCultureAccessor.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/CacheKeys.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/CacheKeys.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/CacheKeys.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/CacheKeys.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentCache.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentCache.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNode.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNode.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNodeKit.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNodeKit.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.ContentDataSerializer.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentDataSerializer.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.ContentDataSerializer.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentDataSerializer.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/BTree.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentData.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentData.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentData.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentData.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentNestedData.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentNestedData.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentNestedData.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentSourceDto.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentSourceDto.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentSourceDto.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentSourceDto.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/CultureVariation.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/CultureVariation.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/CultureVariation.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/CultureVariation.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/DatabaseDataSource.cs similarity index 96% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/DatabaseDataSource.cs index 4515e235ad..fcab4bb5df 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/DatabaseDataSource.cs @@ -10,7 +10,6 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Scoping; using Umbraco.Core.Serialization; -using Umbraco.Web.Composing; using static Umbraco.Core.Persistence.SqlExtensionsStatics; namespace Umbraco.Web.PublishedCache.NuCache.DataSource @@ -20,6 +19,13 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource // provides efficient database access for NuCache internal class DatabaseDataSource : IDataSource { + private readonly ILogger _logger; + + public DatabaseDataSource(ILogger logger) + { + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + } + // we want arrays, we want them all loaded, not an enumerable private Sql ContentSourcesSelect(IScope scope, Func, Sql> joins = null) @@ -181,7 +187,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource return scope.Database.Query(sql).Select(CreateMediaNodeKit); } - private static ContentNodeKit CreateContentNodeKit(ContentSourceDto dto) + private ContentNodeKit CreateContentNodeKit(ContentSourceDto dto) { ContentData d = null; ContentData p = null; @@ -192,7 +198,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource { if (Debugger.IsAttached) throw new Exception("Missing cmsContentNu edited content for node " + dto.Id + ", consider rebuilding."); - Current.Logger.Warn("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id); + _logger.Warn("Missing cmsContentNu edited content for node {NodeId}, consider rebuilding.", dto.Id); } else { @@ -219,7 +225,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource { if (Debugger.IsAttached) throw new Exception("Missing cmsContentNu published content for node " + dto.Id + ", consider rebuilding."); - Current.Logger.Warn("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id); + _logger.Warn("Missing cmsContentNu published content for node {NodeId}, consider rebuilding.", dto.Id); } else { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/IDataSource.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/IDataSource.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/IDataSource.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/IDataSource.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/PropertyData.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/PropertyData.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/PropertyData.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/PropertyData.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/SerializerBase.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/SerializerBase.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DataSource/SerializerBase.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/SerializerBase.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DomainCache.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/DomainCache.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/DomainCache.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/DomainCache.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/MediaCache.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/MediaCache.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/MemberCache.cs similarity index 99% rename from src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/MemberCache.cs index 9e2d1f4582..68d82731d8 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/MemberCache.cs @@ -6,11 +6,9 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.Security; using Umbraco.Core.Services; using Umbraco.Core.Xml.XPath; using Umbraco.Web.PublishedCache.NuCache.Navigable; -using Umbraco.Web.Security; namespace Umbraco.Web.PublishedCache.NuCache { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/INavigableData.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/INavigableData.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Navigable/INavigableData.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/INavigableData.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContent.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContent.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContent.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContent.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContentType.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContentType.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContentType.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContentType.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigablePropertyType.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigablePropertyType.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigablePropertyType.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigablePropertyType.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/RootContent.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/RootContent.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Navigable/RootContent.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/RootContent.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/Source.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/Source.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Navigable/Source.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/Source.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComponent.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComponent.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs similarity index 97% rename from src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs index 186f3908d1..06a2bdbe81 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs @@ -3,6 +3,7 @@ using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Scoping; using Umbraco.Core.Services; +using Umbraco.Infrastructure.PublishedCache; using Umbraco.Web.PublishedCache.NuCache.DataSource; namespace Umbraco.Web.PublishedCache.NuCache diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Property.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Property.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Property.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Property.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs similarity index 93% rename from src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs index 1888613555..f9c6678343 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs @@ -4,9 +4,8 @@ using System.Linq; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Exceptions; -using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; -using Umbraco.Web.Composing; +using Umbraco.Core.Services; using Umbraco.Web.Models; using Umbraco.Web.PublishedCache.NuCache.DataSource; @@ -48,28 +47,6 @@ namespace Umbraco.Web.PublishedCache.NuCache PropertiesArray = properties.ToArray(); } - private string GetProfileNameById(int id) - { - var cache = GetCurrentSnapshotCache(); - return cache == null - ? GetProfileNameByIdNoCache(id) - : (string)cache.Get(CacheKeys.ProfileName(id), () => GetProfileNameByIdNoCache(id)); - } - - private static string GetProfileNameByIdNoCache(int id) - { -#if DEBUG - var userService = Current.Services?.UserService; - if (userService == null) return "[null]"; // for tests -#else - // we don't want each published content to hold a reference to the service - // so where should they get the service from really? from the locator... - var userService = Current.Services.UserService; -#endif - var user = userService.GetProfileById(id); - return user?.Name; - } - // used when cloning in ContentNode public PublishedContent( ContentNode contentNode, @@ -171,7 +148,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public override int CreatorId => _contentNode.CreatorId; /// - public override string CreatorName => GetProfileNameById(_contentNode.CreatorId); + public override string CreatorName => string.Empty; // TODO: remove (as want to avoid injecting user service to get these names) /// public override DateTime CreateDate => _contentNode.CreateDate; @@ -180,7 +157,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public override int WriterId => ContentData.WriterId; /// - public override string WriterName => GetProfileNameById(ContentData.WriterId); + public override string WriterName => string.Empty; // TODO: remove (as want to avoid injecting user service to get these names) /// public override DateTime UpdateDate => ContentData.VersionDate; diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedMember.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedMember.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshot.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshot.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshot.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshot.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs old mode 100755 new mode 100644 similarity index 99% rename from src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs index 67e334ec83..a997b6ab06 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs @@ -26,11 +26,9 @@ using Umbraco.Core.Services.Changes; using Umbraco.Core.Services.Implement; using Umbraco.Core.Strings; using Umbraco.Web.Cache; -using Umbraco.Web.Install; using Umbraco.Web.PublishedCache.NuCache.DataSource; using Umbraco.Web.Routing; using File = System.IO.File; -using Current = Umbraco.Web.Composing.Current; namespace Umbraco.Web.PublishedCache.NuCache { @@ -1767,7 +1765,7 @@ AND cmsContentNu.nodeId IS NULL #region Instrument - public string GetStatus() + public override string GetStatus() { var dbCacheIsOk = VerifyContentDbCache() && VerifyMediaDbCache() @@ -1790,7 +1788,7 @@ AND cmsContentNu.nodeId IS NULL " and " + ms + " snapshot" + (ms > 1 ? "s" : "") + "."; } - public void Collect() + public override void Collect() { var contentCollect = _contentStore.CollectAsync(); var mediaCollect = _mediaStore.CollectAsync(); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotServiceOptions.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotServiceOptions.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotServiceOptions.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotServiceOptions.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Snap/GenObj.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenObj.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Snap/GenObj.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenObj.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Snap/GenRef.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenRef.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Snap/GenRef.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenRef.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Snap/LinkedNode.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/LinkedNode.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/Snap/LinkedNode.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/LinkedNode.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/SnapDictionary.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/SnapDictionary.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/SnapDictionary.cs rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/SnapDictionary.cs diff --git a/src/Umbraco.Web/PublishedCache/NuCache/readme.md b/src/Umbraco.Infrastructure.PublishedCache/NuCache/readme.md similarity index 100% rename from src/Umbraco.Web/PublishedCache/NuCache/readme.md rename to src/Umbraco.Infrastructure.PublishedCache/NuCache/readme.md diff --git a/src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs similarity index 92% rename from src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs rename to src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs index 1f637663e5..50ee48e1ba 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedCacheBase.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs @@ -94,11 +94,14 @@ namespace Umbraco.Web.PublishedCache public virtual IEnumerable GetByContentType(IPublishedContentType contentType) { + // TODO: move this extension method and get working again. + // this is probably not super-efficient, but works // some cache implementation may want to override it, though - return GetAtRoot() - .SelectMany(x => x.DescendantsOrSelf()) - .Where(x => x.ContentType.Id == contentType.Id); + return Enumerable.Empty(); + //return GetAtRoot() + // .SelectMany(x => x.DescendantsOrSelf()) + // .Where(x => x.ContentType.Id == contentType.Id); } } } diff --git a/src/Umbraco.Web/PublishedCache/PublishedContentTypeCache.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedContentTypeCache.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/PublishedContentTypeCache.cs rename to src/Umbraco.Infrastructure.PublishedCache/PublishedContentTypeCache.cs diff --git a/src/Umbraco.Web/PublishedCache/PublishedElement.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedElement.cs similarity index 98% rename from src/Umbraco.Web/PublishedCache/PublishedElement.cs rename to src/Umbraco.Infrastructure.PublishedCache/PublishedElement.cs index 618c075b9b..b7c8f77bb7 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedElement.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedElement.cs @@ -14,7 +14,7 @@ namespace Umbraco.Web.PublishedCache // an entirely new models factory + not even sure it makes sense at all since // sets are created manually todo yes it does! - what does this all mean? // - internal class PublishedElement : IPublishedElement + public class PublishedElement : IPublishedElement { // initializes a new instance of the PublishedElement class // within the context of a published snapshot service (eg a published content property value) diff --git a/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedElementPropertyBase.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs rename to src/Umbraco.Infrastructure.PublishedCache/PublishedElementPropertyBase.cs diff --git a/src/Umbraco.Web/PublishedCache/PublishedMember.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs similarity index 100% rename from src/Umbraco.Web/PublishedCache/PublishedMember.cs rename to src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs diff --git a/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs similarity index 95% rename from src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs rename to src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs index 20d3e6d8e3..c7236f9c54 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs @@ -38,5 +38,11 @@ namespace Umbraco.Web.PublishedCache public virtual void Dispose() { } + + public abstract string GetStatus(); + + public virtual void Collect() + { + } } } diff --git a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj b/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj new file mode 100644 index 0000000000..d4c30668c5 --- /dev/null +++ b/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj @@ -0,0 +1,26 @@ + + + + netstandard2.0 + + + + + + + + + + + + + + + <_Parameter1>Umbraco.Tests + + + <_Parameter1>Umbraco.Tests.Benchmarks + + + + diff --git a/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj b/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj index 073a6566d0..1b9e78728d 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj +++ b/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj @@ -105,6 +105,10 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions + + {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} + Umbraco.Infrastructure.PublishedCache + {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs index 2e8f52a6a7..609dcd98b8 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedSnapshotService.cs @@ -268,5 +268,10 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache } #endregion + + public override string GetStatus() + { + return "Test status"; + } } } diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs index eba7187147..9e351ff3c9 100644 --- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs @@ -100,7 +100,7 @@ namespace Umbraco.Tests.Scoping ScopeProvider, documentRepository, mediaRepository, memberRepository, DefaultCultureAccessor, - new DatabaseDataSource(), + new DatabaseDataSource(Mock.Of()), Factory.GetInstance(), Factory.GetInstance(), new NoopPublishedModelFactory(), diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs index bbd428b918..8653aa3c58 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceVariantsTests.cs @@ -72,7 +72,7 @@ namespace Umbraco.Tests.Services ScopeProvider, documentRepository, mediaRepository, memberRepository, DefaultCultureAccessor, - new DatabaseDataSource(), + new DatabaseDataSource(Mock.Of()), Factory.GetInstance(), Factory.GetInstance(), Mock.Of(), diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index a06c0c0b25..1a3e2ace20 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -562,6 +562,10 @@ {fbe7c065-dac0-4025-a78b-63b24d3ab00b} Umbraco.Configuration + + {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} + Umbraco.Infrastructure.PublishedCache + {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index b04c2e2dcd..f78202af7a 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -383,7 +383,9 @@ + diff --git a/src/Umbraco.Web/CompositionExtensions.cs b/src/Umbraco.Web/CompositionExtensions.cs index 27a56afc1e..ae5a4f9773 100644 --- a/src/Umbraco.Web/CompositionExtensions.cs +++ b/src/Umbraco.Web/CompositionExtensions.cs @@ -169,37 +169,6 @@ namespace Umbraco.Web composition.RegisterUnique(_ => finder); } - /// - /// Sets the published snapshot service. - /// - /// The type of the published snapshot service. - /// The composition. - public static void SetPublishedSnapshotService(this Composition composition) - where T : IPublishedSnapshotService - { - composition.RegisterUnique(); - } - - /// - /// Sets the published snapshot service. - /// - /// The composition. - /// A function creating a published snapshot service. - public static void SetPublishedSnapshotService(this Composition composition, Func factory) - { - composition.RegisterUnique(factory); - } - - /// - /// Sets the published snapshot service. - /// - /// The composition. - /// A published snapshot service. - public static void SetPublishedSnapshotService(this Composition composition, IPublishedSnapshotService service) - { - composition.RegisterUnique(_ => service); - } - /// /// Sets the site domain helper. /// diff --git a/src/Umbraco.Web/Editors/NuCacheStatusController.cs b/src/Umbraco.Web/Editors/NuCacheStatusController.cs index 86dbdd4e01..0f50682e77 100644 --- a/src/Umbraco.Web/Editors/NuCacheStatusController.cs +++ b/src/Umbraco.Web/Editors/NuCacheStatusController.cs @@ -17,14 +17,16 @@ namespace Umbraco.Web.Editors _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); } - private PublishedSnapshotService PublishedSnapshotService + private IPublishedSnapshotService PublishedSnapshotService { get { - var svc = _publishedSnapshotService as PublishedSnapshotService; - if (svc == null) - throw new NotSupportedException("Not running NuCache."); - return svc; + // TODO: do we need this? + //var svc = _publishedSnapshotService as PublishedSnapshotService; + //if (svc == null) + // throw new NotSupportedException("Not running NuCache."); + // return svc; + return _publishedSnapshotService; } } @@ -32,9 +34,7 @@ namespace Umbraco.Web.Editors public string RebuildDbCache() { var service = PublishedSnapshotService; - service.RebuildContentDbCache(); - service.RebuildMediaDbCache(); - service.RebuildMemberDbCache(); + service.Rebuild(); return service.GetStatus(); } diff --git a/src/Umbraco.Web/Editors/PublishedStatusController.cs b/src/Umbraco.Web/Editors/PublishedStatusController.cs index a6272108e9..9b408e177e 100644 --- a/src/Umbraco.Web/Editors/PublishedStatusController.cs +++ b/src/Umbraco.Web/Editors/PublishedStatusController.cs @@ -17,13 +17,13 @@ namespace Umbraco.Web.Editors [HttpGet] public string GetPublishedStatusUrl() { - //if (service is PublishedCache.PublishedNoCache.PublishedSnapshotService) - // return "views/dashboard/developer/nocache.html"; + return "views/dashboard/settings/nucache.html"; - if (_publishedSnapshotService is PublishedCache.NuCache.PublishedSnapshotService) - return "views/dashboard/settings/nucache.html"; + // TODO: do we need this check? + //if (_publishedSnapshotService is PublishedCache.NuCache.PublishedSnapshotService) + // return "views/dashboard/settings/nucache.html"; - throw new NotSupportedException("Not supported: " + _publishedSnapshotService.GetType().FullName); + //throw new NotSupportedException("Not supported: " + _publishedSnapshotService.GetType().FullName); } } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 5d0517a9f3..341b57ceff 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -114,6 +114,10 @@ Umbraco.Examine {07FBC26B-2927-4A22-8D96-D644C667FECC} + + {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} + Umbraco.Infrastructure.PublishedCache + {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure @@ -212,10 +216,7 @@ - - - - + @@ -261,7 +262,6 @@ - @@ -363,48 +363,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -538,7 +497,6 @@ - @@ -641,7 +599,6 @@ - @@ -810,7 +767,6 @@ - diff --git a/src/umbraco.sln b/src/umbraco.sln index 0e060fb4d3..293cbf7dae 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -1,4 +1,5 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 + +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29209.152 MinimumVisualStudioVersion = 10.0.40219.1 @@ -100,18 +101,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IssueTemplates", "IssueTemp ..\.github\ISSUE_TEMPLATE\5_Security_issue.md = ..\.github\ISSUE_TEMPLATE\5_Security_issue.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Abstractions", "Umbraco.Abstractions\Umbraco.Abstractions.csproj", "{29AA69D9-B597-4395-8D42-43B1263C240A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Abstractions", "Umbraco.Abstractions\Umbraco.Abstractions.csproj", "{29AA69D9-B597-4395-8D42-43B1263C240A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.ModelsBuilder.Embedded", "Umbraco.ModelsBuilder.Embedded\Umbraco.ModelsBuilder.Embedded.csproj", "{52AC0BA8-A60E-4E36-897B-E8B97A54ED1C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastructure", "Umbraco.Infrastructure\Umbraco.Infrastructure.csproj", "{3AE7BF57-966B-45A5-910A-954D7C554441}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastructure", "Umbraco.Infrastructure\Umbraco.Infrastructure.csproj", "{3AE7BF57-966B-45A5-910A-954D7C554441}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Configuration", "Umbraco.Configuration\Umbraco.Configuration.csproj", "{FBE7C065-DAC0-4025-A78B-63B24D3AB00B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Configuration", "Umbraco.Configuration\Umbraco.Configuration.csproj", "{FBE7C065-DAC0-4025-A78B-63B24D3AB00B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastrucure.Persistance.SqlCe", "Umbraco.Infrastrucure.Persistance.SqlCe\Umbraco.Infrastrucure.Persistance.SqlCe.csproj", "{33085570-9BF2-4065-A9B0-A29D920D13BA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Infrastrucure.Persistance.SqlCe", "Umbraco.Infrastrucure.Persistance.SqlCe\Umbraco.Infrastrucure.Persistance.SqlCe.csproj", "{33085570-9BF2-4065-A9B0-A29D920D13BA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastructure.PublishedCache", "Umbraco.Infrastructure.PublishedCache\Umbraco.Infrastructure.PublishedCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -164,6 +167,10 @@ Global {FB5676ED-7A69-492C-B802-E7B24144C0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB5676ED-7A69-492C-B802-E7B24144C0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB5676ED-7A69-492C-B802-E7B24144C0FC}.Release|Any CPU.Build.0 = Release|Any CPU + {F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From f13abca1ac89490f6f9a64388a9a66d370f4c401 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 31 Jan 2020 11:28:52 +0100 Subject: [PATCH 02/15] Removed WriterName and CreatorName from IPublished content and replaced functionality with an extension methods requiring an instance of IUserService. --- .../PublishedContent/IPublishedContent.cs | 10 ----- .../PublishedContent/PublishedContentBase.cs | 6 --- .../PublishedContentWrapped.cs | 6 --- .../PublishedContentExtensions.cs | 13 +++++++ .../NuCache/PublishedContent.cs | 6 --- .../PublishedMember.cs | 4 -- .../PublishedMediaCacheTests.cs | 37 +++++++++---------- .../DictionaryPublishedContent.cs | 8 ---- .../XmlPublishedContent.cs | 35 +++--------------- .../PublishedContentDataTableTests.cs | 6 +-- .../PublishedContent/PublishedRouterTests.cs | 2 - .../SolidPublishedSnapshot.cs | 3 -- src/Umbraco.Tests/TestHelpers/BaseWebTest.cs | 3 +- src/Umbraco.Web/Macros/MacroRenderer.cs | 6 ++- .../PublishedContentHashtableConverter.cs | 11 +++--- src/Umbraco.Web/PublishedContentExtensions.cs | 18 ++++----- src/Umbraco.Web/Routing/PublishedRouter.cs | 10 +++-- 17 files changed, 65 insertions(+), 119 deletions(-) diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs index 1c0d39a8b8..d3a87ef3e0 100644 --- a/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs @@ -60,11 +60,6 @@ namespace Umbraco.Core.Models.PublishedContent /// int CreatorId { get; } - /// - /// Gets the name of the user who created the content item. - /// - string CreatorName { get; } - /// /// Gets the date the content item was created. /// @@ -75,11 +70,6 @@ namespace Umbraco.Core.Models.PublishedContent /// int WriterId { get; } - /// - /// Gets the name of the user who last updated the content item. - /// - string WriterName { get; } - /// /// Gets the date the content item was last updated. /// diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs index 6c6c9c4cc7..2aaffbe798 100644 --- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs @@ -60,18 +60,12 @@ namespace Umbraco.Web.Models /// public abstract int CreatorId { get; } - /// - public abstract string CreatorName { get; } - /// public abstract DateTime CreateDate { get; } /// public abstract int WriterId { get; } - /// - public abstract string WriterName { get; } - /// public abstract DateTime UpdateDate { get; } diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs index fb41c95419..7e6c730a02 100644 --- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs @@ -78,18 +78,12 @@ namespace Umbraco.Core.Models.PublishedContent /// public virtual int CreatorId => _content.CreatorId; - /// - public virtual string CreatorName => _content.CreatorName; - /// public virtual DateTime CreateDate => _content.CreateDate; /// public virtual int WriterId => _content.WriterId; - /// - public virtual string WriterName => _content.WriterName; - /// public virtual DateTime UpdateDate => _content.UpdateDate; diff --git a/src/Umbraco.Abstractions/PublishedContentExtensions.cs b/src/Umbraco.Abstractions/PublishedContentExtensions.cs index 5242fdfd67..11444a274b 100644 --- a/src/Umbraco.Abstractions/PublishedContentExtensions.cs +++ b/src/Umbraco.Abstractions/PublishedContentExtensions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Umbraco.Core.Composing; using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.Services; namespace Umbraco.Core { @@ -135,5 +136,17 @@ namespace Umbraco.Core ? children : children.Where(x => x.IsInvariantOrHasCulture(culture)); } + + public static string GetCreatorName(this IPublishedContent content, IUserService userService) + { + var user = userService.GetProfileById(content.CreatorId); + return user?.Name; + } + + public static string GetWriterName(this IPublishedContent content, IUserService userService) + { + var user = userService.GetProfileById(content.WriterId); + return user?.Name; + } } } diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs index f9c6678343..f60e2e1e99 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs @@ -147,18 +147,12 @@ namespace Umbraco.Web.PublishedCache.NuCache /// public override int CreatorId => _contentNode.CreatorId; - /// - public override string CreatorName => string.Empty; // TODO: remove (as want to avoid injecting user service to get these names) - /// public override DateTime CreateDate => _contentNode.CreateDate; /// public override int WriterId => ContentData.WriterId; - /// - public override string WriterName => string.Empty; // TODO: remove (as want to avoid injecting user service to get these names) - /// public override DateTime UpdateDate => ContentData.VersionDate; diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs index f4293b3dfb..bd84e4a9d2 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs @@ -141,10 +141,6 @@ namespace Umbraco.Web.PublishedCache public override string UrlSegment => throw new NotSupportedException(); - public override string WriterName => _member.GetCreatorProfile(_userService).Name; - - public override string CreatorName => _member.GetCreatorProfile(_userService).Name; - public override int WriterId => _member.CreatorId; public override int CreatorId => _member.CreatorId; diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs index 36ac57728e..6be417e484 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs @@ -25,6 +25,7 @@ namespace Umbraco.Tests.Cache.PublishedCache public class PublishMediaCacheTests : BaseWebTest { private Dictionary _mediaTypes; + private int _testWriterAndCreatorId; private IUmbracoContextAccessor _umbracoContextAccessor; protected override void Compose() @@ -51,6 +52,8 @@ namespace Umbraco.Tests.Cache.PublishedCache { testMediaType.Alias, testMediaType } }; ContentTypesCache.GetPublishedContentTypeByAlias = alias => _mediaTypes[alias]; + + _testWriterAndCreatorId = ServiceContext.UserService.CreateUserWithIdentity("Shannon", "test").Id; } private IMediaType MakeNewMediaType(IUser user, string text, int parentId = -1) @@ -201,7 +204,7 @@ namespace Umbraco.Tests.Cache.PublishedCache {"path", "-1,1234"}, {"updateDate", DateTime.Parse("2012-07-16T10:34:09").Ticks.ToString()}, {"createDate", DateTime.Parse("2012-07-17T10:34:09").Ticks.ToString()}, - {"creatorID", "0"}, + {"creatorID", _testWriterAndCreatorId.ToString()}, {"creatorName", "Shannon"} }; @@ -210,7 +213,7 @@ namespace Umbraco.Tests.Cache.PublishedCache var store = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(), VariationContextAccessor); var doc = store.CreateFromCacheValues(store.ConvertFromSearchResult(result)); - DoAssert(doc, 1234, key, null, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", 0, 0, "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2); + DoAssert(doc, 1234, key, null, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2); Assert.AreEqual(null, doc.Parent); } @@ -226,7 +229,7 @@ namespace Umbraco.Tests.Cache.PublishedCache var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null, null, null, null, HostingEnvironment), ServiceContext.MediaService, ServiceContext.UserService, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance(), Factory.GetInstance(),VariationContextAccessor); var doc = cache.CreateFromCacheValues(cache.ConvertFromXPathNavigator(navigator, true)); - DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1); + DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1); Assert.AreEqual(null, doc.Parent); Assert.AreEqual(2, doc.Children.Count()); Assert.AreEqual(2001, doc.Children.ElementAt(0).Id); @@ -243,16 +246,18 @@ namespace Umbraco.Tests.Cache.PublishedCache ]> - + - + - + "; + xml = xml.Replace("[WriterId]", _testWriterAndCreatorId.ToString()); + xml = xml.Replace("[CreatorId]", _testWriterAndCreatorId.ToString()); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); @@ -279,10 +284,8 @@ namespace Umbraco.Tests.Cache.PublishedCache {"urlName", "testing"}, {nodeTypeAliasKey, "myType"}, {"nodeType", "22"}, - {"writerName", "Shannon"}, - {"creatorName", "Shannon"}, - {"writerID", "33"}, - {"creatorID", "33"}, + {"writerID", _testWriterAndCreatorId.ToString()}, + {"creatorID", _testWriterAndCreatorId.ToString()}, {pathKey, "1,2,3,4,5"}, {"createDate", "2012-01-02"}, {"updateDate", "2012-01-02"}, @@ -349,8 +352,6 @@ namespace Umbraco.Tests.Cache.PublishedCache int nodeTypeIdVal = 22, string writerNameVal = "Shannon", string creatorNameVal = "Shannon", - int writerIdVal = 33, - int creatorIdVal = 33, string pathVal = "1,2,3,4,5", DateTime? createDateVal = null, DateTime? updateDateVal = null, @@ -363,7 +364,7 @@ namespace Umbraco.Tests.Cache.PublishedCache updateDateVal = DateTime.Parse("2012-01-02"); DoAssert((IPublishedContent)dicDoc, idVal, keyVal, templateIdVal, sortOrderVal, urlNameVal, nodeTypeAliasVal, nodeTypeIdVal, writerNameVal, - creatorNameVal, writerIdVal, creatorIdVal, pathVal, createDateVal, updateDateVal, levelVal); + creatorNameVal, pathVal, createDateVal, updateDateVal, levelVal); //now validate the parentId that has been parsed, this doesn't exist on the IPublishedContent Assert.AreEqual(parentIdVal, dicDoc.ParentId); @@ -380,8 +381,6 @@ namespace Umbraco.Tests.Cache.PublishedCache int nodeTypeIdVal = 22, string writerNameVal = "Shannon", string creatorNameVal = "Shannon", - int writerIdVal = 33, - int creatorIdVal = 33, string pathVal = "1,2,3,4,5", DateTime? createDateVal = null, DateTime? updateDateVal = null, @@ -399,10 +398,10 @@ namespace Umbraco.Tests.Cache.PublishedCache Assert.AreEqual(urlNameVal, doc.UrlSegment); Assert.AreEqual(nodeTypeAliasVal, doc.ContentType.Alias); Assert.AreEqual(nodeTypeIdVal, doc.ContentType.Id); - Assert.AreEqual(writerNameVal, doc.WriterName); - Assert.AreEqual(creatorNameVal, doc.CreatorName); - Assert.AreEqual(writerIdVal, doc.WriterId); - Assert.AreEqual(creatorIdVal, doc.CreatorId); + Assert.AreEqual(writerNameVal, doc.GetWriterName(ServiceContext.UserService)); + Assert.AreEqual(creatorNameVal, doc.GetCreatorName(ServiceContext.UserService)); + Assert.AreEqual(_testWriterAndCreatorId, doc.WriterId); + Assert.AreEqual(_testWriterAndCreatorId, doc.CreatorId); Assert.AreEqual(pathVal, doc.Path); Assert.AreEqual(createDateVal.Value, doc.CreateDate); Assert.AreEqual(updateDateVal.Value, doc.UpdateDate); diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs index 31fbb8d6b9..11b1f1c049 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs @@ -61,8 +61,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache ValidateAndSetProperty(valueDictionary, val => _urlName = val, "urlName"); ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", LuceneIndex.ItemTypeFieldName); ValidateAndSetProperty(valueDictionary, val => _documentTypeId = Int32.Parse(val), "nodeType"); - //ValidateAndSetProperty(valueDictionary, val => _writerName = val, "writerName"); - ValidateAndSetProperty(valueDictionary, val => _creatorName = val, "creatorName", "writerName"); //this is a bit of a hack fix for: U4-1132 //ValidateAndSetProperty(valueDictionary, val => _writerId = int.Parse(val), "writerID"); ValidateAndSetProperty(valueDictionary, val => _creatorId = Int32.Parse(val), "creatorID", "writerID"); //this is a bit of a hack fix for: U4-1132 ValidateAndSetProperty(valueDictionary, val => _path = val, "path", "__Path"); @@ -161,10 +159,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache public override string UrlSegment => _urlName; - public override string WriterName => _creatorName; - - public override string CreatorName => _creatorName; - public override int WriterId => _creatorId; public override int CreatorId => _creatorId; @@ -203,8 +197,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private string _urlName; private string _documentTypeAlias; private int _documentTypeId; - //private string _writerName; - private string _creatorName; //private int _writerId; private int _creatorId; private string _path; diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs index 03f897b0cc..4d6f57f490 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs @@ -61,8 +61,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private string _name; private string _docTypeAlias; private int _docTypeId; - private string _writerName; - private string _creatorName; private int _writerId; private int _creatorId; private string _urlName; @@ -158,24 +156,6 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache public override IReadOnlyDictionary Cultures => _cultures ?? (_cultures = GetCultures()); - public override string WriterName - { - get - { - EnsureNodeInitialized(); - return _writerName; - } - } - - public override string CreatorName - { - get - { - EnsureNodeInitialized(); - return _creatorName; - } - } - public override int WriterId { get @@ -301,8 +281,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private void InitializeNode() { InitializeNode(this, _xmlNode, _isPreviewing, - out _id, out _key, out _template, out _sortOrder, out _name, out _writerName, - out _urlName, out _creatorName, out _creatorId, out _writerId, out _docTypeAlias, out _docTypeId, out _path, + out _id, out _key, out _template, out _sortOrder, out _name, + out _urlName, out _creatorId, out _writerId, out _docTypeAlias, out _docTypeId, out _path, out _createDate, out _updateDate, out _level, out _isDraft, out _contentType, out _properties, _contentTypeCache.Get); @@ -311,18 +291,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache // internal for some benchmarks internal static void InitializeNode(XmlPublishedContent node, XmlNode xmlNode, bool isPreviewing, - out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName, - out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path, + out int id, out Guid key, out int template, out int sortOrder, out string name, out string urlName, + out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path, out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft, out IPublishedContentType contentType, out Dictionary properties, Func getPublishedContentType) { //initialize the out params with defaults: - writerName = null; docTypeAlias = null; id = template = sortOrder = template = creatorId = writerId = docTypeId = level = default(int); key = default(Guid); - name = writerName = urlName = creatorName = docTypeAlias = path = null; + name = docTypeAlias = urlName = path = null; createDate = updateDate = default(DateTime); isDraft = false; contentType = null; @@ -341,12 +320,8 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache sortOrder = int.Parse(xmlNode.Attributes.GetNamedItem("sortOrder").Value); if (xmlNode.Attributes.GetNamedItem("nodeName") != null) name = xmlNode.Attributes.GetNamedItem("nodeName").Value; - if (xmlNode.Attributes.GetNamedItem("writerName") != null) - writerName = xmlNode.Attributes.GetNamedItem("writerName").Value; if (xmlNode.Attributes.GetNamedItem("urlName") != null) urlName = xmlNode.Attributes.GetNamedItem("urlName").Value; - if (xmlNode.Attributes.GetNamedItem("creatorName") != null) - creatorName = xmlNode.Attributes.GetNamedItem("creatorName").Value; //Added the actual userID, as a user cannot be looked up via full name only... if (xmlNode.Attributes.GetNamedItem("creatorID") != null) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs index 0685e2c679..d35cc941da 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs @@ -52,8 +52,8 @@ namespace Umbraco.Tests.PublishedContent {"NodeTypeAlias", "NodeTypeAlias"}, {"CreateDate", "CreateDate"}, {"UpdateDate", "UpdateDate"}, - {"CreatorName", "CreatorName"}, - {"WriterName", "WriterName"}, + {"CreatorId", "CreatorId"}, + {"WriterId", "WriterId"}, {"Url", "Url"} }; foreach (var f in userFields.Where(f => !allFields.ContainsKey(f.Key))) @@ -135,7 +135,6 @@ namespace Umbraco.Tests.PublishedContent { CreateDate = DateTime.Now, CreatorId = 1, - CreatorName = "Shannon", Id = 3, SortOrder = 4, TemplateId = 5, @@ -145,7 +144,6 @@ namespace Umbraco.Tests.PublishedContent Name = "Page" + Guid.NewGuid(), Version = Guid.NewGuid(), WriterId = 1, - WriterName = "Shannon", Parent = null, Level = 1, Children = new List() diff --git a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs index d8dbabb569..f8f7ddae75 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs @@ -59,8 +59,6 @@ namespace Umbraco.Tests.PublishedContent var pc = new Mock(); pc.Setup(content => content.Id).Returns(1); pc.Setup(content => content.Name).Returns("test"); - pc.Setup(content => content.WriterName).Returns("admin"); - pc.Setup(content => content.CreatorName).Returns("admin"); pc.Setup(content => content.CreateDate).Returns(DateTime.Now); pc.Setup(content => content.UpdateDate).Returns(DateTime.Now); pc.Setup(content => content.Path).Returns("-1,1"); diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs index 713acaa5dc..ac550ed75a 100644 --- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs @@ -167,7 +167,6 @@ namespace Umbraco.Tests.PublishedContent { // initialize boring stuff TemplateId = 0; - WriterName = CreatorName = string.Empty; WriterId = CreatorId = 0; CreateDate = UpdateDate = DateTime.Now; Version = Guid.Empty; @@ -193,8 +192,6 @@ namespace Umbraco.Tests.PublishedContent public string Name { get; set; } public IReadOnlyDictionary Cultures => _cultures ?? (_cultures = GetCultures()); public string UrlSegment { get; set; } - public string WriterName { get; set; } - public string CreatorName { get; set; } public int WriterId { get; set; } public int CreatorId { get; set; } public string Path { get; set; } diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs index 077ed80efa..176664b467 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs @@ -101,7 +101,8 @@ namespace Umbraco.Tests.TestHelpers new TestVariationContextAccessor(), container?.TryGetInstance() ?? ServiceContext.CreatePartial(), new ProfilingLogger(Mock.Of(), Mock.Of()), - container?.TryGetInstance() ?? Current.Factory.GetInstance()); + container?.TryGetInstance() ?? Current.Factory.GetInstance(), + Mock.Of()); } } } diff --git a/src/Umbraco.Web/Macros/MacroRenderer.cs b/src/Umbraco.Web/Macros/MacroRenderer.cs index 1b5f907205..d331dfc65f 100755 --- a/src/Umbraco.Web/Macros/MacroRenderer.cs +++ b/src/Umbraco.Web/Macros/MacroRenderer.cs @@ -26,8 +26,9 @@ namespace Umbraco.Web.Macros private readonly ILocalizedTextService _textService; private readonly AppCaches _appCaches; private readonly IMacroService _macroService; + private readonly IUserService _userService; - public MacroRenderer(IProfilingLogger plogger, IUmbracoContextAccessor umbracoContextAccessor, IContentSection contentSection, ILocalizedTextService textService, AppCaches appCaches, IMacroService macroService) + public MacroRenderer(IProfilingLogger plogger, IUmbracoContextAccessor umbracoContextAccessor, IContentSection contentSection, ILocalizedTextService textService, AppCaches appCaches, IMacroService macroService, IUserService userService) { _plogger = plogger ?? throw new ArgumentNullException(nameof(plogger)); _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); @@ -35,6 +36,7 @@ namespace Umbraco.Web.Macros _textService = textService; _appCaches = appCaches ?? throw new ArgumentNullException(nameof(appCaches)); _macroService = macroService ?? throw new ArgumentNullException(nameof(macroService)); + _userService = userService ?? throw new ArgumentNullException(nameof(userService)); } #region MacroContent cache @@ -201,7 +203,7 @@ namespace Umbraco.Web.Macros if (m == null) throw new InvalidOperationException("No macro found by alias " + macroAlias); - var page = new PublishedContentHashtableConverter(content); + var page = new PublishedContentHashtableConverter(content, _userService); var macro = new MacroModel(m); diff --git a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs index be284c1bb3..5e921eb7c2 100644 --- a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs +++ b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs @@ -25,19 +25,20 @@ namespace Umbraco.Web.Macros /// Initializes a new instance of the class for a published document request. /// /// The pointing to the document. + /// The . /// /// The difference between creating the page with PublishedRequest vs an IPublishedContent item is /// that the PublishedRequest takes into account how a template is assigned during the routing process whereas /// with an IPublishedContent item, the template id is assigned purely based on the default. /// - internal PublishedContentHashtableConverter(PublishedRequest frequest) + internal PublishedContentHashtableConverter(PublishedRequest frequest, IUserService userService) { if (!frequest.HasPublishedContent) throw new ArgumentException("Document request has no node.", nameof(frequest)); PopulatePageData(frequest.PublishedContent.Id, frequest.PublishedContent.Name, frequest.PublishedContent.ContentType.Id, frequest.PublishedContent.ContentType.Alias, - frequest.PublishedContent.WriterName, frequest.PublishedContent.CreatorName, frequest.PublishedContent.CreateDate, frequest.PublishedContent.UpdateDate, + frequest.PublishedContent.GetWriterName(userService), frequest.PublishedContent.GetCreatorName(userService), frequest.PublishedContent.CreateDate, frequest.PublishedContent.UpdateDate, frequest.PublishedContent.Path, frequest.PublishedContent.Parent?.Id ?? -1); if (frequest.HasTemplate) @@ -53,13 +54,13 @@ namespace Umbraco.Web.Macros /// Initializes a new instance of the page for a published document /// /// - internal PublishedContentHashtableConverter(IPublishedContent doc) + internal PublishedContentHashtableConverter(IPublishedContent doc, IUserService userService) { if (doc == null) throw new ArgumentNullException(nameof(doc)); PopulatePageData(doc.Id, doc.Name, doc.ContentType.Id, doc.ContentType.Alias, - doc.WriterName, doc.CreatorName, doc.CreateDate, doc.UpdateDate, + doc.GetWriterName(userService), doc.GetCreatorName(userService), doc.CreateDate, doc.UpdateDate, doc.Path, doc.Parent?.Id ?? -1); if (doc.TemplateId.HasValue) @@ -78,7 +79,7 @@ namespace Umbraco.Web.Macros /// /// This is for usage only. internal PublishedContentHashtableConverter(IContent content, IVariationContextAccessor variationContextAccessor, IUserService userService, IShortStringHelper shortStringHelper, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IPublishedContentTypeFactory publishedContentTypeFactory, UrlSegmentProviderCollection urlSegmentProviders) - : this(new PagePublishedContent(content, variationContextAccessor, userService, shortStringHelper, contentTypeBaseServiceProvider, publishedContentTypeFactory, urlSegmentProviders)) + : this(new PagePublishedContent(content, variationContextAccessor, userService, shortStringHelper, contentTypeBaseServiceProvider, publishedContentTypeFactory, urlSegmentProviders), userService) { } #endregion diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index d02e5a3197..0eaabe0ff6 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -1000,15 +1000,15 @@ namespace Umbraco.Web var standardVals = new Dictionary { - { "Id", n.Id }, - { "NodeName", n.Name(VariationContextAccessor) }, - { "NodeTypeAlias", n.ContentType.Alias }, - { "CreateDate", n.CreateDate }, - { "UpdateDate", n.UpdateDate }, - { "CreatorName", n.CreatorName }, - { "WriterName", n.WriterName }, - { "Url", n.Url() } - }; + { "Id", n.Id }, + { "NodeName", n.Name(VariationContextAccessor) }, + { "NodeTypeAlias", n.ContentType.Alias }, + { "CreateDate", n.CreateDate }, + { "UpdateDate", n.UpdateDate }, + { "CreatorId", n.CreatorId}, + { "WriterId", n.WriterId }, + { "Url", n.Url() } + }; var userVals = new Dictionary(); foreach (var p in from IPublishedProperty p in n.Properties where p.GetSourceValue() != null select p) diff --git a/src/Umbraco.Web/Routing/PublishedRouter.cs b/src/Umbraco.Web/Routing/PublishedRouter.cs index 6f146b35dd..9148ce2e31 100644 --- a/src/Umbraco.Web/Routing/PublishedRouter.cs +++ b/src/Umbraco.Web/Routing/PublishedRouter.cs @@ -28,6 +28,7 @@ namespace Umbraco.Web.Routing private readonly IVariationContextAccessor _variationContextAccessor; private readonly ILogger _logger; private readonly IUmbracoSettingsSection _umbracoSettingsSection; + private readonly IUserService _userService; /// /// Initializes a new instance of the class. @@ -39,7 +40,8 @@ namespace Umbraco.Web.Routing IVariationContextAccessor variationContextAccessor, ServiceContext services, IProfilingLogger proflog, - IUmbracoSettingsSection umbracoSettingsSection) + IUmbracoSettingsSection umbracoSettingsSection, + IUserService userService) { _webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection)); _contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders)); @@ -49,6 +51,7 @@ namespace Umbraco.Web.Routing _variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor)); _logger = proflog; _umbracoSettingsSection = umbracoSettingsSection ?? throw new ArgumentNullException(nameof(umbracoSettingsSection)); + _userService = userService ?? throw new ArgumentNullException(nameof(userService)); } /// @@ -194,7 +197,7 @@ namespace Umbraco.Web.Routing // assign the legacy page back to the request // handlers like default.aspx will want it and most macros currently need it - frequest.LegacyContentHashTable = new PublishedContentHashtableConverter(frequest); + frequest.LegacyContentHashTable = new PublishedContentHashtableConverter(frequest, _userService); return true; } @@ -234,8 +237,7 @@ namespace Umbraco.Web.Routing // assign the legacy page back to the docrequest // handlers like default.aspx will want it and most macros currently need it - request.LegacyContentHashTable = new PublishedContentHashtableConverter(request); - + request.LegacyContentHashTable = new PublishedContentHashtableConverter(request, _userService); } #endregion From d1373862e5705966520c51f56c75826a6b965fb6 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 31 Jan 2020 13:09:33 +0100 Subject: [PATCH 03/15] Removed Url property from IPublishedContent and amended usages to use the existing Url() extension method. --- .../Models/PublishedContent/IPublishedContent.cs | 9 --------- .../Models/PublishedContent/PublishedContentBase.cs | 3 --- .../Models/PublishedContent/PublishedContentWrapped.cs | 3 --- .../PublishedContentLanguageVariantTests.cs | 3 --- .../PublishedContent/PublishedContentMoreTests.cs | 3 --- .../PublishedContent/SolidPublishedSnapshot.cs | 1 - src/Umbraco.Web/Controllers/UmbLoginController.cs | 2 +- .../PropertyEditors/RichTextEditorPastedImages.cs | 2 +- 8 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs index d3a87ef3e0..4872d04321 100644 --- a/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/IPublishedContent.cs @@ -80,15 +80,6 @@ namespace Umbraco.Core.Models.PublishedContent /// DateTime UpdateDate { get; } - /// - /// Gets the url of the content item for the current culture. - /// - /// - /// The value of this property is contextual. It depends on the 'current' request uri, - /// if any. - /// - string Url { get; } - /// /// Gets available culture infos. /// diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs index 2aaffbe798..57c116dc54 100644 --- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentBase.cs @@ -69,9 +69,6 @@ namespace Umbraco.Web.Models /// public abstract DateTime UpdateDate { get; } - /// - public virtual string Url => string.Empty; // TODO: get from this.Url(); - /// public abstract IReadOnlyDictionary Cultures { get; } diff --git a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs index 7e6c730a02..88a904bac1 100644 --- a/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs +++ b/src/Umbraco.Abstractions/Models/PublishedContent/PublishedContentWrapped.cs @@ -87,9 +87,6 @@ namespace Umbraco.Core.Models.PublishedContent /// public virtual DateTime UpdateDate => _content.UpdateDate; - /// - public virtual string Url => _content.Url; - /// public IReadOnlyDictionary Cultures => _content.Cultures; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs index 26b56a07d4..99633b141f 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs @@ -128,7 +128,6 @@ namespace Umbraco.Tests.PublishedContent UrlSegment = "content-1", Path = "/1", Level = 1, - Url = "/content-1", ParentId = -1, ChildIds = new[] { 2 }, Properties = new Collection @@ -145,7 +144,6 @@ namespace Umbraco.Tests.PublishedContent UrlSegment = "content-2", Path = "/1/2", Level = 2, - Url = "/content-1/content-2", ParentId = 1, ChildIds = new int[] { 3 }, Properties = new Collection @@ -170,7 +168,6 @@ namespace Umbraco.Tests.PublishedContent UrlSegment = "content-3", Path = "/1/2/3", Level = 3, - Url = "/content-1/content-2/content-3", ParentId = 2, ChildIds = new int[] { }, Properties = new Collection diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs index db5e59c9c0..8f62320a65 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs @@ -35,7 +35,6 @@ namespace Umbraco.Tests.PublishedContent UrlSegment = "content-1", Path = "/1", Level = 1, - Url = "/content-1", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection @@ -59,7 +58,6 @@ namespace Umbraco.Tests.PublishedContent UrlSegment = "content-2", Path = "/2", Level = 1, - Url = "/content-2", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection @@ -83,7 +81,6 @@ namespace Umbraco.Tests.PublishedContent UrlSegment = "content-2sub", Path = "/3", Level = 1, - Url = "/content-2sub", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs index ac550ed75a..2e348fa7e8 100644 --- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs @@ -199,7 +199,6 @@ namespace Umbraco.Tests.PublishedContent public DateTime UpdateDate { get; set; } public Guid Version { get; set; } public int Level { get; set; } - public string Url { get; set; } public PublishedItemType ItemType => PublishedItemType.Content; public bool IsDraft(string culture = null) => false; diff --git a/src/Umbraco.Web/Controllers/UmbLoginController.cs b/src/Umbraco.Web/Controllers/UmbLoginController.cs index 2ff80e2668..88bc17abff 100644 --- a/src/Umbraco.Web/Controllers/UmbLoginController.cs +++ b/src/Umbraco.Web/Controllers/UmbLoginController.cs @@ -46,7 +46,7 @@ namespace Umbraco.Web.Controllers // if it's not a local url we'll redirect to the root of the current site return Redirect(Url.IsLocalUrl(model.RedirectUrl) ? model.RedirectUrl - : CurrentPage.AncestorOrSelf(1).Url); + : CurrentPage.AncestorOrSelf(1).Url()); } //redirect to current page by default diff --git a/src/Umbraco.Web/PropertyEditors/RichTextEditorPastedImages.cs b/src/Umbraco.Web/PropertyEditors/RichTextEditorPastedImages.cs index 80c55e37d4..76e9d9742f 100644 --- a/src/Umbraco.Web/PropertyEditors/RichTextEditorPastedImages.cs +++ b/src/Umbraco.Web/PropertyEditors/RichTextEditorPastedImages.cs @@ -108,7 +108,7 @@ namespace Umbraco.Web.PropertyEditors if (mediaTyped == null) throw new PanicException($"Could not find media by id {udi.Guid} or there was no UmbracoContext available."); - var location = mediaTyped.Url; + var location = mediaTyped.Url(); // Find the width & height attributes as we need to set the imageprocessor QueryString var width = img.GetAttributeValue("width", int.MinValue); From 5ebade460fe72b38be4c5d82bcc26fe6ff08fb06 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 31 Jan 2020 13:21:53 +0100 Subject: [PATCH 04/15] Removed language features not recognised by build checks. --- .../NuCache/PublishedSnapshotService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs index a997b6ab06..5d99aa6aaa 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs @@ -170,8 +170,8 @@ namespace Umbraco.Web.PublishedCache.NuCache internal int GetMediaId(Guid udi) => GetId(_mediaStore, udi); internal Guid GetDocumentUid(int id) => GetUid(_contentStore, id); internal Guid GetMediaUid(int id) => GetUid(_mediaStore, id); - private int GetId(ContentStore store, Guid uid) => store.LiveSnapshot.Get(uid)?.Id ?? default; - private Guid GetUid(ContentStore store, int id) => store.LiveSnapshot.Get(id)?.Uid ?? default; + private int GetId(ContentStore store, Guid uid) => store.LiveSnapshot.Get(uid)?.Id ?? 0; + private Guid GetUid(ContentStore store, int id) => store.LiveSnapshot.Get(id)?.Uid ?? Guid.Empty; #endregion From 45ee8a985dc6024d5b00c05054098b83c1fddb8d Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 31 Jan 2020 13:36:14 +0100 Subject: [PATCH 05/15] Add disambiguity otherwise flagged by build checks. --- .../NuCache/ContentStore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs index 3ee0c3faa8..e84586f415 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs @@ -1329,7 +1329,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return _collectTask; // ReSharper disable InconsistentlySynchronizedField - var task = _collectTask = Task.Run(Collect); + var task = _collectTask = Task.Run((Action)Collect); _collectTask.ContinueWith(_ => { lock (_rlocko) From 9e89e184928ec9d0e87492fc9b156fe87b9ca08b Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 31 Jan 2020 15:33:31 +0100 Subject: [PATCH 06/15] Migrated various IPublishedContent extension methods from web to core, removin use of service location. Kept the original methods passing through to the core ones, providing the service located dependencies. Used one of these migrated methods in the Umbraco.Infrastructure.PublishedCache project. --- .../PublishedContentExtensions.cs | 713 +++++++++++++++++- .../PublishedElementExtensions.cs | 27 + .../PublishedCacheBase.cs | 16 +- src/Umbraco.Web/PublishedContentExtensions.cs | 453 +---------- src/Umbraco.Web/PublishedElementExtensions.cs | 14 - .../Routing/RedirectTrackingComponent.cs | 1 + 6 files changed, 783 insertions(+), 441 deletions(-) create mode 100644 src/Umbraco.Abstractions/PublishedElementExtensions.cs diff --git a/src/Umbraco.Abstractions/PublishedContentExtensions.cs b/src/Umbraco.Abstractions/PublishedContentExtensions.cs index 11444a274b..53618ea632 100644 --- a/src/Umbraco.Abstractions/PublishedContentExtensions.cs +++ b/src/Umbraco.Abstractions/PublishedContentExtensions.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Umbraco.Core.Composing; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; +using Umbraco.Web.PublishedCache; namespace Umbraco.Core { @@ -101,7 +101,6 @@ namespace Umbraco.Core return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Date : DateTime.MinValue; } - /// /// Gets the children of the content item. /// @@ -137,6 +136,8 @@ namespace Umbraco.Core : children.Where(x => x.IsInvariantOrHasCulture(culture)); } + #region Writer and creator + public static string GetCreatorName(this IPublishedContent content, IUserService userService) { var user = userService.GetProfileById(content.CreatorId); @@ -148,5 +149,713 @@ namespace Umbraco.Core var user = userService.GetProfileById(content.WriterId); return user?.Name; } + + #endregion + + #region Axes: ancestors, ancestors-or-self + + // as per XPath 1.0 specs �2.2, + // - the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist + // of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always + // include the root node, unless the context node is the root node. + // - the ancestor-or-self axis contains the context node and the ancestors of the context node; thus, + // the ancestor axis will always include the root node. + // + // as per XPath 2.0 specs �3.2.1.1, + // - the ancestor axis is defined as the transitive closure of the parent axis; it contains the ancestors + // of the context node (the parent, the parent of the parent, and so on) - The ancestor axis includes the + // root node of the tree in which the context node is found, unless the context node is the root node. + // - the ancestor-or-self axis contains the context node and the ancestors of the context node; thus, + // the ancestor-or-self axis will always include the root node. + // + // the ancestor and ancestor-or-self axis are reverse axes ie they contain the context node or nodes that + // are before the context node in document order. + // + // document order is defined by �2.4.1 as: + // - the root node is the first node. + // - every node occurs before all of its children and descendants. + // - the relative order of siblings is the order in which they occur in the children property of their parent node. + // - children and descendants occur before following siblings. + + /// + /// Gets the ancestors of the content. + /// + /// The content. + /// The ancestors of the content, in down-top order. + /// Does not consider the content itself. + public static IEnumerable Ancestors(this IPublishedContent content) + { + return content.AncestorsOrSelf(false, null); + } + + /// + /// Gets the ancestors of the content, at a level lesser or equal to a specified level. + /// + /// The content. + /// The level. + /// The ancestors of the content, at a level lesser or equal to the specified level, in down-top order. + /// Does not consider the content itself. Only content that are "high enough" in the tree are returned. + public static IEnumerable Ancestors(this IPublishedContent content, int maxLevel) + { + return content.AncestorsOrSelf(false, n => n.Level <= maxLevel); + } + + /// + /// Gets the ancestors of the content, of a specified content type. + /// + /// The content. + /// The content type. + /// The ancestors of the content, of the specified content type, in down-top order. + /// Does not consider the content itself. Returns all ancestors, of the specified content type. + public static IEnumerable Ancestors(this IPublishedContent content, string contentTypeAlias) + { + return content.AncestorsOrSelf(false, n => n.ContentType.Alias.InvariantEquals(contentTypeAlias)); + } + + /// + /// Gets the ancestors of the content, of a specified content type. + /// + /// The content type. + /// The content. + /// The ancestors of the content, of the specified content type, in down-top order. + /// Does not consider the content itself. Returns all ancestors, of the specified content type. + public static IEnumerable Ancestors(this IPublishedContent content) + where T : class, IPublishedContent + { + return content.Ancestors().OfType(); + } + + /// + /// Gets the ancestors of the content, at a level lesser or equal to a specified level, and of a specified content type. + /// + /// The content type. + /// The content. + /// The level. + /// The ancestors of the content, at a level lesser or equal to the specified level, and of the specified + /// content type, in down-top order. + /// Does not consider the content itself. Only content that are "high enough" in the trees, and of the + /// specified content type, are returned. + public static IEnumerable Ancestors(this IPublishedContent content, int maxLevel) + where T : class, IPublishedContent + { + return content.Ancestors(maxLevel).OfType(); + } + + /// + /// Gets the content and its ancestors. + /// + /// The content. + /// The content and its ancestors, in down-top order. + public static IEnumerable AncestorsOrSelf(this IPublishedContent content) + { + return content.AncestorsOrSelf(true, null); + } + + /// + /// Gets the content and its ancestors, at a level lesser or equal to a specified level. + /// + /// The content. + /// The level. + /// The content and its ancestors, at a level lesser or equal to the specified level, + /// in down-top order. + /// Only content that are "high enough" in the tree are returned. So it may or may not begin + /// with the content itself, depending on its level. + public static IEnumerable AncestorsOrSelf(this IPublishedContent content, int maxLevel) + { + return content.AncestorsOrSelf(true, n => n.Level <= maxLevel); + } + + /// + /// Gets the content and its ancestors, of a specified content type. + /// + /// The content. + /// The content type. + /// The content and its ancestors, of the specified content type, in down-top order. + /// May or may not begin with the content itself, depending on its content type. + public static IEnumerable AncestorsOrSelf(this IPublishedContent content, string contentTypeAlias) + { + return content.AncestorsOrSelf(true, n => n.ContentType.Alias.InvariantEquals(contentTypeAlias)); + } + + /// + /// Gets the content and its ancestors, of a specified content type. + /// + /// The content type. + /// The content. + /// The content and its ancestors, of the specified content type, in down-top order. + /// May or may not begin with the content itself, depending on its content type. + public static IEnumerable AncestorsOrSelf(this IPublishedContent content) + where T : class, IPublishedContent + { + return content.AncestorsOrSelf().OfType(); + } + + /// + /// Gets the content and its ancestor, at a lever lesser or equal to a specified level, and of a specified content type. + /// + /// The content type. + /// The content. + /// The level. + /// The content and its ancestors, at a level lesser or equal to the specified level, and of the specified + /// content type, in down-top order. + /// May or may not begin with the content itself, depending on its level and content type. + public static IEnumerable AncestorsOrSelf(this IPublishedContent content, int maxLevel) + where T : class, IPublishedContent + { + return content.AncestorsOrSelf(maxLevel).OfType(); + } + + /// + /// Gets the ancestor of the content, ie its parent. + /// + /// The content. + /// The ancestor of the content. + /// This method is here for consistency purposes but does not make much sense. + public static IPublishedContent Ancestor(this IPublishedContent content) + { + return content.Parent; + } + + /// + /// Gets the nearest ancestor of the content, at a lever lesser or equal to a specified level. + /// + /// The content. + /// The level. + /// The nearest (in down-top order) ancestor of the content, at a level lesser or equal to the specified level. + /// Does not consider the content itself. May return null. + public static IPublishedContent Ancestor(this IPublishedContent content, int maxLevel) + { + return content.EnumerateAncestors(false).FirstOrDefault(x => x.Level <= maxLevel); + } + + /// + /// Gets the nearest ancestor of the content, of a specified content type. + /// + /// The content. + /// The content type alias. + /// The nearest (in down-top order) ancestor of the content, of the specified content type. + /// Does not consider the content itself. May return null. + public static IPublishedContent Ancestor(this IPublishedContent content, string contentTypeAlias) + { + return content.EnumerateAncestors(false).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); + } + + /// + /// Gets the nearest ancestor of the content, of a specified content type. + /// + /// The content type. + /// The content. + /// The nearest (in down-top order) ancestor of the content, of the specified content type. + /// Does not consider the content itself. May return null. + public static T Ancestor(this IPublishedContent content) + where T : class, IPublishedContent + { + return content.Ancestors().FirstOrDefault(); + } + + /// + /// Gets the nearest ancestor of the content, at the specified level and of the specified content type. + /// + /// The content type. + /// The content. + /// The level. + /// The ancestor of the content, at the specified level and of the specified content type. + /// Does not consider the content itself. If the ancestor at the specified level is + /// not of the specified type, returns null. + public static T Ancestor(this IPublishedContent content, int maxLevel) + where T : class, IPublishedContent + { + return content.Ancestors(maxLevel).FirstOrDefault(); + } + + /// + /// Gets the content or its nearest ancestor. + /// + /// The content. + /// The content. + /// This method is here for consistency purposes but does not make much sense. + public static IPublishedContent AncestorOrSelf(this IPublishedContent content) + { + return content; + } + + /// + /// Gets the content or its nearest ancestor, at a lever lesser or equal to a specified level. + /// + /// The content. + /// The level. + /// The content or its nearest (in down-top order) ancestor, at a level lesser or equal to the specified level. + /// May or may not return the content itself depending on its level. May return null. + public static IPublishedContent AncestorOrSelf(this IPublishedContent content, int maxLevel) + { + return content.EnumerateAncestors(true).FirstOrDefault(x => x.Level <= maxLevel); + } + + /// + /// Gets the content or its nearest ancestor, of a specified content type. + /// + /// The content. + /// The content type. + /// The content or its nearest (in down-top order) ancestor, of the specified content type. + /// May or may not return the content itself depending on its content type. May return null. + public static IPublishedContent AncestorOrSelf(this IPublishedContent content, string contentTypeAlias) + { + return content.EnumerateAncestors(true).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); + } + + /// + /// Gets the content or its nearest ancestor, of a specified content type. + /// + /// The content type. + /// The content. + /// The content or its nearest (in down-top order) ancestor, of the specified content type. + /// May or may not return the content itself depending on its content type. May return null. + public static T AncestorOrSelf(this IPublishedContent content) + where T : class, IPublishedContent + { + return content.AncestorsOrSelf().FirstOrDefault(); + } + + /// + /// Gets the content or its nearest ancestor, at a lever lesser or equal to a specified level, and of a specified content type. + /// + /// The content type. + /// The content. + /// The level. + /// + public static T AncestorOrSelf(this IPublishedContent content, int maxLevel) + where T : class, IPublishedContent + { + return content.AncestorsOrSelf(maxLevel).FirstOrDefault(); + } + + public static IEnumerable AncestorsOrSelf(this IPublishedContent content, bool orSelf, Func func) + { + var ancestorsOrSelf = content.EnumerateAncestors(orSelf); + return func == null ? ancestorsOrSelf : ancestorsOrSelf.Where(func); + } + + /// + /// Enumerates ancestors of the content, bottom-up. + /// + /// The content. + /// Indicates whether the content should be included. + /// Enumerates bottom-up ie walking up the tree (parent, grand-parent, etc). + internal static IEnumerable EnumerateAncestors(this IPublishedContent content, bool orSelf) + { + if (content == null) throw new ArgumentNullException(nameof(content)); + if (orSelf) yield return content; + while ((content = content.Parent) != null) + yield return content; + } + + #endregion + + #region Axes: descendants, descendants-or-self + + /// + /// Returns all DescendantsOrSelf of all content referenced + /// + /// + /// Variation context accessor. + /// + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// + /// + /// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot + /// + public static IEnumerable DescendantsOrSelfOfType(this IEnumerable parentNodes, IVariationContextAccessor variationContextAccessor, string docTypeAlias, string culture = null) + { + return parentNodes.SelectMany(x => x.DescendantsOrSelfOfType(variationContextAccessor, docTypeAlias, culture)); + } + + /// + /// Returns all DescendantsOrSelf of all content referenced + /// + /// + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// + /// + /// This can be useful in order to return all nodes in an entire site by a type when combined with TypedContentAtRoot + /// + public static IEnumerable DescendantsOrSelf(this IEnumerable parentNodes, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return parentNodes.SelectMany(x => x.DescendantsOrSelf(variationContextAccessor, culture)); + } + + + // as per XPath 1.0 specs �2.2, + // - the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on; thus + // the descendant axis never contains attribute or namespace nodes. + // - the descendant-or-self axis contains the context node and the descendants of the context node. + // + // as per XPath 2.0 specs �3.2.1.1, + // - the descendant axis is defined as the transitive closure of the child axis; it contains the descendants of the context node (the + // children, the children of the children, and so on). + // - the descendant-or-self axis contains the context node and the descendants of the context node. + // + // the descendant and descendant-or-self axis are forward axes ie they contain the context node or nodes that are after the context + // node in document order. + // + // document order is defined by �2.4.1 as: + // - the root node is the first node. + // - every node occurs before all of its children and descendants. + // - the relative order of siblings is the order in which they occur in the children property of their parent node. + // - children and descendants occur before following siblings. + + public static IEnumerable Descendants(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return content.DescendantsOrSelf(variationContextAccessor, false, null, culture); + } + + public static IEnumerable Descendants(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + { + return content.DescendantsOrSelf(variationContextAccessor, false, p => p.Level >= level, culture); + } + + public static IEnumerable DescendantsOfType(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.DescendantsOrSelf(variationContextAccessor, false, p => p.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); + } + + public static IEnumerable Descendants(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.Descendants(variationContextAccessor, culture).OfType(); + } + + public static IEnumerable Descendants(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + where T : class, IPublishedContent + { + return content.Descendants(variationContextAccessor, level, culture).OfType(); + } + + public static IEnumerable DescendantsOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return content.DescendantsOrSelf(variationContextAccessor, true, null, culture); + } + + public static IEnumerable DescendantsOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + { + return content.DescendantsOrSelf(variationContextAccessor, true, p => p.Level >= level, culture); + } + + public static IEnumerable DescendantsOrSelfOfType(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.DescendantsOrSelf(variationContextAccessor, true, p => p.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); + } + + public static IEnumerable DescendantsOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.DescendantsOrSelf(variationContextAccessor, culture).OfType(); + } + + public static IEnumerable DescendantsOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + where T : class, IPublishedContent + { + return content.DescendantsOrSelf(variationContextAccessor, level, culture).OfType(); + } + + public static IPublishedContent Descendant(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return content.Children(variationContextAccessor, culture).FirstOrDefault(); + } + + public static IPublishedContent Descendant(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + { + return content.EnumerateDescendants(variationContextAccessor, false, culture).FirstOrDefault(x => x.Level == level); + } + + public static IPublishedContent DescendantOfType(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.EnumerateDescendants(variationContextAccessor, false, culture).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); + } + + public static T Descendant(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.EnumerateDescendants(variationContextAccessor, false, culture).FirstOrDefault(x => x is T) as T; + } + + public static T Descendant(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + where T : class, IPublishedContent + { + return content.Descendant(variationContextAccessor, level, culture) as T; + } + + public static IPublishedContent DescendantOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return content; + } + + public static IPublishedContent DescendantOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + { + return content.EnumerateDescendants(variationContextAccessor, true, culture).FirstOrDefault(x => x.Level == level); + } + + public static IPublishedContent DescendantOrSelfOfType(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.EnumerateDescendants(variationContextAccessor, true, culture).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); + } + + public static T DescendantOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.EnumerateDescendants(variationContextAccessor, true, culture).FirstOrDefault(x => x is T) as T; + } + + public static T DescendantOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, int level, string culture = null) + where T : class, IPublishedContent + { + return content.DescendantOrSelf(variationContextAccessor, level, culture) as T; + } + + internal static IEnumerable DescendantsOrSelf(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, bool orSelf, Func func, string culture = null) + { + return content.EnumerateDescendants(variationContextAccessor, orSelf, culture).Where(x => func == null || func(x)); + } + + internal static IEnumerable EnumerateDescendants(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, bool orSelf, string culture = null) + { + if (content == null) throw new ArgumentNullException(nameof(content)); + if (orSelf) yield return content; + + foreach (var desc in content.Children(variationContextAccessor, culture).SelectMany(x => x.EnumerateDescendants(variationContextAccessor, culture))) + yield return desc; + } + + internal static IEnumerable EnumerateDescendants(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + { + yield return content; + + foreach (var desc in content.Children(variationContextAccessor, culture).SelectMany(x => x.EnumerateDescendants(variationContextAccessor, culture))) + yield return desc; + } + + #endregion + + #region Axes: children + + /// + /// Gets the children of the content, filtered by a predicate. + /// + /// The content. + /// Published snapshot instance + /// The predicate. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The children of the content, filtered by the predicate. + /// + /// Children are sorted by their sortOrder. + /// + public static IEnumerable Children(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, Func predicate, string culture = null) + { + return content.Children(variationContextAccessor, culture).Where(predicate); + } + + /// + /// Gets the children of the content, of any of the specified types. + /// + /// The content. + /// Published snapshot instance + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The content type alias. + /// The children of the content, of any of the specified types. + public static IEnumerable ChildrenOfType(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.Children(variationContextAccessor, x => x.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); + } + + /// + /// Gets the children of the content, of a given content type. + /// + /// The content type. + /// The content. + /// Published snapshot instance + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The children of content, of the given content type. + /// + /// Children are sorted by their sortOrder. + /// + public static IEnumerable Children(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.Children(variationContextAccessor, culture).OfType(); + } + + public static IPublishedContent FirstChild(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return content.Children(variationContextAccessor, culture).FirstOrDefault(); + } + + /// + /// Gets the first child of the content, of a given content type. + /// + public static IPublishedContent FirstChildOfType(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.ChildrenOfType(variationContextAccessor, contentTypeAlias, culture).FirstOrDefault(); + } + + public static IPublishedContent FirstChild(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, Func predicate, string culture = null) + { + return content.Children(variationContextAccessor, predicate, culture).FirstOrDefault(); + } + + public static IPublishedContent FirstChild(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, Guid uniqueId, string culture = null) + { + return content.Children(variationContextAccessor, x => x.Key == uniqueId, culture).FirstOrDefault(); + } + + public static T FirstChild(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.Children(variationContextAccessor, culture).FirstOrDefault(); + } + + public static T FirstChild(this IPublishedContent content, IVariationContextAccessor variationContextAccessor, Func predicate, string culture = null) + where T : class, IPublishedContent + { + return content.Children(variationContextAccessor, culture).FirstOrDefault(predicate); + } + + #endregion + + #region Axes: parent + + // Parent is native + + /// + /// Gets the parent of the content, of a given content type. + /// + /// The content type. + /// The content. + /// The parent of content, of the given content type, else null. + public static T Parent(this IPublishedContent content) + where T : class, IPublishedContent + { + if (content == null) throw new ArgumentNullException(nameof(content)); + return content.Parent as T; + } + + #endregion + + #region Axes: Siblings + + /// + /// Gets the siblings of the content. + /// + /// The content. + /// Published snapshot instance + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The siblings of the content. + /// + /// Note that in V7 this method also return the content node self. + /// + public static IEnumerable Siblings(this IPublishedContent content, IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return SiblingsAndSelf(content, publishedSnapshot, variationContextAccessor, culture).Where(x => x.Id != content.Id); + } + + /// + /// Gets the siblings of the content, of a given content type. + /// + /// The content. + /// Published snapshot instance + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The content type alias. + /// The siblings of the content, of the given content type. + /// + /// Note that in V7 this method also return the content node self. + /// + public static IEnumerable SiblingsOfType(this IPublishedContent content, IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return SiblingsAndSelfOfType(content, publishedSnapshot, variationContextAccessor, contentTypeAlias, culture).Where(x => x.Id != content.Id); + } + + /// + /// Gets the siblings of the content, of a given content type. + /// + /// The content type. + /// The content. + /// Published snapshot instance + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The siblings of the content, of the given content type. + /// + /// Note that in V7 this method also return the content node self. + /// + public static IEnumerable Siblings(this IPublishedContent content, IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return SiblingsAndSelf(content, publishedSnapshot, variationContextAccessor, culture).Where(x => x.Id != content.Id); + } + + /// + /// Gets the siblings of the content including the node itself to indicate the position. + /// + /// The content. + /// Published snapshot instance + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The siblings of the content including the node itself. + public static IEnumerable SiblingsAndSelf(this IPublishedContent content, IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, string culture = null) + { + return content.Parent != null + ? content.Parent.Children(variationContextAccessor, culture) + : publishedSnapshot.Content.GetAtRoot().WhereIsInvariantOrHasCulture(variationContextAccessor, culture); + } + + /// + /// Gets the siblings of the content including the node itself to indicate the position, of a given content type. + /// + /// The content. + /// Published snapshot instance + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The content type alias. + /// The siblings of the content including the node itself, of the given content type. + public static IEnumerable SiblingsAndSelfOfType(this IPublishedContent content, IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, string contentTypeAlias, string culture = null) + { + return content.Parent != null + ? content.Parent.ChildrenOfType(variationContextAccessor, contentTypeAlias, culture) + : publishedSnapshot.Content.GetAtRoot().OfTypes(contentTypeAlias).WhereIsInvariantOrHasCulture(variationContextAccessor, culture); + } + + /// + /// Gets the siblings of the content including the node itself to indicate the position, of a given content type. + /// + /// The content type. + /// The content. + /// Published snapshot instance + /// Variation context accessor. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null) + /// The siblings of the content including the node itself, of the given content type. + public static IEnumerable SiblingsAndSelf(this IPublishedContent content, IPublishedSnapshot publishedSnapshot, IVariationContextAccessor variationContextAccessor, string culture = null) + where T : class, IPublishedContent + { + return content.Parent != null + ? content.Parent.Children(variationContextAccessor, culture) + : publishedSnapshot.Content.GetAtRoot().OfType().WhereIsInvariantOrHasCulture(variationContextAccessor, culture); + } + + #endregion + + #region Axes: custom + + /// + /// Gets the root content for this content. + /// + /// The content. + /// The 'site' content ie AncestorOrSelf(1). + public static IPublishedContent Root(this IPublishedContent content) + { + return content.AncestorOrSelf(1); + } + + #endregion } } diff --git a/src/Umbraco.Abstractions/PublishedElementExtensions.cs b/src/Umbraco.Abstractions/PublishedElementExtensions.cs new file mode 100644 index 0000000000..77b6b1516a --- /dev/null +++ b/src/Umbraco.Abstractions/PublishedElementExtensions.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.Linq; +using Umbraco.Core; +using Umbraco.Core.Models.PublishedContent; + +namespace Umbraco.Core +{ + /// + /// Provides extension methods for IPublishedElement. + /// + public static class PublishedElementExtensions + { + #region OfTypes + + // the .OfType() filter is nice when there's only one type + // this is to support filtering with multiple types + public static IEnumerable OfTypes(this IEnumerable contents, params string[] types) + where T : IPublishedElement + { + if (types == null || types.Length == 0) return Enumerable.Empty(); + + return contents.Where(x => types.InvariantContains(x.ContentType.Alias)); + } + + #endregion + } +} diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs index 50ee48e1ba..28bc218f54 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs @@ -10,6 +10,13 @@ namespace Umbraco.Web.PublishedCache { abstract class PublishedCacheBase : IPublishedCache { + private readonly IVariationContextAccessor _variationContextAccessor; + + public PublishedCacheBase(IVariationContextAccessor variationContextAccessor) + { + _variationContextAccessor = variationContextAccessor ?? throw new ArgumentNullException(nameof(variationContextAccessor)); + + } public bool PreviewDefault { get; } protected PublishedCacheBase(bool previewDefault) @@ -94,14 +101,11 @@ namespace Umbraco.Web.PublishedCache public virtual IEnumerable GetByContentType(IPublishedContentType contentType) { - // TODO: move this extension method and get working again. - // this is probably not super-efficient, but works // some cache implementation may want to override it, though - return Enumerable.Empty(); - //return GetAtRoot() - // .SelectMany(x => x.DescendantsOrSelf()) - // .Where(x => x.ContentType.Id == contentType.Id); + return GetAtRoot() + .SelectMany(x => x.DescendantsOrSelf(_variationContextAccessor)) + .Where(x => x.ContentType.Id == contentType.Id); } } } diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 0eaabe0ff6..fe42d5a165 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -365,305 +365,6 @@ namespace Umbraco.Web #endregion - #region Axes: ancestors, ancestors-or-self - - // as per XPath 1.0 specs �2.2, - // - the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist - // of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always - // include the root node, unless the context node is the root node. - // - the ancestor-or-self axis contains the context node and the ancestors of the context node; thus, - // the ancestor axis will always include the root node. - // - // as per XPath 2.0 specs �3.2.1.1, - // - the ancestor axis is defined as the transitive closure of the parent axis; it contains the ancestors - // of the context node (the parent, the parent of the parent, and so on) - The ancestor axis includes the - // root node of the tree in which the context node is found, unless the context node is the root node. - // - the ancestor-or-self axis contains the context node and the ancestors of the context node; thus, - // the ancestor-or-self axis will always include the root node. - // - // the ancestor and ancestor-or-self axis are reverse axes ie they contain the context node or nodes that - // are before the context node in document order. - // - // document order is defined by �2.4.1 as: - // - the root node is the first node. - // - every node occurs before all of its children and descendants. - // - the relative order of siblings is the order in which they occur in the children property of their parent node. - // - children and descendants occur before following siblings. - - /// - /// Gets the ancestors of the content. - /// - /// The content. - /// The ancestors of the content, in down-top order. - /// Does not consider the content itself. - public static IEnumerable Ancestors(this IPublishedContent content) - { - return content.AncestorsOrSelf(false, null); - } - - /// - /// Gets the ancestors of the content, at a level lesser or equal to a specified level. - /// - /// The content. - /// The level. - /// The ancestors of the content, at a level lesser or equal to the specified level, in down-top order. - /// Does not consider the content itself. Only content that are "high enough" in the tree are returned. - public static IEnumerable Ancestors(this IPublishedContent content, int maxLevel) - { - return content.AncestorsOrSelf(false, n => n.Level <= maxLevel); - } - - /// - /// Gets the ancestors of the content, of a specified content type. - /// - /// The content. - /// The content type. - /// The ancestors of the content, of the specified content type, in down-top order. - /// Does not consider the content itself. Returns all ancestors, of the specified content type. - public static IEnumerable Ancestors(this IPublishedContent content, string contentTypeAlias) - { - return content.AncestorsOrSelf(false, n => n.ContentType.Alias.InvariantEquals(contentTypeAlias)); - } - - /// - /// Gets the ancestors of the content, of a specified content type. - /// - /// The content type. - /// The content. - /// The ancestors of the content, of the specified content type, in down-top order. - /// Does not consider the content itself. Returns all ancestors, of the specified content type. - public static IEnumerable Ancestors(this IPublishedContent content) - where T : class, IPublishedContent - { - return content.Ancestors().OfType(); - } - - /// - /// Gets the ancestors of the content, at a level lesser or equal to a specified level, and of a specified content type. - /// - /// The content type. - /// The content. - /// The level. - /// The ancestors of the content, at a level lesser or equal to the specified level, and of the specified - /// content type, in down-top order. - /// Does not consider the content itself. Only content that are "high enough" in the trees, and of the - /// specified content type, are returned. - public static IEnumerable Ancestors(this IPublishedContent content, int maxLevel) - where T : class, IPublishedContent - { - return content.Ancestors(maxLevel).OfType(); - } - - /// - /// Gets the content and its ancestors. - /// - /// The content. - /// The content and its ancestors, in down-top order. - public static IEnumerable AncestorsOrSelf(this IPublishedContent content) - { - return content.AncestorsOrSelf(true, null); - } - - /// - /// Gets the content and its ancestors, at a level lesser or equal to a specified level. - /// - /// The content. - /// The level. - /// The content and its ancestors, at a level lesser or equal to the specified level, - /// in down-top order. - /// Only content that are "high enough" in the tree are returned. So it may or may not begin - /// with the content itself, depending on its level. - public static IEnumerable AncestorsOrSelf(this IPublishedContent content, int maxLevel) - { - return content.AncestorsOrSelf(true, n => n.Level <= maxLevel); - } - - /// - /// Gets the content and its ancestors, of a specified content type. - /// - /// The content. - /// The content type. - /// The content and its ancestors, of the specified content type, in down-top order. - /// May or may not begin with the content itself, depending on its content type. - public static IEnumerable AncestorsOrSelf(this IPublishedContent content, string contentTypeAlias) - { - return content.AncestorsOrSelf(true, n => n.ContentType.Alias.InvariantEquals(contentTypeAlias)); - } - - /// - /// Gets the content and its ancestors, of a specified content type. - /// - /// The content type. - /// The content. - /// The content and its ancestors, of the specified content type, in down-top order. - /// May or may not begin with the content itself, depending on its content type. - public static IEnumerable AncestorsOrSelf(this IPublishedContent content) - where T : class, IPublishedContent - { - return content.AncestorsOrSelf().OfType(); - } - - /// - /// Gets the content and its ancestor, at a lever lesser or equal to a specified level, and of a specified content type. - /// - /// The content type. - /// The content. - /// The level. - /// The content and its ancestors, at a level lesser or equal to the specified level, and of the specified - /// content type, in down-top order. - /// May or may not begin with the content itself, depending on its level and content type. - public static IEnumerable AncestorsOrSelf(this IPublishedContent content, int maxLevel) - where T : class, IPublishedContent - { - return content.AncestorsOrSelf(maxLevel).OfType(); - } - - /// - /// Gets the ancestor of the content, ie its parent. - /// - /// The content. - /// The ancestor of the content. - /// This method is here for consistency purposes but does not make much sense. - public static IPublishedContent Ancestor(this IPublishedContent content) - { - return content.Parent; - } - - /// - /// Gets the nearest ancestor of the content, at a lever lesser or equal to a specified level. - /// - /// The content. - /// The level. - /// The nearest (in down-top order) ancestor of the content, at a level lesser or equal to the specified level. - /// Does not consider the content itself. May return null. - public static IPublishedContent Ancestor(this IPublishedContent content, int maxLevel) - { - return content.EnumerateAncestors(false).FirstOrDefault(x => x.Level <= maxLevel); - } - - /// - /// Gets the nearest ancestor of the content, of a specified content type. - /// - /// The content. - /// The content type alias. - /// The nearest (in down-top order) ancestor of the content, of the specified content type. - /// Does not consider the content itself. May return null. - public static IPublishedContent Ancestor(this IPublishedContent content, string contentTypeAlias) - { - return content.EnumerateAncestors(false).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); - } - - /// - /// Gets the nearest ancestor of the content, of a specified content type. - /// - /// The content type. - /// The content. - /// The nearest (in down-top order) ancestor of the content, of the specified content type. - /// Does not consider the content itself. May return null. - public static T Ancestor(this IPublishedContent content) - where T : class, IPublishedContent - { - return content.Ancestors().FirstOrDefault(); - } - - /// - /// Gets the nearest ancestor of the content, at the specified level and of the specified content type. - /// - /// The content type. - /// The content. - /// The level. - /// The ancestor of the content, at the specified level and of the specified content type. - /// Does not consider the content itself. If the ancestor at the specified level is - /// not of the specified type, returns null. - public static T Ancestor(this IPublishedContent content, int maxLevel) - where T : class, IPublishedContent - { - return content.Ancestors(maxLevel).FirstOrDefault(); - } - - /// - /// Gets the content or its nearest ancestor. - /// - /// The content. - /// The content. - /// This method is here for consistency purposes but does not make much sense. - public static IPublishedContent AncestorOrSelf(this IPublishedContent content) - { - return content; - } - - /// - /// Gets the content or its nearest ancestor, at a lever lesser or equal to a specified level. - /// - /// The content. - /// The level. - /// The content or its nearest (in down-top order) ancestor, at a level lesser or equal to the specified level. - /// May or may not return the content itself depending on its level. May return null. - public static IPublishedContent AncestorOrSelf(this IPublishedContent content, int maxLevel) - { - return content.EnumerateAncestors(true).FirstOrDefault(x => x.Level <= maxLevel); - } - - /// - /// Gets the content or its nearest ancestor, of a specified content type. - /// - /// The content. - /// The content type. - /// The content or its nearest (in down-top order) ancestor, of the specified content type. - /// May or may not return the content itself depending on its content type. May return null. - public static IPublishedContent AncestorOrSelf(this IPublishedContent content, string contentTypeAlias) - { - return content.EnumerateAncestors(true).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); - } - - /// - /// Gets the content or its nearest ancestor, of a specified content type. - /// - /// The content type. - /// The content. - /// The content or its nearest (in down-top order) ancestor, of the specified content type. - /// May or may not return the content itself depending on its content type. May return null. - public static T AncestorOrSelf(this IPublishedContent content) - where T : class, IPublishedContent - { - return content.AncestorsOrSelf().FirstOrDefault(); - } - - /// - /// Gets the content or its nearest ancestor, at a lever lesser or equal to a specified level, and of a specified content type. - /// - /// The content type. - /// The content. - /// The level. - /// - public static T AncestorOrSelf(this IPublishedContent content, int maxLevel) - where T : class, IPublishedContent - { - return content.AncestorsOrSelf(maxLevel).FirstOrDefault(); - } - - public static IEnumerable AncestorsOrSelf(this IPublishedContent content, bool orSelf, Func func) - { - var ancestorsOrSelf = content.EnumerateAncestors(orSelf); - return func == null ? ancestorsOrSelf : ancestorsOrSelf.Where(func); - } - - /// - /// Enumerates ancestors of the content, bottom-up. - /// - /// The content. - /// Indicates whether the content should be included. - /// Enumerates bottom-up ie walking up the tree (parent, grand-parent, etc). - internal static IEnumerable EnumerateAncestors(this IPublishedContent content, bool orSelf) - { - if (content == null) throw new ArgumentNullException(nameof(content)); - if (orSelf) yield return content; - while ((content = content.Parent) != null) - yield return content; - } - - #endregion - #region Axes: descendants, descendants-or-self /// @@ -678,7 +379,7 @@ namespace Umbraco.Web /// public static IEnumerable DescendantsOrSelfOfType(this IEnumerable parentNodes, string docTypeAlias, string culture = null) { - return parentNodes.SelectMany(x => x.DescendantsOrSelfOfType(docTypeAlias, culture)); + return parentNodes.DescendantsOrSelfOfType(VariationContextAccessor, docTypeAlias, culture); } /// @@ -693,176 +394,110 @@ namespace Umbraco.Web public static IEnumerable DescendantsOrSelf(this IEnumerable parentNodes, string culture = null) where T : class, IPublishedContent { - return parentNodes.SelectMany(x => x.DescendantsOrSelf(culture)); + return parentNodes.DescendantsOrSelf(VariationContextAccessor, culture); } - - - // as per XPath 1.0 specs �2.2, - // - the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on; thus - // the descendant axis never contains attribute or namespace nodes. - // - the descendant-or-self axis contains the context node and the descendants of the context node. - // - // as per XPath 2.0 specs �3.2.1.1, - // - the descendant axis is defined as the transitive closure of the child axis; it contains the descendants of the context node (the - // children, the children of the children, and so on). - // - the descendant-or-self axis contains the context node and the descendants of the context node. - // - // the descendant and descendant-or-self axis are forward axes ie they contain the context node or nodes that are after the context - // node in document order. - // - // document order is defined by �2.4.1 as: - // - the root node is the first node. - // - every node occurs before all of its children and descendants. - // - the relative order of siblings is the order in which they occur in the children property of their parent node. - // - children and descendants occur before following siblings. - + public static IEnumerable Descendants(this IPublishedContent content, string culture = null) { - return content.DescendantsOrSelf(false, null, culture); + return content.Descendants(VariationContextAccessor, culture); } public static IEnumerable Descendants(this IPublishedContent content, int level, string culture = null) { - return content.DescendantsOrSelf(false, p => p.Level >= level, culture); + return content.Descendants(VariationContextAccessor, level, culture); } public static IEnumerable DescendantsOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.DescendantsOrSelf(false, p => p.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); + return content.DescendantsOfType(VariationContextAccessor, contentTypeAlias, culture); } public static IEnumerable Descendants(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.Descendants(culture).OfType(); + return content.Descendants(VariationContextAccessor, culture); } public static IEnumerable Descendants(this IPublishedContent content, int level, string culture = null) where T : class, IPublishedContent { - return content.Descendants(level, culture).OfType(); + return content.Descendants(VariationContextAccessor, level, culture); } public static IEnumerable DescendantsOrSelf(this IPublishedContent content, string culture = null) { - return content.DescendantsOrSelf(true, null, culture); + return content.DescendantsOrSelf(VariationContextAccessor, culture); } public static IEnumerable DescendantsOrSelf(this IPublishedContent content, int level, string culture = null) { - return content.DescendantsOrSelf(true, p => p.Level >= level, culture); + return content.DescendantsOrSelf(VariationContextAccessor, level, culture); } public static IEnumerable DescendantsOrSelfOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.DescendantsOrSelf(true, p => p.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); + return content.DescendantsOrSelfOfType(VariationContextAccessor, contentTypeAlias, culture); } public static IEnumerable DescendantsOrSelf(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.DescendantsOrSelf(culture).OfType(); + return content.DescendantsOrSelf(VariationContextAccessor, culture); } public static IEnumerable DescendantsOrSelf(this IPublishedContent content, int level, string culture = null) where T : class, IPublishedContent { - return content.DescendantsOrSelf(level, culture).OfType(); + return content.DescendantsOrSelf(VariationContextAccessor, level, culture); } public static IPublishedContent Descendant(this IPublishedContent content, string culture = null) { - return content.Children(VariationContextAccessor, culture).FirstOrDefault(); + return content.Descendant(VariationContextAccessor, culture); } public static IPublishedContent Descendant(this IPublishedContent content, int level, string culture = null) { - return content.EnumerateDescendants(false, culture).FirstOrDefault(x => x.Level == level); + return content.Descendant(VariationContextAccessor, level, culture); } public static IPublishedContent DescendantOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.EnumerateDescendants(false, culture).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); + return content.DescendantOfType(VariationContextAccessor, contentTypeAlias, culture); } public static T Descendant(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.EnumerateDescendants(false, culture).FirstOrDefault(x => x is T) as T; + return content.Descendant(VariationContextAccessor, culture); } public static T Descendant(this IPublishedContent content, int level, string culture = null) where T : class, IPublishedContent { - return content.Descendant(level, culture) as T; - } - - public static IPublishedContent DescendantOrSelf(this IPublishedContent content, string culture = null) - { - return content; + return content.Descendant(VariationContextAccessor, level, culture); } public static IPublishedContent DescendantOrSelf(this IPublishedContent content, int level, string culture = null) { - return content.EnumerateDescendants(true, culture).FirstOrDefault(x => x.Level == level); + return content.DescendantOrSelf(VariationContextAccessor, level, culture); } public static IPublishedContent DescendantOrSelfOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.EnumerateDescendants(true, culture).FirstOrDefault(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias)); + return content.DescendantOrSelfOfType(VariationContextAccessor, contentTypeAlias, culture); } public static T DescendantOrSelf(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.EnumerateDescendants(true, culture).FirstOrDefault(x => x is T) as T; + return content.DescendantOrSelf(VariationContextAccessor, culture); } public static T DescendantOrSelf(this IPublishedContent content, int level, string culture = null) where T : class, IPublishedContent { - return content.DescendantOrSelf(level, culture) as T; - } - - internal static IEnumerable DescendantsOrSelf(this IPublishedContent content, bool orSelf, Func func, string culture = null) - { - return content.EnumerateDescendants(orSelf, culture).Where(x => func == null || func(x)); - } - - internal static IEnumerable EnumerateDescendants(this IPublishedContent content, bool orSelf, string culture = null) - { - if (content == null) throw new ArgumentNullException(nameof(content)); - if (orSelf) yield return content; - - foreach (var desc in content.Children(VariationContextAccessor, culture).SelectMany(x => x.EnumerateDescendants(culture))) - yield return desc; - } - - internal static IEnumerable EnumerateDescendants(this IPublishedContent content, string culture = null) - { - yield return content; - - foreach (var desc in content.Children(VariationContextAccessor, culture).SelectMany(x => x.EnumerateDescendants(culture))) - yield return desc; - } - - #endregion - - #region Axes: parent - - // Parent is native - - /// - /// Gets the parent of the content, of a given content type. - /// - /// The content type. - /// The content. - /// The parent of content, of the given content type, else null. - public static T Parent(this IPublishedContent content) - where T : class, IPublishedContent - { - if (content == null) throw new ArgumentNullException(nameof(content)); - return content.Parent as T; + return content.DescendantOrSelf(VariationContextAccessor, level, culture); } #endregion @@ -893,7 +528,7 @@ namespace Umbraco.Web /// The children of the content, of any of the specified types. public static IEnumerable ChildrenOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.Children(x => x.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); + return content.Children(VariationContextAccessor, x => x.ContentType.Alias.InvariantEquals(contentTypeAlias), culture); } /// @@ -922,29 +557,29 @@ namespace Umbraco.Web /// public static IPublishedContent FirstChildOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.ChildrenOfType(contentTypeAlias, culture).FirstOrDefault(); + return content.ChildrenOfType(VariationContextAccessor, contentTypeAlias, culture).FirstOrDefault(); } public static IPublishedContent FirstChild(this IPublishedContent content, Func predicate, string culture = null) { - return content.Children(predicate, culture).FirstOrDefault(); + return content.Children(VariationContextAccessor, predicate, culture).FirstOrDefault(); } public static IPublishedContent FirstChild(this IPublishedContent content, Guid uniqueId, string culture = null) { - return content.Children(x=>x.Key == uniqueId, culture).FirstOrDefault(); + return content.Children(VariationContextAccessor, x => x.Key == uniqueId, culture).FirstOrDefault(); } public static T FirstChild(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.Children(culture).FirstOrDefault(); + return content.Children(VariationContextAccessor, culture).FirstOrDefault(); } public static T FirstChild(this IPublishedContent content, Func predicate, string culture = null) where T : class, IPublishedContent { - return content.Children(culture).FirstOrDefault(predicate); + return content.Children(VariationContextAccessor, culture).FirstOrDefault(predicate); } /// @@ -1040,7 +675,7 @@ namespace Umbraco.Web /// public static IEnumerable Siblings(this IPublishedContent content, string culture = null) { - return SiblingsAndSelf(content, culture).Where(x => x.Id != content.Id); + return content.Siblings(PublishedSnapshot, VariationContextAccessor, culture); } /// @@ -1055,7 +690,7 @@ namespace Umbraco.Web /// public static IEnumerable SiblingsOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return SiblingsAndSelfOfType(content, contentTypeAlias, culture).Where(x => x.Id != content.Id); + return content.SiblingsOfType(PublishedSnapshot, VariationContextAccessor, contentTypeAlias, culture); } /// @@ -1071,7 +706,7 @@ namespace Umbraco.Web public static IEnumerable Siblings(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return SiblingsAndSelf(content, culture).Where(x => x.Id != content.Id); + return content.Siblings(PublishedSnapshot, VariationContextAccessor, culture); } /// @@ -1082,9 +717,7 @@ namespace Umbraco.Web /// The siblings of the content including the node itself. public static IEnumerable SiblingsAndSelf(this IPublishedContent content, string culture = null) { - return content.Parent != null - ? content.Parent.Children(VariationContextAccessor, culture) - : PublishedSnapshot.Content.GetAtRoot().WhereIsInvariantOrHasCulture(VariationContextAccessor, culture); + return content.SiblingsAndSelf(PublishedSnapshot, VariationContextAccessor, culture); } /// @@ -1096,9 +729,7 @@ namespace Umbraco.Web /// The siblings of the content including the node itself, of the given content type. public static IEnumerable SiblingsAndSelfOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.Parent != null - ? content.Parent.ChildrenOfType(contentTypeAlias, culture) - : PublishedSnapshot.Content.GetAtRoot().OfTypes(contentTypeAlias).WhereIsInvariantOrHasCulture(VariationContextAccessor, culture); + return content.SiblingsAndSelfOfType(PublishedSnapshot, VariationContextAccessor, contentTypeAlias, culture); } /// @@ -1111,23 +742,7 @@ namespace Umbraco.Web public static IEnumerable SiblingsAndSelf(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.Parent != null - ? content.Parent.Children(culture) - : PublishedSnapshot.Content.GetAtRoot().OfType().WhereIsInvariantOrHasCulture(VariationContextAccessor, culture); - } - - #endregion - - #region Axes: custom - - /// - /// Gets the root content for this content. - /// - /// The content. - /// The 'site' content ie AncestorOrSelf(1). - public static IPublishedContent Root(this IPublishedContent content) - { - return content.AncestorOrSelf(1); + return content.SiblingsAndSelf(PublishedSnapshot, VariationContextAccessor, culture); } #endregion diff --git a/src/Umbraco.Web/PublishedElementExtensions.cs b/src/Umbraco.Web/PublishedElementExtensions.cs index 982f5566f5..661c740d90 100644 --- a/src/Umbraco.Web/PublishedElementExtensions.cs +++ b/src/Umbraco.Web/PublishedElementExtensions.cs @@ -157,20 +157,6 @@ namespace Umbraco.Web #endregion - #region OfTypes - - // the .OfType() filter is nice when there's only one type - // this is to support filtering with multiple types - public static IEnumerable OfTypes(this IEnumerable contents, params string[] types) - where T : IPublishedElement - { - if (types == null || types.Length == 0) return Enumerable.Empty(); - - return contents.Where(x => types.InvariantContains(x.ContentType.Alias)); - } - - #endregion - #region IsSomething /// diff --git a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs index fcf6f55f44..dffb956b1a 100644 --- a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs +++ b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Events; From 50c309e613cef05018be7bb4b192aa2349f91f75 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Fri, 31 Jan 2020 15:52:08 +0100 Subject: [PATCH 07/15] Removed type check for dashboard status URL from published status controller and moved to interface. --- .../PublishedCache/IPublishedSnapshotService.cs | 6 ++++++ .../NuCache/PublishedSnapshotService.cs | 2 ++ .../PublishedSnapshotServiceBase.cs | 2 ++ src/Umbraco.Web/Editors/PublishedStatusController.cs | 11 +++++------ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs b/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs index 96831e3112..a1894c902c 100644 --- a/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs +++ b/src/Umbraco.Abstractions/PublishedCache/IPublishedSnapshotService.cs @@ -161,8 +161,14 @@ namespace Umbraco.Web.PublishedCache #endregion + #region Status + string GetStatus(); + string StatusUrl { get; } + + #endregion + void Collect(); } } diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs index 5d99aa6aaa..f4636857b5 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs @@ -1788,6 +1788,8 @@ AND cmsContentNu.nodeId IS NULL " and " + ms + " snapshot" + (ms > 1 ? "s" : "") + "."; } + public override string StatusUrl => "views/dashboard/settings/nucache.html"; + public override void Collect() { var contentCollect = _contentStore.CollectAsync(); diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs index c7236f9c54..33ac485a26 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs @@ -41,6 +41,8 @@ namespace Umbraco.Web.PublishedCache public abstract string GetStatus(); + public virtual string StatusUrl => string.Empty; + public virtual void Collect() { } diff --git a/src/Umbraco.Web/Editors/PublishedStatusController.cs b/src/Umbraco.Web/Editors/PublishedStatusController.cs index 9b408e177e..5ed70c4811 100644 --- a/src/Umbraco.Web/Editors/PublishedStatusController.cs +++ b/src/Umbraco.Web/Editors/PublishedStatusController.cs @@ -17,13 +17,12 @@ namespace Umbraco.Web.Editors [HttpGet] public string GetPublishedStatusUrl() { - return "views/dashboard/settings/nucache.html"; + if (!string.IsNullOrWhiteSpace(_publishedSnapshotService.StatusUrl)) + { + return _publishedSnapshotService.StatusUrl; + } - // TODO: do we need this check? - //if (_publishedSnapshotService is PublishedCache.NuCache.PublishedSnapshotService) - // return "views/dashboard/settings/nucache.html"; - - //throw new NotSupportedException("Not supported: " + _publishedSnapshotService.GetType().FullName); + throw new NotSupportedException("Not supported: " + _publishedSnapshotService.GetType().FullName); } } } From b8bfdf14418daec90aab63633d3bb9ffb57ab04c Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Sat, 1 Feb 2020 18:19:50 +0100 Subject: [PATCH 08/15] Restored type check for NuCache status controller. Added service located extension method for retrieving creator and writer name. --- .../Umbraco.Infrastructure.PublishedCache.csproj | 3 +++ .../Editors/NuCacheStatusController.cs | 10 ++++------ src/Umbraco.Web/PublishedContentExtensions.cs | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj b/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj index d4c30668c5..f818df2d41 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj +++ b/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj @@ -15,6 +15,9 @@ + + <_Parameter1>Umbraco.Web + <_Parameter1>Umbraco.Tests diff --git a/src/Umbraco.Web/Editors/NuCacheStatusController.cs b/src/Umbraco.Web/Editors/NuCacheStatusController.cs index 0f50682e77..3494b7ba96 100644 --- a/src/Umbraco.Web/Editors/NuCacheStatusController.cs +++ b/src/Umbraco.Web/Editors/NuCacheStatusController.cs @@ -21,12 +21,10 @@ namespace Umbraco.Web.Editors { get { - // TODO: do we need this? - //var svc = _publishedSnapshotService as PublishedSnapshotService; - //if (svc == null) - // throw new NotSupportedException("Not running NuCache."); - // return svc; - return _publishedSnapshotService; + var svc = _publishedSnapshotService as PublishedSnapshotService; + if (svc == null) + throw new NotSupportedException("Not running NuCache."); + return svc; } } diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index fe42d5a165..73696bc8d4 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -28,6 +28,7 @@ namespace Umbraco.Web private static UmbracoContext UmbracoContext => Current.UmbracoContext; private static ISiteDomainHelper SiteDomainHelper => Current.Factory.GetInstance(); private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor; + private static IUserService UserService => Current.Services.UserService; #region IsComposedOf @@ -795,6 +796,20 @@ namespace Umbraco.Web #endregion + #region Writer and creator + + public static string CreatorName(this IPublishedContent content) + { + return content.GetCreatorName(UserService); + } + + public static string WriterName(this IPublishedContent content) + { + return content.GetWriterName(UserService); + } + + #endregion + #region Url /// From bc6f79ef5bff5d85991e046306813ea989d334d2 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 4 Feb 2020 09:50:32 +0100 Subject: [PATCH 09/15] Fixed views after moving extension methods --- .../Umbraco/PartialViewMacros/Templates/Breadcrumb.cshtml | 3 ++- .../Templates/ListAncestorsFromCurrentPage.cshtml | 1 + .../Templates/ListImagesFromMediaFolder.cshtml | 3 ++- .../Umbraco/PartialViewMacros/Templates/Navigation.cshtml | 1 + .../Umbraco/PartialViewMacros/Templates/SiteMap.cshtml | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Breadcrumb.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Breadcrumb.cshtml index 263d4ae66e..335987f542 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Breadcrumb.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Breadcrumb.cshtml @@ -1,4 +1,5 @@ -@using Umbraco.Web +@using Umbraco.Core +@using Umbraco.Web @inherits Umbraco.Web.Macros.PartialViewMacroPage @* diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml index b654935558..e067ef6376 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListAncestorsFromCurrentPage.cshtml @@ -1,3 +1,4 @@ +@using Umbraco.Core @using Umbraco.Web @inherits Umbraco.Web.Macros.PartialViewMacroPage diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml index 51fdbadb00..7a561cf94d 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml @@ -1,3 +1,4 @@ +@using Umbraco.Web @inherits Umbraco.Web.Macros.PartialViewMacroPage @* @@ -26,7 +27,7 @@ @foreach (var item in selection) {
  • - @item.Name + @item.Name
  • } diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml index 1c01eeb855..363352c148 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml @@ -1,3 +1,4 @@ +@using Umbraco.Core @using Umbraco.Web @inherits Umbraco.Web.Macros.PartialViewMacroPage diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml index 567ed5d07d..d6b12bbd78 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml @@ -1,3 +1,4 @@ +@using Umbraco.Core @using Umbraco.Core.Models.PublishedContent @using Umbraco.Web @inherits Umbraco.Web.Macros.PartialViewMacroPage From b0c752bc5ce3fec11e4c785b7edcae623fc0d68b Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 4 Feb 2020 19:18:35 +0100 Subject: [PATCH 10/15] Removed concrete type checks for back-office published cache details, so now working from interface. Renamed controller and FE assets to more generic name. --- .../NuCache/PublishedSnapshotService.cs | 2 - .../PublishedSnapshotServiceBase.cs | 2 +- ...s => publishedsnapshotcache.controller.js} | 12 ++-- ...cache.html => publishedsnapshotcache.html} | 2 +- .../settings/publishedstatus.controller.js | 2 - .../Editors/BackOfficeServerVariables.cs | 2 +- .../Editors/NuCacheStatusController.cs | 61 ------------------- .../PublishedSnapshotCacheStatusController.cs | 46 ++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 2 +- 9 files changed, 56 insertions(+), 75 deletions(-) rename src/Umbraco.Web.UI.Client/src/views/dashboard/settings/{nucache.controller.js => publishedsnapshotcache.controller.js} (80%) rename src/Umbraco.Web.UI.Client/src/views/dashboard/settings/{nucache.html => publishedsnapshotcache.html} (99%) delete mode 100644 src/Umbraco.Web/Editors/NuCacheStatusController.cs create mode 100644 src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs index f4636857b5..5d99aa6aaa 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs @@ -1788,8 +1788,6 @@ AND cmsContentNu.nodeId IS NULL " and " + ms + " snapshot" + (ms > 1 ? "s" : "") + "."; } - public override string StatusUrl => "views/dashboard/settings/nucache.html"; - public override void Collect() { var contentCollect = _contentStore.CollectAsync(); diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs index 33ac485a26..5c30bb8410 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs @@ -41,7 +41,7 @@ namespace Umbraco.Web.PublishedCache public abstract string GetStatus(); - public virtual string StatusUrl => string.Empty; + public virtual string StatusUrl => "views/dashboard/settings/publishedsnapshotcache.html"; public virtual void Collect() { diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js similarity index 80% rename from src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js rename to src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js index c3baf7246e..5270892fa5 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.controller.js @@ -1,4 +1,4 @@ -function nuCacheController($scope, $http, umbRequestHelper, localizationService, overlayService) { +function publishedSnapshotCacheController($scope, $http, umbRequestHelper, localizationService, overlayService) { var vm = this; @@ -35,7 +35,7 @@ if (vm.working) return; vm.working = true; umbRequestHelper.resourcePromise( - $http.get(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "Collect")), + $http.get(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "Collect")), 'Failed to verify the cache.') .then(function (result) { vm.working = false; @@ -47,7 +47,7 @@ if (vm.working) return; vm.working = true; umbRequestHelper.resourcePromise( - $http.get(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "GetStatus")), + $http.get(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "GetStatus")), 'Failed to verify the cache.') .then(function (result) { vm.working = false; @@ -83,7 +83,7 @@ vm.working = true; umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "ReloadCache")), + $http.post(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "ReloadCache")), 'Failed to trigger a cache reload') .then(function (result) { vm.working = false; @@ -94,7 +94,7 @@ vm.working = true; umbRequestHelper.resourcePromise( - $http.post(umbRequestHelper.getApiUrl("nuCacheStatusBaseUrl", "RebuildDbCache")), + $http.post(umbRequestHelper.getApiUrl("publishedSnapshotCacheStatusBaseUrl", "RebuildDbCache")), 'Failed to rebuild the cache.') .then(function (result) { vm.working = false; @@ -109,4 +109,4 @@ init(); } -angular.module("umbraco").controller("Umbraco.Dashboard.NuCacheController", nuCacheController); +angular.module("umbraco").controller("Umbraco.Dashboard.PublishedSnapshotCacheController", publishedSnapshotCacheController); diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.html similarity index 99% rename from src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html rename to src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.html index 0b14e9c3ff..e1f95ad62d 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/nucache.html +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedsnapshotcache.html @@ -1,4 +1,4 @@ -
    +
    diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js index 27c3e57ddf..ca4d5e1450 100644 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/settings/publishedstatus.controller.js @@ -7,8 +7,6 @@ $http.get(umbRequestHelper.getApiUrl('publishedStatusBaseUrl', 'GetPublishedStatusUrl')), 'Failed to get published status url') .then(function (result) { - - //result = 'views/dashboard/developer/nucache.html' vm.includeUrl = result; }); diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index b85bc1187e..8764590118 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -286,7 +286,7 @@ namespace Umbraco.Web.Editors controller => controller.DeleteById(int.MaxValue)) }, { - "nuCacheStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + "publishedSnapshotCacheStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetStatus()) }, { diff --git a/src/Umbraco.Web/Editors/NuCacheStatusController.cs b/src/Umbraco.Web/Editors/NuCacheStatusController.cs deleted file mode 100644 index 3494b7ba96..0000000000 --- a/src/Umbraco.Web/Editors/NuCacheStatusController.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Web.Http; -using Umbraco.Web.Cache; -using Umbraco.Web.Composing; -using Umbraco.Web.PublishedCache; -using Umbraco.Web.PublishedCache.NuCache; -using Umbraco.Web.WebApi; - -namespace Umbraco.Web.Editors -{ - public class NuCacheStatusController : UmbracoAuthorizedApiController - { - private readonly IPublishedSnapshotService _publishedSnapshotService; - - public NuCacheStatusController(IPublishedSnapshotService publishedSnapshotService) - { - _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); - } - - private IPublishedSnapshotService PublishedSnapshotService - { - get - { - var svc = _publishedSnapshotService as PublishedSnapshotService; - if (svc == null) - throw new NotSupportedException("Not running NuCache."); - return svc; - } - } - - [HttpPost] - public string RebuildDbCache() - { - var service = PublishedSnapshotService; - service.Rebuild(); - return service.GetStatus(); - } - - [HttpGet] - public string GetStatus() - { - var service = PublishedSnapshotService; - return service.GetStatus(); - } - - [HttpGet] - public string Collect() - { - var service = PublishedSnapshotService; - GC.Collect(); - service.Collect(); - return service.GetStatus(); - } - - [HttpPost] - public void ReloadCache() - { - Current.DistributedCache.RefreshAllPublishedSnapshot(); - } - } -} diff --git a/src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs b/src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs new file mode 100644 index 0000000000..6a701fdcfa --- /dev/null +++ b/src/Umbraco.Web/Editors/PublishedSnapshotCacheStatusController.cs @@ -0,0 +1,46 @@ +using System; +using System.Web.Http; +using Umbraco.Web.Cache; +using Umbraco.Web.Composing; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.WebApi; + +namespace Umbraco.Web.Editors +{ + public class PublishedSnapshotCacheStatusController : UmbracoAuthorizedApiController + { + private readonly IPublishedSnapshotService _publishedSnapshotService; + + public PublishedSnapshotCacheStatusController(IPublishedSnapshotService publishedSnapshotService) + { + _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); + } + + [HttpPost] + public string RebuildDbCache() + { + _publishedSnapshotService.Rebuild(); + return _publishedSnapshotService.GetStatus(); + } + + [HttpGet] + public string GetStatus() + { + return _publishedSnapshotService.GetStatus(); + } + + [HttpGet] + public string Collect() + { + GC.Collect(); + _publishedSnapshotService.Collect(); + return _publishedSnapshotService.GetStatus(); + } + + [HttpPost] + public void ReloadCache() + { + Current.DistributedCache.RefreshAllPublishedSnapshot(); + } + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c612ea4361..ed5cee711a 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -406,7 +406,7 @@ - + From 41fde9318d06d29ac6376d3eac20efff9d182286 Mon Sep 17 00:00:00 2001 From: Andy Butland Date: Tue, 4 Feb 2020 19:19:51 +0100 Subject: [PATCH 11/15] Restored accidental change of csproj --- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 7e821fe0c7..fd20d0cea1 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -382,9 +382,7 @@ - From a018315404594ffa896a98e25f730599a31cdc09 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 6 Feb 2020 14:09:16 +0100 Subject: [PATCH 12/15] Removed references from web and Models builder.. Moved some classes to do so --- .../Composing/IPublishedCacheComposer .cs | 5 +++++ .../PublishedCache}/DefaultCultureAccessor.cs | 0 .../PublishedCache/IPublishedElementFactory.cs | 7 +++++++ .../PublishedCache}/PublishedElement.cs | 0 .../PublishedCache}/PublishedElementPropertyBase.cs | 0 .../NuCache/NuCacheComposer.cs | 4 ++-- .../Compose/ModelsBuilderComposer.cs | 5 +---- .../Umbraco.ModelsBuilder.Embedded.csproj | 4 ---- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 6 +++++- src/Umbraco.Web/Umbraco.Web.csproj | 4 ---- 10 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 src/Umbraco.Abstractions/Composing/IPublishedCacheComposer .cs rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/PublishedCache}/DefaultCultureAccessor.cs (100%) create mode 100644 src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/PublishedCache}/PublishedElement.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/PublishedCache}/PublishedElementPropertyBase.cs (100%) diff --git a/src/Umbraco.Abstractions/Composing/IPublishedCacheComposer .cs b/src/Umbraco.Abstractions/Composing/IPublishedCacheComposer .cs new file mode 100644 index 0000000000..d88eb44ea3 --- /dev/null +++ b/src/Umbraco.Abstractions/Composing/IPublishedCacheComposer .cs @@ -0,0 +1,5 @@ +namespace Umbraco.Core.Composing +{ + public interface IPublishedCacheComposer : ICoreComposer + { } +} diff --git a/src/Umbraco.Infrastructure.PublishedCache/DefaultCultureAccessor.cs b/src/Umbraco.Abstractions/PublishedCache/DefaultCultureAccessor.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/DefaultCultureAccessor.cs rename to src/Umbraco.Abstractions/PublishedCache/DefaultCultureAccessor.cs diff --git a/src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs b/src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs new file mode 100644 index 0000000000..4de3cb0300 --- /dev/null +++ b/src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs @@ -0,0 +1,7 @@ +namespace Umbraco.Web.PublishedCache +{ + public interface IPublishedElementFactory + { + + } +} diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedElement.cs b/src/Umbraco.Abstractions/PublishedCache/PublishedElement.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/PublishedElement.cs rename to src/Umbraco.Abstractions/PublishedCache/PublishedElement.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedElementPropertyBase.cs b/src/Umbraco.Abstractions/PublishedCache/PublishedElementPropertyBase.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/PublishedElementPropertyBase.cs rename to src/Umbraco.Abstractions/PublishedCache/PublishedElementPropertyBase.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs b/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs index 06a2bdbe81..d3b1777163 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs +++ b/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs @@ -8,7 +8,7 @@ using Umbraco.Web.PublishedCache.NuCache.DataSource; namespace Umbraco.Web.PublishedCache.NuCache { - public class NuCacheComposer : ComponentComposer, ICoreComposer + public class NuCacheComposer : ComponentComposer, IPublishedCacheComposer { public override void Compose(Composition composition) { @@ -32,7 +32,7 @@ namespace Umbraco.Web.PublishedCache.NuCache { idkSvc.SetMapper(UmbracoObjectTypes.Document, id => publishedSnapshotService.GetDocumentUid(id), uid => publishedSnapshotService.GetDocumentId(uid)); idkSvc.SetMapper(UmbracoObjectTypes.Media, id => publishedSnapshotService.GetMediaUid(id), uid => publishedSnapshotService.GetMediaId(uid)); - } + } return idkSvc; }); diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs index d5138953cf..bb8a3f7e18 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs @@ -3,19 +3,16 @@ using System.Reflection; using Umbraco.Core; using Umbraco.Core.Logging; using Umbraco.Core.Composing; -using Umbraco.Core.IO; using Umbraco.Core.Models.PublishedContent; using Umbraco.ModelsBuilder.Embedded.Building; using Umbraco.ModelsBuilder.Embedded.Configuration; using Umbraco.Web; -using Umbraco.Web.PublishedCache.NuCache; -using Umbraco.Web.Features; namespace Umbraco.ModelsBuilder.Embedded.Compose { - [ComposeBefore(typeof(NuCacheComposer))] + [ComposeBefore(typeof(IPublishedCacheComposer))] [RuntimeLevel(MinLevel = RuntimeLevel.Run)] public sealed class ModelsBuilderComposer : ICoreComposer { diff --git a/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj b/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj index 1b9e78728d..073a6566d0 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj +++ b/src/Umbraco.ModelsBuilder.Embedded/Umbraco.ModelsBuilder.Embedded.csproj @@ -105,10 +105,6 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions - - {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} - Umbraco.Infrastructure.PublishedCache - {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index fd20d0cea1..d1e9d0c47a 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -120,6 +120,10 @@ Umbraco.Examine.Lucene {07FBC26B-2927-4A22-8D96-D644C667FECC} + + {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} + Umbraco.Infrastructure.PublishedCache + {52ac0ba8-a60e-4e36-897b-e8b97a54ed1c} Umbraco.ModelsBuilder.Embedded @@ -427,4 +431,4 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index ed5cee711a..f4441650a2 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -116,10 +116,6 @@ {f9b7fe05-0f93-4d0d-9c10-690b33ecbbd8} Umbraco.Examine - - {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} - Umbraco.Infrastructure.PublishedCache - {3ae7bf57-966b-45a5-910a-954d7c554441} Umbraco.Infrastructure From d147b182ee5e791bc453aaf2ee8421bdf5e7d8b7 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 6 Feb 2020 14:40:46 +0100 Subject: [PATCH 13/15] Renamed the project to Umbraco.PublishedCache.NuCache - and move non NuCache related stuff to abstractions and infrastructure. --- .../Composing}/CompositionExtensions.cs | 0 .../PublishedCache}/PublishedCacheBase.cs | 2 +- .../PublishedCache}/PublishedMember.cs | 0 .../PublishedCache}/PublishedSnapshotServiceBase.cs | 2 +- .../PublishedCache}/PublishedContentTypeCache.cs | 2 +- .../CacheKeys.cs | 0 .../ContentCache.cs | 0 .../ContentNode.cs | 4 ++-- .../ContentNodeKit.cs | 2 +- .../ContentStore.cs | 2 +- .../DataSource/BTree.ContentDataSerializer.cs | 0 .../DataSource/BTree.ContentNodeKitSerializer.cs | 0 .../BTree.DictionaryOfCultureVariationSerializer.cs | 0 .../BTree.DictionaryOfPropertyDataSerializer.cs | 0 .../DataSource/BTree.cs | 0 .../DataSource/ContentData.cs | 2 +- .../DataSource/ContentNestedData.cs | 0 .../DataSource/ContentSourceDto.cs | 0 .../DataSource/CultureVariation.cs | 2 +- .../DataSource/DatabaseDataSource.cs | 0 .../DataSource/IDataSource.cs | 0 .../DataSource/PropertyData.cs | 2 +- .../DataSource/SerializerBase.cs | 0 .../DomainCache.cs | 0 .../MediaCache.cs | 2 +- .../MemberCache.cs | 0 .../Navigable/INavigableData.cs | 0 .../Navigable/NavigableContent.cs | 0 .../Navigable/NavigableContentType.cs | 0 .../Navigable/NavigablePropertyType.cs | 0 .../Navigable/RootContent.cs | 0 .../Navigable/Source.cs | 0 .../NuCacheComponent.cs | 0 .../NuCacheComposer.cs | 0 .../Property.cs | 0 .../PublishedContent.cs | 0 .../PublishedMember.cs | 0 .../PublishedSnapshot.cs | 0 .../PublishedSnapshotService.cs | 0 .../PublishedSnapshotServiceOptions.cs | 0 .../Snap/GenObj.cs | 0 .../Snap/GenRef.cs | 0 .../Snap/LinkedNode.cs | 0 .../SnapDictionary.cs | 0 .../Umbraco.PublishedCache.NuCache.csproj} | 1 + .../readme.md | 0 src/Umbraco.Tests/Cache/SnapDictionaryTests.cs | 13 ++++++------- src/Umbraco.Tests/Umbraco.Tests.csproj | 9 +++++---- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 8 ++++---- src/umbraco.sln | 2 +- 50 files changed, 28 insertions(+), 27 deletions(-) rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/Composing}/CompositionExtensions.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/PublishedCache}/PublishedCacheBase.cs (98%) rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/PublishedCache}/PublishedMember.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Abstractions/PublishedCache}/PublishedSnapshotServiceBase.cs (96%) rename src/{Umbraco.Infrastructure.PublishedCache => Umbraco.Infrastructure/PublishedCache}/PublishedContentTypeCache.cs (98%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/CacheKeys.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/ContentCache.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/ContentNode.cs (99%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/ContentNodeKit.cs (98%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/ContentStore.cs (99%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/BTree.ContentDataSerializer.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/BTree.ContentNodeKitSerializer.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/BTree.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/ContentData.cs (96%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/ContentNestedData.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/ContentSourceDto.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/CultureVariation.cs (93%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/DatabaseDataSource.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/IDataSource.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/PropertyData.cs (95%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DataSource/SerializerBase.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/DomainCache.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/MediaCache.cs (98%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/MemberCache.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Navigable/INavigableData.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Navigable/NavigableContent.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Navigable/NavigableContentType.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Navigable/NavigablePropertyType.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Navigable/RootContent.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Navigable/Source.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/NuCacheComponent.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/NuCacheComposer.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Property.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/PublishedContent.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/PublishedMember.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/PublishedSnapshot.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/PublishedSnapshotService.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/PublishedSnapshotServiceOptions.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Snap/GenObj.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Snap/GenRef.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/Snap/LinkedNode.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/SnapDictionary.cs (100%) rename src/{Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj => Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj} (93%) rename src/{Umbraco.Infrastructure.PublishedCache/NuCache => Umbraco.PublishedCache.NuCache}/readme.md (100%) diff --git a/src/Umbraco.Infrastructure.PublishedCache/CompositionExtensions.cs b/src/Umbraco.Abstractions/Composing/CompositionExtensions.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/CompositionExtensions.cs rename to src/Umbraco.Abstractions/Composing/CompositionExtensions.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs b/src/Umbraco.Abstractions/PublishedCache/PublishedCacheBase.cs similarity index 98% rename from src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs rename to src/Umbraco.Abstractions/PublishedCache/PublishedCacheBase.cs index 28bc218f54..56fbf6e553 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedCacheBase.cs +++ b/src/Umbraco.Abstractions/PublishedCache/PublishedCacheBase.cs @@ -8,7 +8,7 @@ using Umbraco.Core.Xml; namespace Umbraco.Web.PublishedCache { - abstract class PublishedCacheBase : IPublishedCache + public abstract class PublishedCacheBase : IPublishedCache { private readonly IVariationContextAccessor _variationContextAccessor; diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs b/src/Umbraco.Abstractions/PublishedCache/PublishedMember.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/PublishedMember.cs rename to src/Umbraco.Abstractions/PublishedCache/PublishedMember.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs b/src/Umbraco.Abstractions/PublishedCache/PublishedSnapshotServiceBase.cs similarity index 96% rename from src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs rename to src/Umbraco.Abstractions/PublishedCache/PublishedSnapshotServiceBase.cs index 5c30bb8410..cb3ca269f4 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedSnapshotServiceBase.cs +++ b/src/Umbraco.Abstractions/PublishedCache/PublishedSnapshotServiceBase.cs @@ -5,7 +5,7 @@ using Umbraco.Web.Cache; namespace Umbraco.Web.PublishedCache { - abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService + public abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService { protected PublishedSnapshotServiceBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor) { diff --git a/src/Umbraco.Infrastructure.PublishedCache/PublishedContentTypeCache.cs b/src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs similarity index 98% rename from src/Umbraco.Infrastructure.PublishedCache/PublishedContentTypeCache.cs rename to src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs index e453471bb8..ba4f76dca6 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/PublishedContentTypeCache.cs +++ b/src/Umbraco.Infrastructure/PublishedCache/PublishedContentTypeCache.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.PublishedCache private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(); // default ctor - internal PublishedContentTypeCache(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger logger) + public PublishedContentTypeCache(IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IPublishedContentTypeFactory publishedContentTypeFactory, ILogger logger) { _contentTypeService = contentTypeService; _mediaTypeService = mediaTypeService; diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/CacheKeys.cs b/src/Umbraco.PublishedCache.NuCache/CacheKeys.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/CacheKeys.cs rename to src/Umbraco.PublishedCache.NuCache/CacheKeys.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.PublishedCache.NuCache/ContentCache.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentCache.cs rename to src/Umbraco.PublishedCache.NuCache/ContentCache.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNode.cs b/src/Umbraco.PublishedCache.NuCache/ContentNode.cs similarity index 99% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNode.cs rename to src/Umbraco.PublishedCache.NuCache/ContentNode.cs index 43c8e89d2e..38ba78caae 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNode.cs +++ b/src/Umbraco.PublishedCache.NuCache/ContentNode.cs @@ -8,7 +8,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // represents a content "node" ie a pair of draft + published versions // internal, never exposed, to be accessed from ContentStore (only!) [DebuggerDisplay("Id: {Id}, Path: {Path}")] - internal class ContentNode + public class ContentNode { // special ctor for root pseudo node public ContentNode() @@ -113,7 +113,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // everything that is common to both draft and published versions // keep this as small as possible - + public readonly int Id; public readonly Guid Uid; public IPublishedContentType ContentType; diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNodeKit.cs b/src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs similarity index 98% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNodeKit.cs rename to src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs index 842ca19388..8e24afd620 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentNodeKit.cs +++ b/src/Umbraco.PublishedCache.NuCache/ContentNodeKit.cs @@ -4,7 +4,7 @@ using Umbraco.Web.PublishedCache.NuCache.DataSource; namespace Umbraco.Web.PublishedCache.NuCache { // what's needed to actually build a content node - internal struct ContentNodeKit + public struct ContentNodeKit { public ContentNode Node; public int ContentTypeId; diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.PublishedCache.NuCache/ContentStore.cs similarity index 99% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs rename to src/Umbraco.PublishedCache.NuCache/ContentStore.cs index e84586f415..2927bd6cc0 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/ContentStore.cs +++ b/src/Umbraco.PublishedCache.NuCache/ContentStore.cs @@ -26,7 +26,7 @@ namespace Umbraco.Web.PublishedCache.NuCache /// This class's logic is based on the class but has been slightly modified to suit these purposes. /// /// - internal class ContentStore + public class ContentStore { // this class is an extended version of SnapDictionary // most of the snapshots management code, etc is an exact copy diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentDataSerializer.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.ContentDataSerializer.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentDataSerializer.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/BTree.ContentDataSerializer.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.ContentNodeKitSerializer.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.ContentNodeKitSerializer.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/BTree.ContentNodeKitSerializer.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/BTree.DictionaryOfCultureVariationSerializer.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/BTree.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentData.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs similarity index 96% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentData.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs index 36586acd12..42e7e340cd 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentData.cs +++ b/src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace Umbraco.Web.PublishedCache.NuCache.DataSource { // represents everything that is specific to edited or published version - internal class ContentData + public class ContentData { public string Name { get; set; } public string UrlSegment { get; set; } diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentNestedData.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentNestedData.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/ContentNestedData.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentSourceDto.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/ContentSourceDto.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/ContentSourceDto.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/ContentSourceDto.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/CultureVariation.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs similarity index 93% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/CultureVariation.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs index a98a96f424..2521d42744 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/CultureVariation.cs +++ b/src/Umbraco.PublishedCache.NuCache/DataSource/CultureVariation.cs @@ -6,7 +6,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource /// /// Represents the culture variation information on a content item /// - internal class CultureVariation + public class CultureVariation { [JsonProperty("name")] public string Name { get; set; } diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/DatabaseDataSource.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/DatabaseDataSource.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/DatabaseDataSource.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/DatabaseDataSource.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/IDataSource.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/IDataSource.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/IDataSource.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/IDataSource.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/PropertyData.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs similarity index 95% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/PropertyData.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs index e14426a2e2..9ab9401d71 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/PropertyData.cs +++ b/src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; namespace Umbraco.Web.PublishedCache.NuCache.DataSource { - internal class PropertyData + public class PropertyData { private string _culture; private string _segment; diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/SerializerBase.cs b/src/Umbraco.PublishedCache.NuCache/DataSource/SerializerBase.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DataSource/SerializerBase.cs rename to src/Umbraco.PublishedCache.NuCache/DataSource/SerializerBase.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/DomainCache.cs b/src/Umbraco.PublishedCache.NuCache/DomainCache.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/DomainCache.cs rename to src/Umbraco.PublishedCache.NuCache/DomainCache.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/MediaCache.cs b/src/Umbraco.PublishedCache.NuCache/MediaCache.cs similarity index 98% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/MediaCache.cs rename to src/Umbraco.PublishedCache.NuCache/MediaCache.cs index 182086ed7f..376e1d2e48 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/NuCache/MediaCache.cs +++ b/src/Umbraco.PublishedCache.NuCache/MediaCache.cs @@ -11,7 +11,7 @@ using Umbraco.Web.PublishedCache.NuCache.Navigable; namespace Umbraco.Web.PublishedCache.NuCache { - internal class MediaCache : PublishedCacheBase, IPublishedMediaCache, INavigableData, IDisposable + public class MediaCache : PublishedCacheBase, IPublishedMediaCache, INavigableData, IDisposable { private readonly ContentStore.Snapshot _snapshot; private readonly IVariationContextAccessor _variationContextAccessor; diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/MemberCache.cs b/src/Umbraco.PublishedCache.NuCache/MemberCache.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/MemberCache.cs rename to src/Umbraco.PublishedCache.NuCache/MemberCache.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/INavigableData.cs b/src/Umbraco.PublishedCache.NuCache/Navigable/INavigableData.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/INavigableData.cs rename to src/Umbraco.PublishedCache.NuCache/Navigable/INavigableData.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContent.cs b/src/Umbraco.PublishedCache.NuCache/Navigable/NavigableContent.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContent.cs rename to src/Umbraco.PublishedCache.NuCache/Navigable/NavigableContent.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContentType.cs b/src/Umbraco.PublishedCache.NuCache/Navigable/NavigableContentType.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigableContentType.cs rename to src/Umbraco.PublishedCache.NuCache/Navigable/NavigableContentType.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigablePropertyType.cs b/src/Umbraco.PublishedCache.NuCache/Navigable/NavigablePropertyType.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/NavigablePropertyType.cs rename to src/Umbraco.PublishedCache.NuCache/Navigable/NavigablePropertyType.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/RootContent.cs b/src/Umbraco.PublishedCache.NuCache/Navigable/RootContent.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/RootContent.cs rename to src/Umbraco.PublishedCache.NuCache/Navigable/RootContent.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/Source.cs b/src/Umbraco.PublishedCache.NuCache/Navigable/Source.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Navigable/Source.cs rename to src/Umbraco.PublishedCache.NuCache/Navigable/Source.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComponent.cs b/src/Umbraco.PublishedCache.NuCache/NuCacheComponent.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComponent.cs rename to src/Umbraco.PublishedCache.NuCache/NuCacheComponent.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs b/src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/NuCacheComposer.cs rename to src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Property.cs b/src/Umbraco.PublishedCache.NuCache/Property.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Property.cs rename to src/Umbraco.PublishedCache.NuCache/Property.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.PublishedCache.NuCache/PublishedContent.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedContent.cs rename to src/Umbraco.PublishedCache.NuCache/PublishedContent.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedMember.cs b/src/Umbraco.PublishedCache.NuCache/PublishedMember.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedMember.cs rename to src/Umbraco.PublishedCache.NuCache/PublishedMember.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshot.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshot.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshot.cs rename to src/Umbraco.PublishedCache.NuCache/PublishedSnapshot.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotService.cs rename to src/Umbraco.PublishedCache.NuCache/PublishedSnapshotService.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotServiceOptions.cs b/src/Umbraco.PublishedCache.NuCache/PublishedSnapshotServiceOptions.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/PublishedSnapshotServiceOptions.cs rename to src/Umbraco.PublishedCache.NuCache/PublishedSnapshotServiceOptions.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenObj.cs b/src/Umbraco.PublishedCache.NuCache/Snap/GenObj.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenObj.cs rename to src/Umbraco.PublishedCache.NuCache/Snap/GenObj.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenRef.cs b/src/Umbraco.PublishedCache.NuCache/Snap/GenRef.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/GenRef.cs rename to src/Umbraco.PublishedCache.NuCache/Snap/GenRef.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/LinkedNode.cs b/src/Umbraco.PublishedCache.NuCache/Snap/LinkedNode.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/Snap/LinkedNode.cs rename to src/Umbraco.PublishedCache.NuCache/Snap/LinkedNode.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/SnapDictionary.cs b/src/Umbraco.PublishedCache.NuCache/SnapDictionary.cs similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/SnapDictionary.cs rename to src/Umbraco.PublishedCache.NuCache/SnapDictionary.cs diff --git a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj similarity index 93% rename from src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj rename to src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj index f818df2d41..f638e88b63 100644 --- a/src/Umbraco.Infrastructure.PublishedCache/Umbraco.Infrastructure.PublishedCache.csproj +++ b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj @@ -2,6 +2,7 @@ netstandard2.0 + Umbraco.Infrastructure.PublishedCache diff --git a/src/Umbraco.Infrastructure.PublishedCache/NuCache/readme.md b/src/Umbraco.PublishedCache.NuCache/readme.md similarity index 100% rename from src/Umbraco.Infrastructure.PublishedCache/NuCache/readme.md rename to src/Umbraco.PublishedCache.NuCache/readme.md diff --git a/src/Umbraco.Tests/Cache/SnapDictionaryTests.cs b/src/Umbraco.Tests/Cache/SnapDictionaryTests.cs index 00ba721bdb..739268b451 100644 --- a/src/Umbraco.Tests/Cache/SnapDictionaryTests.cs +++ b/src/Umbraco.Tests/Cache/SnapDictionaryTests.cs @@ -5,7 +5,6 @@ using Moq; using NUnit.Framework; using Umbraco.Core.Scoping; using Umbraco.Web.PublishedCache.NuCache; -using Umbraco.Web.PublishedCache.NuCache.Snap; namespace Umbraco.Tests.Cache { @@ -223,7 +222,7 @@ namespace Umbraco.Tests.Cache { var d = new SnapDictionary(); d.Test.CollectAuto = false; - + // gen 1 d.Set(1, "one"); Assert.AreEqual(1, d.Test.GetValues(1).Length); @@ -321,7 +320,7 @@ namespace Umbraco.Tests.Cache { var d = new SnapDictionary(); d.Test.CollectAuto = false; - + Assert.AreEqual(0, d.Test.GetValues(1).Length); // gen 1 @@ -416,7 +415,7 @@ namespace Umbraco.Tests.Cache { var d = new SnapDictionary(); d.Test.CollectAuto = false; - + // gen 1 d.Set(1, "one"); Assert.AreEqual(1, d.Test.GetValues(1).Length); @@ -578,7 +577,7 @@ namespace Umbraco.Tests.Cache { var d = new SnapDictionary(); d.Test.CollectAuto = false; - + d.Set(1, "one"); d.Set(2, "two"); @@ -875,7 +874,7 @@ namespace Umbraco.Tests.Cache { var d = new SnapDictionary(); d.Test.CollectAuto = false; - + // gen 1 d.Set(1, "one"); @@ -960,7 +959,7 @@ namespace Umbraco.Tests.Cache var d = new SnapDictionary(); var t = d.Test; t.CollectAuto = false; - + // gen 1 d.Set(1, "one"); var s1 = d.CreateSnapshot(); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 34cd80fcd4..31cc85e5c5 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -564,9 +564,6 @@ {fbe7c065-dac0-4025-a78b-63b24d3ab00b} Umbraco.Configuration - - {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} - Umbraco.Infrastructure.PublishedCache {0fad7d2a-d7dd-45b1-91fd-488bb6cdacea} Umbraco.Examine.Lucene @@ -587,6 +584,10 @@ {33085570-9bf2-4065-a9b0-a29d920d13ba} Umbraco.Persistance.SqlCe + + {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} + Umbraco.PublishedCache.NuCache + {651E1350-91B6-44B7-BD60-7207006D7003} Umbraco.Web @@ -655,4 +656,4 @@ - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index 12eab15215..276eed8344 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -120,14 +120,14 @@ {0fad7d2a-d7dd-45b1-91fd-488bb6cdacea} Umbraco.Examine.Lucene - - {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} - Umbraco.Infrastructure.PublishedCache - {52ac0ba8-a60e-4e36-897b-e8b97a54ed1c} Umbraco.ModelsBuilder.Embedded + + {f6de8da0-07cc-4ef2-8a59-2bc81dbb3830} + Umbraco.PublishedCache.NuCache + {651e1350-91b6-44b7-bd60-7207006d7003} Umbraco.Web diff --git a/src/umbraco.sln b/src/umbraco.sln index 10a3a33b80..d54554434e 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -111,7 +111,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Persistance.SqlCe", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.TestData", "Umbraco.TestData\Umbraco.TestData.csproj", "{FB5676ED-7A69-492C-B802-E7B24144C0FC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastructure.PublishedCache", "Umbraco.Infrastructure.PublishedCache\Umbraco.Infrastructure.PublishedCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.PublishedCache.NuCache", "Umbraco.PublishedCache.NuCache\Umbraco.PublishedCache.NuCache.csproj", "{F6DE8DA0-07CC-4EF2-8A59-2BC81DBB3830}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Examine", "Umbraco.Examine\Umbraco.Examine.csproj", "{F9B7FE05-0F93-4D0D-9C10-690B33ECBBD8}" EndProject From add34e4f6b93be7c6ab88ce3d62472cf61673801 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 7 Feb 2020 06:13:59 +0100 Subject: [PATCH 14/15] Removed unused interface --- .../PublishedCache/IPublishedElementFactory.cs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs diff --git a/src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs b/src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs deleted file mode 100644 index 4de3cb0300..0000000000 --- a/src/Umbraco.Abstractions/PublishedCache/IPublishedElementFactory.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Umbraco.Web.PublishedCache -{ - public interface IPublishedElementFactory - { - - } -} From 81bbd201ea2754e0da893192385b05c148bca797 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 7 Feb 2020 06:16:27 +0100 Subject: [PATCH 15/15] Removed internal visible tos --- src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj | 3 --- .../Umbraco.PublishedCache.NuCache.csproj | 3 --- 2 files changed, 6 deletions(-) diff --git a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj index 38e9168e0d..b3b291a286 100644 --- a/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj +++ b/src/Umbraco.Infrastructure/Umbraco.Infrastructure.csproj @@ -51,9 +51,6 @@ - - <_Parameter1>Umbraco.Core - <_Parameter1>Umbraco.Tests diff --git a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj index f638e88b63..4c369ec2fa 100644 --- a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj +++ b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj @@ -16,9 +16,6 @@ - - <_Parameter1>Umbraco.Web - <_Parameter1>Umbraco.Tests