From ec6ba01cbfb45f1b75afa8c9e5536d3f698f6e0f Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 31 Oct 2017 12:48:24 +0100 Subject: [PATCH] So long Facade --- src/Umbraco.Compat7/Umbraco.Compat7.csproj | 39 +++++- .../PublishedCache/FacadeServiceResolver.cs | 15 --- .../PublishedSnapshotServiceResolver.cs | 15 +++ .../PublishedContent/IPublishedElement.cs | 2 +- .../PublishedContent/PublishedPropertyBase.cs | 4 +- .../PublishedContent/PublishedPropertyType.cs | 2 +- .../DataTypeDefinitionRepository.cs | 2 +- .../PropertyEditors/PropertyCacheLevel.cs | 29 ++--- .../PropertyValueConverterBase.cs | 2 +- .../CheckboxListValueConverter.cs | 2 +- .../ColorPickerValueConverter.cs | 2 +- .../DatePickerValueConverter.cs | 2 +- .../ValueConverters/DecimalValueConverter.cs | 2 +- .../DropdownListMultipleValueConverter.cs | 2 +- ...pdownListMultipleWithKeysValueConverter.cs | 2 +- .../DropdownListValueConverter.cs | 2 +- .../DropdownListWithKeysValueConverter.cs | 2 +- .../EmailAddressValueConverter.cs | 2 +- .../ValueConverters/GridValueConverter.cs | 2 +- .../ImageCropperValueConverter.cs | 2 +- .../ValueConverters/IntegerValueConverter.cs | 2 +- .../ValueConverters/JsonValueConverter.cs | 2 +- .../ValueConverters/LabelValueConverter.cs | 2 +- .../MarkdownEditorValueConverter.cs | 2 +- .../MemberGroupPickerValueConverter.cs | 2 +- .../MultipleTextStringValueConverter.cs | 2 +- .../MustBeStringValueConverter.cs | 2 +- .../RadioButtonListValueConverter.cs | 2 +- .../ValueConverters/SliderValueConverter.cs | 2 +- .../ValueConverters/TagsValueConverter.cs | 2 +- .../TextStringValueConverter.cs | 2 +- .../ValueConverters/TinyMceValueConverter.cs | 2 +- .../UploadPropertyConverter.cs | 2 +- .../ValueConverters/YesNoValueConverter.cs | 2 +- .../Sync/DatabaseServerMessenger.cs | 7 +- .../PublishedContentCacheTests.cs | 8 +- .../{Facade => Published}/ConvertersTests.cs | 74 ++++++------ .../{Facade => Published}/ModelTypeTests.cs | 14 +-- .../NestedContentTests.cs | 30 +++-- .../PropertyCacheLevelTests.cs | 105 ++++++++-------- .../PublishedSnapshotTestObjects.cs} | 4 +- .../PublishedContentMoreTests.cs | 12 +- .../PublishedContentRequestEngineTests.cs | 24 ++-- .../PublishedContentTestElements.cs | 6 +- .../Routing/ContentFinderByAliasTests.cs | 4 +- .../ContentFinderByAliasWithDomainsTests.cs | 6 +- .../Routing/ContentFinderByIdTests.cs | 4 +- .../ContentFinderByNiceUrlAndTemplateTests.cs | 4 +- .../Routing/ContentFinderByNiceUrlTests.cs | 20 +-- .../ContentFinderByNiceUrlWithDomainsTests.cs | 12 +- .../ContentFinderByPageIdQueryTests.cs | 4 +- .../Routing/DomainsAndCulturesTests.cs | 14 +-- .../Routing/RenderRouteHandlerTests.cs | 8 +- src/Umbraco.Tests/Routing/RoutesCacheTests.cs | 2 +- .../Routing/UrlsWithNestedDomains.cs | 6 +- .../Scoping/ScopedNuCacheTests.cs | 16 +-- src/Umbraco.Tests/Scoping/ScopedXmlTests.cs | 4 +- .../Security/BackOfficeCookieManagerTests.cs | 4 +- .../Services/ContentServiceTests.cs | 2 +- .../Services/ContentTypeServiceTests.cs | 2 +- .../Services/MediaServiceTests.cs | 2 +- .../Services/MemberServiceTests.cs | 2 +- .../Services/MemberTypeServiceTests.cs | 2 +- src/Umbraco.Tests/TestHelpers/BaseWebTest.cs | 8 +- .../TestControllerActivatorBase.cs | 10 +- .../TestHelpers/Stubs/TestFacadeAccessor.cs | 9 -- .../Stubs/TestPublishedSnapshotAccessor.cs | 9 ++ .../TestHelpers/TestObjects-Mocks.cs | 15 ++- .../TestHelpers/TestWithDatabaseBase.cs | 26 ++-- .../Testing/UmbracoTestAttribute.cs | 6 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 12 +- ...RenderIndexActionSelectorAttributeTests.cs | 8 +- .../Web/Mvc/SurfaceControllerTests.cs | 22 ++-- .../Web/Mvc/UmbracoViewPageTests.cs | 8 +- .../Web/TemplateUtilitiesTests.cs | 2 +- .../Web/WebExtensionMethodTests.cs | 6 +- .../developer/facadestatus.controller.js | 15 --- .../dashboard/developer/facadestatus.html | 9 -- .../developer/publishedstatus.controller.js | 15 +++ .../dashboard/developer/publishedstatus.html | 9 ++ .../config/Dashboard.Release.config | 4 +- src/Umbraco.Web.UI/config/Dashboard.config | 4 +- .../Cache/ContentCacheRefresher.cs | 8 +- .../Cache/ContentTypeCacheRefresher.cs | 8 +- .../Cache/DataTypeCacheRefresher.cs | 8 +- .../Cache/DistributedCacheExtensions.cs | 4 +- src/Umbraco.Web/Cache/DomainCacheRefresher.cs | 8 +- src/Umbraco.Web/Cache/MediaCacheRefresher.cs | 8 +- src/Umbraco.Web/Composing/Current.cs | 8 +- src/Umbraco.Web/CompositionExtensions.cs | 22 ++-- .../Editors/BackOfficeServerVariables.cs | 4 +- src/Umbraco.Web/Editors/ContentController.cs | 10 +- .../XmlDataIntegrityHealthCheck.cs | 22 ++-- .../Controllers/InstallPackageController.cs | 4 +- .../Install/FilePermissionHelper.cs | 10 +- .../InstallSteps/SetUmbracoVersionStep.cs | 4 +- .../InstallSteps/StarterKitCleanupStep.cs | 4 +- src/Umbraco.Web/Models/ContentExtensions.cs | 2 +- .../EnsurePublishedContentRequestAttribute.cs | 6 +- src/Umbraco.Web/Mvc/RenderRouteHandler.cs | 4 +- .../Mvc/UmbracoVirtualNodeRouteHandler.cs | 6 +- .../ContentPickerValueConverter.cs | 12 +- .../MacroContainerValueConverter.cs | 2 +- .../MarkdownEditorValueConverter.cs | 2 +- .../MediaPickerLegacyValueConverter.cs | 2 +- .../MediaPickerValueConverter.cs | 10 +- .../MemberPickerValueConverter.cs | 12 +- .../MultiNodeTreePickerValueConverter.cs | 20 +-- .../NestedContentManyValueConverter.cs | 6 +- .../NestedContentSingleValueConverter.cs | 6 +- .../NestedContentValueConverterBase.cs | 10 +- .../RelatedLinksLegacyValueConverter.cs | 2 +- .../RelatedLinksValueConverter.cs | 10 +- .../RteMacroRenderingValueConverter.cs | 4 +- .../TextStringValueConverter.cs | 2 +- .../PublishedCache/IFacadeAccessor.cs | 10 -- .../{IFacade.cs => IPublishedShapshot.cs} | 24 ++-- .../IPublishedSnapshotAccessor.cs | 10 ++ ...ervice.cs => IPublishedSnapshotService.cs} | 40 +++--- .../PublishedCache/NuCache/ContentCache.cs | 18 +-- .../PublishedCache/NuCache/ContentNode.cs | 18 +-- .../PublishedCache/NuCache/ContentNodeKit.cs | 4 +- .../PublishedCache/NuCache/ContentStore.cs | 16 +-- .../PublishedCache/NuCache/MediaCache.cs | 14 +-- .../PublishedCache/NuCache/MemberCache.cs | 30 ++--- .../NuCache/NuCacheComponent.cs | 10 +- .../PublishedCache/NuCache/Property.cs | 46 +++---- .../NuCache/PublishedContent.cs | 62 +++++----- .../PublishedCache/NuCache/PublishedMember.cs | 10 +- .../{Facade.cs => PublishedShapshot.cs} | 38 +++--- ...Service.cs => PublishedSnapshotService.cs} | 114 +++++++++--------- .../PublishedCache/NuCache/notes.txt | 4 + .../PublishedCache/PublishedElement.cs | 12 +- .../PublishedElementPropertyBase.cs | 42 +++---- ...ase.cs => PublishedSnapshotServiceBase.cs} | 14 +-- ...mbracoContextPublishedSnapshotAccessor.cs} | 8 +- .../{Facade.cs => PublishedShapshot.cs} | 14 +-- ...Service.cs => PublishedSnapshotService.cs} | 28 ++--- .../XmlPublishedCache/XmlCacheComponent.cs | 6 +- .../XmlPublishedCache/XmlPublishedContent.cs | 2 +- .../XmlPublishedCache/XmlPublishedProperty.cs | 2 +- .../XmlPublishedCache/XmlStore.cs | 32 ++--- src/Umbraco.Web/Routing/AliasUrlProvider.cs | 2 +- .../Routing/ContentFinderByLegacy404.cs | 2 +- src/Umbraco.Web/Routing/DefaultUrlProvider.cs | 4 +- src/Umbraco.Web/Routing/Domain.cs | 2 +- src/Umbraco.Web/Routing/DomainAndUri.cs | 2 +- src/Umbraco.Web/Routing/DomainHelper.cs | 2 +- .../Routing/PublishedContentRequest.cs | 18 +-- .../{FacadeRouter.cs => PublishedRouter.cs} | 99 +++++++-------- .../Routing/UrlProviderExtensions.cs | 2 +- src/Umbraco.Web/Security/MembershipHelper.cs | 4 +- ...aseServerRegistrarAndMessengerComponent.cs | 8 +- ...ediaXmlCacheForDeletedItemsAfterUpgrade.cs | 1 - .../RebuildXmlCachesAfterUpgrade.cs | 4 +- src/Umbraco.Web/Templates/TemplateRenderer.cs | 4 +- src/Umbraco.Web/Umbraco.Web.csproj | 22 ++-- src/Umbraco.Web/UmbracoContext.cs | 36 +++--- src/Umbraco.Web/UmbracoModule.cs | 10 +- .../WebApi/Binders/ContentItemBaseBinder.cs | 9 -- src/Umbraco.Web/WebRuntimeComponent.cs | 12 +- .../WebServices/FacadeStatusController.cs | 33 ----- .../WebServices/NuCacheStatusController.cs | 20 +-- .../WebServices/PublishedStatusController.cs | 32 +++++ .../WebServices/XmlDataIntegrityController.cs | 28 ++--- .../umbraco.presentation/library.cs | 8 +- .../developer/Packages/installer.aspx.cs | 4 +- .../umbraco/dialogs/Preview.aspx.cs | 4 +- .../umbraco/endPreview.aspx.cs | 2 +- 169 files changed, 1000 insertions(+), 1011 deletions(-) delete mode 100644 src/Umbraco.Compat7/Web/PublishedCache/FacadeServiceResolver.cs create mode 100644 src/Umbraco.Compat7/Web/PublishedCache/PublishedSnapshotServiceResolver.cs rename src/Umbraco.Tests/{Facade => Published}/ConvertersTests.cs (73%) rename src/Umbraco.Tests/{Facade => Published}/ModelTypeTests.cs (87%) rename src/Umbraco.Tests/{Facade => Published}/NestedContentTests.cs (92%) rename src/Umbraco.Tests/{Facade => Published}/PropertyCacheLevelTests.cs (70%) rename src/Umbraco.Tests/{Facade/FacadeTestObjects.cs => Published/PublishedSnapshotTestObjects.cs} (98%) delete mode 100644 src/Umbraco.Tests/TestHelpers/Stubs/TestFacadeAccessor.cs create mode 100644 src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedSnapshotAccessor.cs delete mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.controller.js delete mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.html create mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.html delete mode 100644 src/Umbraco.Web/PublishedCache/IFacadeAccessor.cs rename src/Umbraco.Web/PublishedCache/{IFacade.cs => IPublishedShapshot.cs} (69%) create mode 100644 src/Umbraco.Web/PublishedCache/IPublishedSnapshotAccessor.cs rename src/Umbraco.Web/PublishedCache/{IFacadeService.cs => IPublishedSnapshotService.cs} (80%) rename src/Umbraco.Web/PublishedCache/NuCache/{Facade.cs => PublishedShapshot.cs} (61%) rename src/Umbraco.Web/PublishedCache/NuCache/{FacadeService.cs => PublishedSnapshotService.cs} (92%) rename src/Umbraco.Web/PublishedCache/{FacadeServiceBase.cs => PublishedSnapshotServiceBase.cs} (64%) rename src/Umbraco.Web/PublishedCache/{UmbracoContextFacadeAccessor.cs => UmbracoContextPublishedSnapshotAccessor.cs} (67%) rename src/Umbraco.Web/PublishedCache/XmlPublishedCache/{Facade.cs => PublishedShapshot.cs} (82%) rename src/Umbraco.Web/PublishedCache/XmlPublishedCache/{FacadeService.cs => PublishedSnapshotService.cs} (88%) rename src/Umbraco.Web/Routing/{FacadeRouter.cs => PublishedRouter.cs} (85%) delete mode 100644 src/Umbraco.Web/WebServices/FacadeStatusController.cs create mode 100644 src/Umbraco.Web/WebServices/PublishedStatusController.cs diff --git a/src/Umbraco.Compat7/Umbraco.Compat7.csproj b/src/Umbraco.Compat7/Umbraco.Compat7.csproj index 62a983bb52..583eaa33a5 100644 --- a/src/Umbraco.Compat7/Umbraco.Compat7.csproj +++ b/src/Umbraco.Compat7/Umbraco.Compat7.csproj @@ -52,7 +52,44 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Properties\SolutionInfo.cs diff --git a/src/Umbraco.Compat7/Web/PublishedCache/FacadeServiceResolver.cs b/src/Umbraco.Compat7/Web/PublishedCache/FacadeServiceResolver.cs deleted file mode 100644 index f5063d18ab..0000000000 --- a/src/Umbraco.Compat7/Web/PublishedCache/FacadeServiceResolver.cs +++ /dev/null @@ -1,15 +0,0 @@ -using WebCurrent = Umbraco.Web.Composing.Current; - -// ReSharper disable once CheckNamespace -namespace Umbraco.Web.PublishedCache -{ - public class FacadeServiceResolver - { - private FacadeServiceResolver() - { } - - public static FacadeServiceResolver Current { get; } = new FacadeServiceResolver(); - - public IFacadeService Service => WebCurrent.FacadeService; - } -} diff --git a/src/Umbraco.Compat7/Web/PublishedCache/PublishedSnapshotServiceResolver.cs b/src/Umbraco.Compat7/Web/PublishedCache/PublishedSnapshotServiceResolver.cs new file mode 100644 index 0000000000..13bbfd72b9 --- /dev/null +++ b/src/Umbraco.Compat7/Web/PublishedCache/PublishedSnapshotServiceResolver.cs @@ -0,0 +1,15 @@ +using WebCurrent = Umbraco.Web.Composing.Current; + +// ReSharper disable once CheckNamespace +namespace Umbraco.Web.PublishedCache +{ + public class PublishedSnapshotServiceResolver + { + private PublishedSnapshotServiceResolver() + { } + + public static PublishedSnapshotServiceResolver Current { get; } = new PublishedSnapshotServiceResolver(); + + public IPublishedSnapshotService Service => WebCurrent.PublishedSnapshotService; + } +} diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs index 31325e8c3a..6cd4818587 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedElement.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core.Models.PublishedContent #region PublishedElement /// - /// Gets the unique key of the facade item. + /// Gets the unique key of the published snapshot item. /// Guid Key { get; } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs index 8aea69a835..9166831862 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyBase.cs @@ -22,9 +22,9 @@ namespace Umbraco.Core.Models.PublishedContent { switch (cacheLevel) { - case PropertyCacheLevel.Content: + case PropertyCacheLevel.Element: + case PropertyCacheLevel.Elements: case PropertyCacheLevel.Snapshot: - case PropertyCacheLevel.Facade: case PropertyCacheLevel.None: break; case PropertyCacheLevel.Unknown: diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index 81981bb6a8..dd3d0afbb2 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -182,7 +182,7 @@ namespace Umbraco.Core.Models.PublishedContent } } - _cacheLevel = _converter?.GetPropertyCacheLevel(this) ?? PropertyCacheLevel.Facade; + _cacheLevel = _converter?.GetPropertyCacheLevel(this) ?? PropertyCacheLevel.Snapshot; _modelClrType = _converter == null ? typeof (object) : _converter.GetPropertyValueType(this); } diff --git a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs index ffb4687586..261bc474d3 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs @@ -104,7 +104,7 @@ namespace Umbraco.Core.Persistence.Repositories // so... we are modifying content types here. the service will trigger Deleted event, // which will propagate to DataTypeCacheRefresher which will clear almost every cache - // there is to clear... and in addition facade caches will clear themselves too, so + // there is to clear... and in addition published snapshot caches will clear themselves too, so // this is probably safe alghough it looks... weird. // // what IS weird is that a content type is losing a property and we do NOT raise any diff --git a/src/Umbraco.Core/PropertyEditors/PropertyCacheLevel.cs b/src/Umbraco.Core/PropertyEditors/PropertyCacheLevel.cs index a295435f10..22ffa41f52 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyCacheLevel.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyCacheLevel.cs @@ -1,40 +1,37 @@ namespace Umbraco.Core.PropertyEditors { /// - /// Specifies the acceptable level of cache for a property value. + /// Specifies the level of cache for a property value. /// - /// By default, Request is assumed. public enum PropertyCacheLevel { - // note: we use the relative values in PublishedPropertyType to ensure that - // object level >= source level - // xpath level >= source level - /// /// Default value. /// Unknown = 0, /// - /// Indicates that the property value can be cached at the content level, ie it can be - /// cached until the content itself is modified. + /// Indicates that the property value can be cached at the element level, i.e. it can be + /// cached until the element itself is modified. /// - Content = 1, + Element = 1, /// - /// Indicates that the property value can be cached at the snapshot level, ie it can - /// be cached until any content in the cache is modified. + /// Indicates that the property value can be cached at the elements level, i.e. it can + /// be cached until any element is modified. /// - Snapshot = 2, + Elements = 2, /// - /// Indicates that the property value can be cached at the facade level, ie it can be - /// cached for the duration of the current facade (ie, in most cases, request). + /// Indicates that the property value can be cached at the snapshot level, i.e. it can be + /// cached for the duration of the current snapshot. /// - Facade = 3, + /// In most cases, a snapshot is created per request, and therefore this is + /// equivalent to cache the value for the duration of the request. + Snapshot = 3, /// - /// Indicates that the property value cannot be cached and has to be converted any time + /// Indicates that the property value cannot be cached and has to be converted each time /// it is requested. /// None = 4 diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index 849886c66b..53a5e7a0ed 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core.PropertyEditors public virtual PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) { - return PropertyCacheLevel.Facade; + return PropertyCacheLevel.Snapshot; } public virtual object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs index 85fdf9bc0b..52436dafdc 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/CheckboxListValueConverter.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (IEnumerable); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs index 1f16c3e12a..bc1200df98 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ColorPickerValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs index 100dbba575..a10d870803 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DatePickerValueConverter.cs @@ -21,7 +21,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (DateTime); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs index b8652c4d3c..06955446cf 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DecimalValueConverter.cs @@ -14,7 +14,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (decimal); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs index 412d47ad96..2f540e5976 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (IEnumerable); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs index e032674fb8..4e0d0345de 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListMultipleWithKeysValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (IEnumerable); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs index 2f071935cd..3175fbd05c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs index a70d600d37..d14c191226 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/DropdownListWithKeysValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (int); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs index 0e646f4e1f..63355c18e0 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/EmailAddressValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs index 3a403e3222..f90357002f 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs @@ -26,7 +26,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (JToken); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs index 28686c0b4a..cbbfbb90db 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/ImageCropperValueConverter.cs @@ -25,7 +25,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (JToken); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public ImageCropperValueConverter() { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs index c9ca2e4fcf..fd11619e46 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/IntegerValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (int); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs index 4645f8bf3d..f14b613d44 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/JsonValueConverter.cs @@ -32,7 +32,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (JToken); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs index b9990ae7cb..6164fdf553 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/LabelValueConverter.cs @@ -22,7 +22,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index b95840c2ae..b1c4ca47ae 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters // PropertyCacheLevel.Content is ok here because that converter does not parse {locallink} nor executes macros public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs index 2d3aaa9d19..32e3203e94 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberGroupPickerValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs index 67a76462f2..d9fd11377b 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs @@ -16,7 +16,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (IEnumerable); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs index 4a8b50e009..260560141e 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MustBeStringValueConverter.cs @@ -30,7 +30,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs index dc38a4ed85..eccada88e1 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/RadioButtonListValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (int); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs index 61b3068dee..71004ac2d6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/SliderValueConverter.cs @@ -25,7 +25,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => IsRangeDataType(propertyType.DataTypeId) ? typeof (Range) : typeof (decimal); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs index ccc0713cf6..2881fbe0c1 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TagsValueConverter.cs @@ -26,7 +26,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (IEnumerable); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs index cef7656421..20cce12538 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TextStringValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs index ae4cb1a701..54f4169424 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/TinyMceValueConverter.cs @@ -18,7 +18,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters // PropertyCacheLevel.Content is ok here because that converter does not parse {locallink} nor executes macros public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs index 52176126ad..0b148ef13c 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/UploadPropertyConverter.cs @@ -16,7 +16,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel cacheLevel, object source, bool preview) { diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs index c3f2ca2290..8abe6c9ab6 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/YesNoValueConverter.cs @@ -13,7 +13,7 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters => typeof (bool); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs index 4ad462d93a..6098055b68 100644 --- a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs @@ -115,12 +115,13 @@ namespace Umbraco.Core.Sync /// protected void Boot() { - // weight:10, must release *before* the facade service, because once released + // weight:10, must release *before* the published snapshot service, because once released // the service will *not* be able to properly handle our notifications anymore const int weight = 10; - var runtime = _runtime as RuntimeState; - if (runtime == null) throw new NotSupportedException($"Unsupported IRuntimeState implementation {_runtime.GetType().FullName}, expecting {typeof(RuntimeState).FullName}."); + if (!(_runtime is RuntimeState runtime)) + throw new NotSupportedException($"Unsupported IRuntimeState implementation {_runtime.GetType().FullName}, expecting {typeof(RuntimeState).FullName}."); + var registered = runtime.MainDom.Register( () => { diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs index 8d339824fe..c71c2a1a38 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedContentCacheTests.cs @@ -61,17 +61,17 @@ namespace Umbraco.Tests.Cache.PublishedCache var xmlStore = new XmlStore(() => _xml); var cacheProvider = new StaticCacheProvider(); var domainCache = new DomainCache(ServiceContext.DomainService); - var facade = new Umbraco.Web.PublishedCache.XmlPublishedCache.Facade( + var publishedShapshot = new Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedShapshot( new PublishedContentCache(xmlStore, domainCache, cacheProvider, ContentTypesCache, null, null), new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, cacheProvider, ContentTypesCache), new PublishedMemberCache(null, cacheProvider, Current.Services.MemberService, ContentTypesCache), domainCache); - var facadeService = new Mock(); - facadeService.Setup(x => x.CreateFacade(It.IsAny())).Returns(facade); + var publishedSnapshotService = new Mock(); + publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedShapshot); _umbracoContext = new UmbracoContext( _httpContextFactory.HttpContext, - facadeService.Object, + publishedSnapshotService.Object, new WebSecurity(_httpContextFactory.HttpContext, Current.Services.UserService), settings, Enumerable.Empty()); diff --git a/src/Umbraco.Tests/Facade/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs similarity index 73% rename from src/Umbraco.Tests/Facade/ConvertersTests.cs rename to src/Umbraco.Tests/Published/ConvertersTests.cs index 1fd4652a4b..1b63af6850 100644 --- a/src/Umbraco.Tests/Facade/ConvertersTests.cs +++ b/src/Umbraco.Tests/Published/ConvertersTests.cs @@ -11,7 +11,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Web; using Umbraco.Web.PublishedCache; -namespace Umbraco.Tests.Facade +namespace Umbraco.Tests.Published { [TestFixture] public class ConvertersTests @@ -46,7 +46,7 @@ namespace Umbraco.Tests.Facade => typeof (int); public PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) => int.TryParse(source as string, out int i) ? i : 0; @@ -68,15 +68,15 @@ namespace Umbraco.Tests.Facade var cacheMock = new Mock(); var cacheContent = new Dictionary(); cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null); - var facadeMock = new Mock(); - facadeMock.Setup(x => x.ContentCache).Returns(cacheMock.Object); - var facadeAccessorMock = new Mock(); - facadeAccessorMock.Setup(x => x.Facade).Returns(facadeMock.Object); - var facadeAccessor = facadeAccessorMock.Object; + var publishedSnapshotMock = new Mock(); + publishedSnapshotMock.Setup(x => x.ContentCache).Returns(cacheMock.Object); + var publishedSnapshotAccessorMock = new Mock(); + publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshotMock.Object); + var publishedSnapshotAccessor = publishedSnapshotAccessorMock.Object; var converters = new PropertyValueConverterCollection(new IPropertyValueConverter[] { - new SimpleConverter2(facadeAccessor), + new SimpleConverter2(publishedSnapshotAccessor), }); var contentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), converters, Mock.Of()); @@ -88,7 +88,7 @@ namespace Umbraco.Tests.Facade var element1 = new PublishedElement(elementType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false); var cntType1 = contentTypeFactory.CreateContentType(1001, "cnt1", Array.Empty()); - var cnt1 = new FacadeTestObjects.TestPublishedContent(cntType1, 1234, Guid.NewGuid(), new Dictionary(), false); + var cnt1 = new PublishedSnapshotTestObjects.TestPublishedContent(cntType1, 1234, Guid.NewGuid(), new Dictionary(), false); cacheContent[cnt1.Id] = cnt1; Assert.AreSame(cnt1, element1.Value("prop1")); @@ -96,12 +96,12 @@ namespace Umbraco.Tests.Facade private class SimpleConverter2 : IPropertyValueConverter { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly PropertyCacheLevel _cacheLevel; - public SimpleConverter2(IFacadeAccessor facadeAccessor, PropertyCacheLevel cacheLevel = PropertyCacheLevel.None) + public SimpleConverter2(IPublishedSnapshotAccessor publishedSnapshotAccessor, PropertyCacheLevel cacheLevel = PropertyCacheLevel.None) { - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; _cacheLevel = cacheLevel; } @@ -122,7 +122,7 @@ namespace Umbraco.Tests.Facade => int.TryParse(source as string, out int i) ? i : -1; public object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) - => _facadeAccessor.Facade.ContentCache.GetById((int) inter); + => _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById((int) inter); public object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => ((int) inter).ToString(); @@ -145,19 +145,19 @@ namespace Umbraco.Tests.Facade IPublishedModelFactory factory = new PublishedModelFactory(new[] { - typeof (FacadeTestObjects.TestElementModel1), typeof (FacadeTestObjects.TestElementModel2), - typeof (FacadeTestObjects.TestContentModel1), typeof (FacadeTestObjects.TestContentModel2), + typeof (PublishedSnapshotTestObjects.TestElementModel1), typeof (PublishedSnapshotTestObjects.TestElementModel2), + typeof (PublishedSnapshotTestObjects.TestContentModel1), typeof (PublishedSnapshotTestObjects.TestContentModel2), }); Current.Container.Register(f => factory); var cacheMock = new Mock(); var cacheContent = new Dictionary(); cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null); - var facadeMock = new Mock(); - facadeMock.Setup(x => x.ContentCache).Returns(cacheMock.Object); - var facadeAccessorMock = new Mock(); - facadeAccessorMock.Setup(x => x.Facade).Returns(facadeMock.Object); - Current.Container.Register(f => facadeAccessorMock.Object); + var publishedSnapshotMock = new Mock(); + publishedSnapshotMock.Setup(x => x.ContentCache).Returns(cacheMock.Object); + var publishedSnapshotAccessorMock = new Mock(); + publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshotMock.Object); + Current.Container.Register(f => publishedSnapshotAccessorMock.Object); var converters = Current.Container.GetInstance(); var contentTypeFactory = new PublishedContentTypeFactory(factory, converters, Mock.Of()); @@ -184,8 +184,8 @@ namespace Umbraco.Tests.Facade var element1 = new PublishedElement(elementType1, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); var element2 = new PublishedElement(elementType2, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); - var cnt1 = new FacadeTestObjects.TestPublishedContent(contentType1, 1003, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); - var cnt2 = new FacadeTestObjects.TestPublishedContent(contentType2, 1004, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); + var cnt1 = new PublishedSnapshotTestObjects.TestPublishedContent(contentType1, 1003, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); + var cnt2 = new PublishedSnapshotTestObjects.TestPublishedContent(contentType2, 1004, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); cacheContent[cnt1.Id] = cnt1.CreateModel(); cacheContent[cnt2.Id] = cnt2.CreateModel(); @@ -194,25 +194,25 @@ namespace Umbraco.Tests.Facade // ie ModelType gets properly mapped by IPublishedContentModelFactory // must test ModelClrType with special equals 'cos they are not ref-equals Assert.IsTrue(ModelType.Equals(typeof (IEnumerable<>).MakeGenericType(ModelType.For("content1")), contentType2.GetPropertyType("prop2").ModelClrType)); - Assert.AreEqual(typeof (IEnumerable), contentType2.GetPropertyType("prop2").ClrType); + Assert.AreEqual(typeof (IEnumerable), contentType2.GetPropertyType("prop2").ClrType); // can create a model for an element var model1 = factory.CreateModel(element1); - Assert.IsInstanceOf(model1); - Assert.AreEqual("val1", ((FacadeTestObjects.TestElementModel1) model1).Prop1); + Assert.IsInstanceOf(model1); + Assert.AreEqual("val1", ((PublishedSnapshotTestObjects.TestElementModel1) model1).Prop1); // can create a model for a published content var model2 = factory.CreateModel(element2); - Assert.IsInstanceOf(model2); - var mmodel2 = (FacadeTestObjects.TestElementModel2) model2; + Assert.IsInstanceOf(model2); + var mmodel2 = (PublishedSnapshotTestObjects.TestElementModel2) model2; // and get direct property - Assert.IsInstanceOf(model2.Value("prop2")); - Assert.AreEqual(1, ((FacadeTestObjects.TestContentModel1[]) model2.Value("prop2")).Length); + Assert.IsInstanceOf(model2.Value("prop2")); + Assert.AreEqual(1, ((PublishedSnapshotTestObjects.TestContentModel1[]) model2.Value("prop2")).Length); // and get model property - Assert.IsInstanceOf>(mmodel2.Prop2); - Assert.IsInstanceOf(mmodel2.Prop2); + Assert.IsInstanceOf>(mmodel2.Prop2); + Assert.IsInstanceOf(mmodel2.Prop2); var mmodel1 = mmodel2.Prop2.First(); // and we get what we want @@ -228,16 +228,16 @@ namespace Umbraco.Tests.Facade => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; } public class SimpleConverter3B : PropertyValueConverterBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - public SimpleConverter3B(IFacadeAccessor facadeAccessor) + public SimpleConverter3B(IPublishedSnapshotAccessor publishedSnapshotAccessor) { - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; } public override bool IsConverter(PublishedPropertyType propertyType) @@ -247,7 +247,7 @@ namespace Umbraco.Tests.Facade => typeof (IEnumerable<>).MakeGenericType(ModelType.For("content1")); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Snapshot; + => PropertyCacheLevel.Elements; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { @@ -257,7 +257,7 @@ namespace Umbraco.Tests.Facade public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { - return ((int[]) inter).Select(x => (FacadeTestObjects.TestContentModel1) _facadeAccessor.Facade.ContentCache.GetById(x)).ToArray(); + return ((int[]) inter).Select(x => (PublishedSnapshotTestObjects.TestContentModel1) _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(x)).ToArray(); } } diff --git a/src/Umbraco.Tests/Facade/ModelTypeTests.cs b/src/Umbraco.Tests/Published/ModelTypeTests.cs similarity index 87% rename from src/Umbraco.Tests/Facade/ModelTypeTests.cs rename to src/Umbraco.Tests/Published/ModelTypeTests.cs index 34d1005448..623de01fcb 100644 --- a/src/Umbraco.Tests/Facade/ModelTypeTests.cs +++ b/src/Umbraco.Tests/Published/ModelTypeTests.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using NUnit.Framework; using Umbraco.Core.Models.PublishedContent; -namespace Umbraco.Tests.Facade +namespace Umbraco.Tests.Published { [TestFixture] public class ModelTypeTests @@ -71,17 +71,17 @@ namespace Umbraco.Tests.Facade { var map = new Dictionary { - { "alias1", typeof (FacadeTestObjects.TestElementModel1) }, - { "alias2", typeof (FacadeTestObjects.TestElementModel2) }, + { "alias1", typeof (PublishedSnapshotTestObjects.TestElementModel1) }, + { "alias2", typeof (PublishedSnapshotTestObjects.TestElementModel2) }, }; - Assert.AreEqual("Umbraco.Tests.Facade.FacadeTestObjects+TestElementModel1", + Assert.AreEqual("Umbraco.Tests.Published.PublishedSnapshotTestObjects+TestElementModel1", ModelType.Map(ModelType.For("alias1"), map).ToString()); - Assert.AreEqual("Umbraco.Tests.Facade.FacadeTestObjects+TestElementModel1[]", + Assert.AreEqual("Umbraco.Tests.Published.PublishedSnapshotTestObjects+TestElementModel1[]", ModelType.Map(ModelType.For("alias1").MakeArrayType(), map).ToString()); - Assert.AreEqual("System.Collections.Generic.IEnumerable`1[Umbraco.Tests.Facade.FacadeTestObjects+TestElementModel1]", + Assert.AreEqual("System.Collections.Generic.IEnumerable`1[Umbraco.Tests.Published.PublishedSnapshotTestObjects+TestElementModel1]", ModelType.Map(typeof(IEnumerable<>).MakeGenericType(ModelType.For("alias1")), map).ToString()); - Assert.AreEqual("System.Collections.Generic.IEnumerable`1[Umbraco.Tests.Facade.FacadeTestObjects+TestElementModel1[]]", + Assert.AreEqual("System.Collections.Generic.IEnumerable`1[Umbraco.Tests.Published.PublishedSnapshotTestObjects+TestElementModel1[]]", ModelType.Map(typeof(IEnumerable<>).MakeGenericType(ModelType.For("alias1").MakeArrayType()), map).ToString()); } } diff --git a/src/Umbraco.Tests/Facade/NestedContentTests.cs b/src/Umbraco.Tests/Published/NestedContentTests.cs similarity index 92% rename from src/Umbraco.Tests/Facade/NestedContentTests.cs rename to src/Umbraco.Tests/Published/NestedContentTests.cs index b5c05bf644..9de718bc35 100644 --- a/src/Umbraco.Tests/Facade/NestedContentTests.cs +++ b/src/Umbraco.Tests/Published/NestedContentTests.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using LightInject; using Moq; using NUnit.Framework; using Umbraco.Core; @@ -19,7 +18,7 @@ using Umbraco.Web.PropertyEditors; using Umbraco.Web.PropertyEditors.ValueConverters; using Umbraco.Web.PublishedCache; -namespace Umbraco.Tests.Facade +namespace Umbraco.Tests.Published { [TestFixture] public class NestedContentTests @@ -88,25 +87,24 @@ namespace Umbraco.Tests.Facade }); var contentCache = new Mock(); - var facade = new Mock(); + var publishedSnapshot = new Mock(); - // mocked facade returns a content cache - facade + // mocked published snapshot returns a content cache + publishedSnapshot .Setup(x => x.ContentCache) .Returns(contentCache.Object); - var facadeAccessor = new Mock(); - //container.RegisterSingleton(f => facadeAccessor.Object); + var publishedSnapshotAccessor = new Mock(); - // mocked facade accessor returns a facade - facadeAccessor - .Setup(x => x.Facade) - .Returns(facade.Object); + // mocked published snapshot accessor returns a facade + publishedSnapshotAccessor + .Setup(x => x.PublishedSnapshot) + .Returns(publishedSnapshot.Object); var converters = new PropertyValueConverterCollection(new IPropertyValueConverter[] { - new NestedContentSingleValueConverter(facadeAccessor.Object, publishedModelFactory.Object, proflog), - new NestedContentManyValueConverter(facadeAccessor.Object, publishedModelFactory.Object, proflog), + new NestedContentSingleValueConverter(publishedSnapshotAccessor.Object, publishedModelFactory.Object, proflog), + new NestedContentManyValueConverter(publishedSnapshotAccessor.Object, publishedModelFactory.Object, proflog), }); PropertyEditorCollection editors = null; @@ -145,7 +143,7 @@ namespace Umbraco.Tests.Facade // nested single converter returns the proper value clr type TestModel, and cache level Assert.AreEqual(typeof (TestElementModel), contentType1.GetPropertyType("property1").ClrType); - Assert.AreEqual(PropertyCacheLevel.Content, contentType1.GetPropertyType("property1").CacheLevel); + Assert.AreEqual(PropertyCacheLevel.Element, contentType1.GetPropertyType("property1").CacheLevel); var key = Guid.NewGuid(); var keyA = Guid.NewGuid(); @@ -171,7 +169,7 @@ namespace Umbraco.Tests.Facade // nested many converter returns the proper value clr type IEnumerable, and cache level Assert.AreEqual(typeof (IEnumerable), contentType2.GetPropertyType("property2").ClrType); - Assert.AreEqual(PropertyCacheLevel.Content, contentType2.GetPropertyType("property2").CacheLevel); + Assert.AreEqual(PropertyCacheLevel.Element, contentType2.GetPropertyType("property2").CacheLevel); var key = Guid.NewGuid(); var keyA = Guid.NewGuid(); @@ -210,7 +208,7 @@ namespace Umbraco.Tests.Facade private IPublishedElement _owner; public TestPublishedProperty(PublishedPropertyType propertyType, object source) - : base(propertyType, PropertyCacheLevel.Content) // initial reference cache level always is .Content + : base(propertyType, PropertyCacheLevel.Element) // initial reference cache level always is .Content { SourceValue = source; HasValue = source != null && (!(source is string ssource) || !string.IsNullOrWhiteSpace(ssource)); diff --git a/src/Umbraco.Tests/Facade/PropertyCacheLevelTests.cs b/src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs similarity index 70% rename from src/Umbraco.Tests/Facade/PropertyCacheLevelTests.cs rename to src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs index e6edb5247c..fb68c334aa 100644 --- a/src/Umbraco.Tests/Facade/PropertyCacheLevelTests.cs +++ b/src/Umbraco.Tests/Published/PropertyCacheLevelTests.cs @@ -9,15 +9,15 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Web; using Umbraco.Web.PublishedCache; -namespace Umbraco.Tests.Facade +namespace Umbraco.Tests.Published { [TestFixture] public class PropertyCacheLevelTests { [TestCase(PropertyCacheLevel.None, 2)] - [TestCase(PropertyCacheLevel.Content, 1)] + [TestCase(PropertyCacheLevel.Element, 1)] + [TestCase(PropertyCacheLevel.Elements, 1)] [TestCase(PropertyCacheLevel.Snapshot, 1)] - [TestCase(PropertyCacheLevel.Facade, 1)] public void CacheLevelTest(PropertyCacheLevel cacheLevel, int interConverts) { var converter = new CacheConverter1(cacheLevel); @@ -63,37 +63,37 @@ namespace Umbraco.Tests.Facade // property is not cached, converted cached at Content, exept // /None = not cached at all [TestCase(PropertyCacheLevel.None, PropertyCacheLevel.None, 2, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.None, PropertyCacheLevel.Content, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.None, PropertyCacheLevel.Element, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.None, PropertyCacheLevel.Elements, 1, 0, 0, 0, 0)] [TestCase(PropertyCacheLevel.None, PropertyCacheLevel.Snapshot, 1, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.None, PropertyCacheLevel.Facade, 1, 0, 0, 0, 0)] - // property is cached at content level, converted cached at + // property is cached at element level, converted cached at // /None = not at all - // /Content = in content - // /Facade = in facade + // /Element = in element // /Snapshot = in snapshot - [TestCase(PropertyCacheLevel.Content, PropertyCacheLevel.None, 2, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Content, PropertyCacheLevel.Content, 1, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Content, PropertyCacheLevel.Snapshot, 1, 1, 0, 1, 0)] - [TestCase(PropertyCacheLevel.Content, PropertyCacheLevel.Facade, 1, 0, 1, 0, 1)] + // /Elements = in elements + [TestCase(PropertyCacheLevel.Element, PropertyCacheLevel.None, 2, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Element, PropertyCacheLevel.Element, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Element, PropertyCacheLevel.Elements, 1, 1, 0, 1, 0)] + [TestCase(PropertyCacheLevel.Element, PropertyCacheLevel.Snapshot, 1, 0, 1, 0, 1)] - // property is cached at snapshot level, converted cached at Content, exept + // property is cached at elements level, converted cached at Element, exept + // /None = not cached at all + // /Snapshot = cached in snapshot + [TestCase(PropertyCacheLevel.Elements, PropertyCacheLevel.None, 2, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Elements, PropertyCacheLevel.Element, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Elements, PropertyCacheLevel.Elements, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Elements, PropertyCacheLevel.Snapshot, 1, 0, 1, 0, 1)] + + // property is cached at snapshot level, converted cached at Element, exept // /None = not cached at all - // /Facade = cached in facade [TestCase(PropertyCacheLevel.Snapshot, PropertyCacheLevel.None, 2, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Snapshot, PropertyCacheLevel.Content, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Snapshot, PropertyCacheLevel.Element, 1, 0, 0, 0, 0)] + [TestCase(PropertyCacheLevel.Snapshot, PropertyCacheLevel.Elements, 1, 0, 0, 0, 0)] [TestCase(PropertyCacheLevel.Snapshot, PropertyCacheLevel.Snapshot, 1, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Snapshot, PropertyCacheLevel.Facade, 1, 0, 1, 0, 1)] - // property is cached at facade level, converted cached at Content, exept - // /None = not cached at all - [TestCase(PropertyCacheLevel.Facade, PropertyCacheLevel.None, 2, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Facade, PropertyCacheLevel.Content, 1, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Facade, PropertyCacheLevel.Snapshot, 1, 0, 0, 0, 0)] - [TestCase(PropertyCacheLevel.Facade, PropertyCacheLevel.Facade, 1, 0, 0, 0, 0)] - - public void CacheFacadeTest(PropertyCacheLevel referenceCacheLevel, PropertyCacheLevel converterCacheLevel, int interConverts, - int snapshotCount1, int facadeCount1, int snapshotCount2, int facadeCount2) + public void CachePublishedSnapshotTest(PropertyCacheLevel referenceCacheLevel, PropertyCacheLevel converterCacheLevel, int interConverts, + int elementsCount1, int snapshotCount1, int elementsCount2, int snapshotCount2) { var converter = new CacheConverter1(converterCacheLevel); @@ -108,47 +108,35 @@ namespace Umbraco.Tests.Facade publishedContentTypeFactory.CreatePropertyType("prop1", 0, "editor1"), }); + var elementsCache = new DictionaryCacheProvider(); var snapshotCache = new DictionaryCacheProvider(); - var facadeCache = new DictionaryCacheProvider(); - var facade = new Mock(); - facade.Setup(x => x.FacadeCache).Returns(facadeCache); - facade.Setup(x => x.SnapshotCache).Returns(snapshotCache); + var publishedSnapshot = new Mock(); + publishedSnapshot.Setup(x => x.SnapshotCache).Returns(snapshotCache); + publishedSnapshot.Setup(x => x.ElementsCache).Returns(elementsCache); - var facadeAccessor = new Mock(); - facadeAccessor.Setup(x => x.Facade).Returns(facade.Object); + var publishedSnapshotAccessor = new Mock(); + publishedSnapshotAccessor.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshot.Object); // pretend we're creating this set as a value for a property // referenceCacheLevel is the cache level for this fictious property // converterCacheLevel is the cache level specified by the converter - var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false, referenceCacheLevel, facadeAccessor.Object); + var set1 = new PublishedElement(setType1, Guid.NewGuid(), new Dictionary { { "prop1", "1234" } }, false, referenceCacheLevel, publishedSnapshotAccessor.Object); Assert.AreEqual(1234, set1.Value("prop1")); Assert.AreEqual(1, converter.SourceConverts); Assert.AreEqual(1, converter.InterConverts); + Assert.AreEqual(elementsCount1, elementsCache.Items.Count); Assert.AreEqual(snapshotCount1, snapshotCache.Items.Count); - Assert.AreEqual(facadeCount1, facadeCache.Items.Count); Assert.AreEqual(1234, set1.Value("prop1")); Assert.AreEqual(1, converter.SourceConverts); Assert.AreEqual(interConverts, converter.InterConverts); + Assert.AreEqual(elementsCount2, elementsCache.Items.Count); Assert.AreEqual(snapshotCount2, snapshotCache.Items.Count); - Assert.AreEqual(facadeCount2, facadeCache.Items.Count); - - var oldFacadeCache = facadeCache; - facadeCache.Items.Clear(); - - Assert.AreEqual(1234, set1.Value("prop1")); - Assert.AreEqual(1, converter.SourceConverts); - - Assert.AreEqual(snapshotCount2, snapshotCache.Items.Count); - Assert.AreEqual(facadeCount2, facadeCache.Items.Count); - Assert.AreEqual(facadeCount2, oldFacadeCache.Items.Count); - - Assert.AreEqual((interConverts == 1 ? 1 : 3) + facadeCache.Items.Count, converter.InterConverts); var oldSnapshotCache = snapshotCache; snapshotCache.Items.Clear(); @@ -156,11 +144,23 @@ namespace Umbraco.Tests.Facade Assert.AreEqual(1234, set1.Value("prop1")); Assert.AreEqual(1, converter.SourceConverts); + Assert.AreEqual(elementsCount2, elementsCache.Items.Count); Assert.AreEqual(snapshotCount2, snapshotCache.Items.Count); Assert.AreEqual(snapshotCount2, oldSnapshotCache.Items.Count); - Assert.AreEqual(facadeCount2, facadeCache.Items.Count); - Assert.AreEqual((interConverts == 1 ? 1 : 4) + facadeCache.Items.Count + snapshotCache.Items.Count, converter.InterConverts); + Assert.AreEqual((interConverts == 1 ? 1 : 3) + snapshotCache.Items.Count, converter.InterConverts); + + var oldElementsCache = elementsCache; + elementsCache.Items.Clear(); + + Assert.AreEqual(1234, set1.Value("prop1")); + Assert.AreEqual(1, converter.SourceConverts); + + Assert.AreEqual(elementsCount2, elementsCache.Items.Count); + Assert.AreEqual(elementsCount2, oldElementsCache.Items.Count); + Assert.AreEqual(snapshotCount2, snapshotCache.Items.Count); + + Assert.AreEqual((interConverts == 1 ? 1 : 4) + snapshotCache.Items.Count + elementsCache.Items.Count, converter.InterConverts); } [Test] @@ -221,14 +221,5 @@ namespace Umbraco.Tests.Facade public object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => ((int) inter).ToString(); } - - // fixme kill - private class TestPublishedElementProperty : PublishedElementPropertyBase - { - public TestPublishedElementProperty(PublishedPropertyType propertyType, IPublishedElement element, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue, - Func> getSnapshotCache, Func> getFacadeCache) - : base(propertyType, element, previewing, referenceCacheLevel, sourceValue) - { } - } } } \ No newline at end of file diff --git a/src/Umbraco.Tests/Facade/FacadeTestObjects.cs b/src/Umbraco.Tests/Published/PublishedSnapshotTestObjects.cs similarity index 98% rename from src/Umbraco.Tests/Facade/FacadeTestObjects.cs rename to src/Umbraco.Tests/Published/PublishedSnapshotTestObjects.cs index 4a8cfe47fb..84668f97a5 100644 --- a/src/Umbraco.Tests/Facade/FacadeTestObjects.cs +++ b/src/Umbraco.Tests/Published/PublishedSnapshotTestObjects.cs @@ -4,9 +4,9 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.Web; using Umbraco.Web.PublishedCache; -namespace Umbraco.Tests.Facade +namespace Umbraco.Tests.Published { - public class FacadeTestObjects + public class PublishedSnapshotTestObjects { #region Published models diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs index e3785f3d80..742b6bd4c6 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs @@ -56,15 +56,15 @@ namespace Umbraco.Tests.PublishedContent { RouteData routeData = null; - var facade = CreateFacade(); + var publishedSnapshot = CreatePublishedSnapshot(); - var facadeService = new Mock(); - facadeService.Setup(x => x.CreateFacade(It.IsAny())).Returns(facade); + var publishedSnapshotService = new Mock(); + publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot); var httpContext = GetHttpContextFactory("http://umbraco.local/", routeData).HttpContext; var umbracoContext = new UmbracoContext( httpContext, - facadeService.Object, + publishedSnapshotService.Object, new WebSecurity(httpContext, Current.Services.UserService), TestObjects.GetUmbracoSettings(), Enumerable.Empty()); @@ -189,10 +189,10 @@ namespace Umbraco.Tests.PublishedContent Assert.AreEqual(2, result[1].Id); } - private static SolidFacade CreateFacade() + private static SolidPublishedShapshot CreatePublishedSnapshot() { var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), Mock.Of()); - var caches = new SolidFacade(); + var caches = new SolidPublishedShapshot(); var cache = caches.InnerContentCache; var props = new[] diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs index cba58d57c2..3defbff700 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs @@ -16,9 +16,9 @@ namespace Umbraco.Tests.PublishedContent public void ConfigureRequest_Returns_False_Without_HasPublishedContent() { var umbracoContext = GetUmbracoContext("/test"); - var facadeRouter = CreateFacadeRouter(); - var request = facadeRouter.CreateRequest(umbracoContext); - var result = facadeRouter.ConfigureRequest(request); + var publishedRouter = CreatePublishedRouter(); + var request = publishedRouter.CreateRequest(umbracoContext); + var result = publishedRouter.ConfigureRequest(request); Assert.IsFalse(result); } @@ -27,13 +27,13 @@ namespace Umbraco.Tests.PublishedContent public void ConfigureRequest_Returns_False_When_IsRedirect() { var umbracoContext = GetUmbracoContext("/test"); - var facadeRouter = CreateFacadeRouter(); - var request = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var request = publishedRouter.CreateRequest(umbracoContext); var content = GetPublishedContentMock(); request.PublishedContent = content.Object; request.Culture = new CultureInfo("en-AU"); request.SetRedirect("/hello"); - var result = facadeRouter.ConfigureRequest(request); + var result = publishedRouter.ConfigureRequest(request); Assert.IsFalse(result); } @@ -42,12 +42,12 @@ namespace Umbraco.Tests.PublishedContent public void ConfigureRequest_Adds_HttpContext_Items_When_Published_Content_Assigned() { var umbracoContext = GetUmbracoContext("/test"); - var facadeRouter = CreateFacadeRouter(); - var request = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var request = publishedRouter.CreateRequest(umbracoContext); var content = GetPublishedContentMock(); request.PublishedContent = content.Object; request.Culture = new CultureInfo("en-AU"); - facadeRouter.ConfigureRequest(request); + publishedRouter.ConfigureRequest(request); Assert.AreEqual(1, umbracoContext.HttpContext.Items["pageID"]); Assert.AreEqual(request.UmbracoPage.Elements.Count, ((Hashtable) umbracoContext.HttpContext.Items["pageElements"]).Count); @@ -57,12 +57,12 @@ namespace Umbraco.Tests.PublishedContent public void ConfigureRequest_Sets_UmbracoPage_When_Published_Content_Assigned() { var umbracoContext = GetUmbracoContext("/test"); - var facadeRouter = CreateFacadeRouter(); - var request = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var request = publishedRouter.CreateRequest(umbracoContext); var content = GetPublishedContentMock(); request.Culture = new CultureInfo("en-AU"); request.PublishedContent = content.Object; - facadeRouter.ConfigureRequest(request); + publishedRouter.ConfigureRequest(request); Assert.IsNotNull(request.UmbracoPage); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs index c774c7a911..53b26b73bc 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs @@ -11,7 +11,7 @@ using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.PublishedContent { - class SolidFacade : IFacade + class SolidPublishedShapshot : IPublishedShapshot { public readonly SolidPublishedContentCache InnerContentCache = new SolidPublishedContentCache(); public readonly SolidPublishedContentCache InnerMediaCache = new SolidPublishedContentCache(); @@ -32,9 +32,9 @@ namespace Umbraco.Tests.PublishedContent public void Resync() { } - public ICacheProvider FacadeCache => null; - public ICacheProvider SnapshotCache => null; + + public ICacheProvider ElementsCache => null; } class SolidPublishedContentCache : PublishedCacheBase, IPublishedContentCache, IPublishedMediaCache diff --git a/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs index e93a84ce2d..09ee0346fb 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByAliasTests.cs @@ -18,8 +18,8 @@ namespace Umbraco.Tests.Routing public void Lookup_By_Url_Alias(string urlAsString, int nodeMatch) { var umbracoContext = GetUmbracoContext(urlAsString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByUrlAlias(Logger); var result = lookup.TryFindContent(frequest); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs index 149b75d1c0..5992463296 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByAliasWithDomainsTests.cs @@ -22,10 +22,10 @@ namespace Umbraco.Tests.Routing //SetDomains1(); var umbracoContext = GetUmbracoContext(inputUrl); - var facadeRouter = CreateFacadeRouter(); - var request = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var request = publishedRouter.CreateRequest(umbracoContext); // must lookup domain - facadeRouter.FindDomain(request); + publishedRouter.FindDomain(request); if (expectedNode > 0) Assert.AreEqual(expectedCulture, request.Culture.Name); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs index 9813e66d45..61c5b4aae9 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByIdTests.cs @@ -13,8 +13,8 @@ namespace Umbraco.Tests.Routing public void Lookup_By_Id(string urlAsString, int nodeMatch) { var umbracoContext = GetUmbracoContext(urlAsString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByIdPath(Logger); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs index bf227d3101..713a8e68d6 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlAndTemplateTests.cs @@ -29,8 +29,8 @@ namespace Umbraco.Tests.Routing var template1 = CreateTemplate("test"); var template2 = CreateTemplate("blah"); var umbracoContext = GetUmbracoContext(urlAsString, template1.Id); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByNiceUrlAndTemplate(Logger); SettingsForTests.HideTopLevelNodeFromPath = false; diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs index 579ad76be7..fe8fbcf8f7 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlTests.cs @@ -26,8 +26,8 @@ namespace Umbraco.Tests.Routing public void Match_Document_By_Url_Hide_Top_Level(string urlString, int expectedId) { var umbracoContext = GetUmbracoContext(urlString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByNiceUrl(Logger); SettingsForTests.HideTopLevelNodeFromPath = true; @@ -59,8 +59,8 @@ namespace Umbraco.Tests.Routing public void Match_Document_By_Url(string urlString, int expectedId) { var umbracoContext = GetUmbracoContext(urlString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByNiceUrl(Logger); SettingsForTests.HideTopLevelNodeFromPath = false; @@ -82,8 +82,8 @@ namespace Umbraco.Tests.Routing public void Match_Document_By_Url_With_Special_Characters(string urlString, int expectedId) { var umbracoContext = GetUmbracoContext(urlString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByNiceUrl(Logger); SettingsForTests.HideTopLevelNodeFromPath = false; @@ -107,8 +107,8 @@ namespace Umbraco.Tests.Routing public void Match_Document_By_Url_With_Special_Characters_Using_Hostname(string urlString, int expectedId) { var umbracoContext = GetUmbracoContext(urlString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); frequest.Domain = new DomainAndUri(new Domain(1, "mysite", -1, CultureInfo.CurrentCulture, false), new Uri("http://mysite/")); var lookup = new ContentFinderByNiceUrl(Logger); SettingsForTests.HideTopLevelNodeFromPath = false; @@ -134,8 +134,8 @@ namespace Umbraco.Tests.Routing public void Match_Document_By_Url_With_Special_Characters_In_Hostname(string urlString, int expectedId) { var umbracoContext = GetUmbracoContext(urlString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); frequest.Domain = new DomainAndUri(new Domain(1, "mysite/æøå", -1, CultureInfo.CurrentCulture, false), new Uri("http://mysite/æøå")); var lookup = new ContentFinderByNiceUrl(Logger); SettingsForTests.HideTopLevelNodeFromPath = false; diff --git a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs index bdffa14251..e05fed11dc 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByNiceUrlWithDomainsTests.cs @@ -126,11 +126,11 @@ namespace Umbraco.Tests.Routing SettingsForTests.HideTopLevelNodeFromPath = true; var umbracoContext = GetUmbracoContext(url); - var facadeRouter = CreateFacadeRouter(Container); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(Container); + var frequest = publishedRouter.CreateRequest(umbracoContext); // must lookup domain else lookup by url fails - facadeRouter.FindDomain(frequest); + publishedRouter.FindDomain(frequest); var lookup = new ContentFinderByNiceUrl(Logger); var result = lookup.TryFindContent(frequest); @@ -167,11 +167,11 @@ namespace Umbraco.Tests.Routing SettingsForTests.HideTopLevelNodeFromPath = true; var umbracoContext = GetUmbracoContext(url); - var facadeRouter = CreateFacadeRouter(Container); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(Container); + var frequest = publishedRouter.CreateRequest(umbracoContext); // must lookup domain else lookup by url fails - facadeRouter.FindDomain(frequest); + publishedRouter.FindDomain(frequest); Assert.AreEqual(expectedCulture, frequest.Culture.Name); var lookup = new ContentFinderByNiceUrl(Logger); diff --git a/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs b/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs index d1179e5e05..c557d61e7e 100644 --- a/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs +++ b/src/Umbraco.Tests/Routing/ContentFinderByPageIdQueryTests.cs @@ -16,8 +16,8 @@ namespace Umbraco.Tests.Routing public void Lookup_By_Page_Id(string urlAsString, int nodeMatch) { var umbracoContext = GetUmbracoContext(urlAsString); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); var lookup = new ContentFinderByPageIdQuery(); //we need to manually stub the return output of HttpContext.Request["umbPageId"] diff --git a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs index 31107530b6..e67248cdfa 100644 --- a/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs +++ b/src/Umbraco.Tests/Routing/DomainsAndCulturesTests.cs @@ -264,11 +264,11 @@ namespace Umbraco.Tests.Routing SetDomains1(); var umbracoContext = GetUmbracoContext(inputUrl); - var facadeRouter = CreateFacadeRouter(Container); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(Container); + var frequest = publishedRouter.CreateRequest(umbracoContext); // lookup domain - facadeRouter.FindDomain(frequest); + publishedRouter.FindDomain(frequest); Assert.AreEqual(expectedCulture, frequest.Culture.Name); @@ -311,11 +311,11 @@ namespace Umbraco.Tests.Routing expectedCulture = expectedCulture ?? System.Threading.Thread.CurrentThread.CurrentUICulture.Name; var umbracoContext = GetUmbracoContext(inputUrl); - var facadeRouter = CreateFacadeRouter(Container); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(Container); + var frequest = publishedRouter.CreateRequest(umbracoContext); // lookup domain - facadeRouter.FindDomain(frequest); + publishedRouter.FindDomain(frequest); // find document SettingsForTests.HideTopLevelNodeFromPath = false; @@ -323,7 +323,7 @@ namespace Umbraco.Tests.Routing var result = finder.TryFindContent(frequest); // apply wildcard domain - facadeRouter.HandleWildcardDomains(frequest); + publishedRouter.HandleWildcardDomains(frequest); Assert.IsTrue(result); Assert.AreEqual(expectedCulture, frequest.Culture.Name); diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs index 7511a816c3..2091064889 100644 --- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs +++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs @@ -99,8 +99,8 @@ namespace Umbraco.Tests.Routing var route = RouteTable.Routes["Umbraco_default"]; var routeData = new RouteData { Route = route }; var umbracoContext = GetUmbracoContext("~/dummy-page", template.Id, routeData); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); frequest.PublishedContent = umbracoContext.ContentCache.GetById(1174); frequest.TemplateModel = template; frequest.RenderingEngine = RenderingEngine.Mvc; @@ -135,8 +135,8 @@ namespace Umbraco.Tests.Routing var route = RouteTable.Routes["Umbraco_default"]; var routeData = new RouteData() {Route = route}; var umbracoContext = GetUmbracoContext("~/dummy-page", template.Id, routeData, true); - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); frequest.PublishedContent = umbracoContext.ContentCache.GetById(1172); frequest.TemplateModel = template; diff --git a/src/Umbraco.Tests/Routing/RoutesCacheTests.cs b/src/Umbraco.Tests/Routing/RoutesCacheTests.cs index 83ee2363e6..e12d8523a6 100644 --- a/src/Umbraco.Tests/Routing/RoutesCacheTests.cs +++ b/src/Umbraco.Tests/Routing/RoutesCacheTests.cs @@ -19,7 +19,7 @@ namespace Umbraco.Tests.Routing { //var routingContext = GetRoutingContext("/test", 1111); var umbracoContext = GetUmbracoContext("/test", 0); - var cache = umbracoContext.Facade.ContentCache as PublishedContentCache; + var cache = umbracoContext.PublishedShapshot.ContentCache as PublishedContentCache; if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported."); // fixme not sure? diff --git a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs index 6f374cb514..857f91f0c9 100644 --- a/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs +++ b/src/Umbraco.Tests/Routing/UrlsWithNestedDomains.cs @@ -50,10 +50,10 @@ namespace Umbraco.Tests.Routing Assert.AreEqual("10011/1001-1-1", cachedRoutes[100111]); // route a rogue url - var facadeRouter = CreateFacadeRouter(); - var frequest = facadeRouter.CreateRequest(umbracoContext); + var publishedRouter = CreatePublishedRouter(); + var frequest = publishedRouter.CreateRequest(umbracoContext); - facadeRouter.FindDomain(frequest); + publishedRouter.FindDomain(frequest); Assert.IsTrue(frequest.HasDomain); // check that it's been routed diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs index 94f3004f7a..406a3e1ccb 100644 --- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs @@ -27,7 +27,7 @@ using Umbraco.Web.Security; namespace Umbraco.Tests.Scoping { [TestFixture] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class ScopedNuCacheTests : TestWithDatabaseBase { private CacheRefresherComponent _cacheRefresher; @@ -64,31 +64,31 @@ namespace Umbraco.Tests.Scoping private Action _onPublishedAssertAction; - protected override IFacadeService CreateFacadeService() + protected override IPublishedSnapshotService CreatePublishedSnapshotService() { - var options = new FacadeService.Options { IgnoreLocalDb = true }; - var facadeAccessor = new UmbracoContextFacadeAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor); + var options = new PublishedSnapshotService.Options { IgnoreLocalDb = true }; + var publishedSnapshotAccessor = new UmbracoContextPublishedSnapshotAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor); var runtimeStateMock = new Mock(); runtimeStateMock.Setup(x => x.Level).Returns(() => RuntimeLevel.Run); var contentTypeFactory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), Mock.Of()); - return new FacadeService( + return new PublishedSnapshotService( options, null, runtimeStateMock.Object, ServiceContext, contentTypeFactory, UowProvider, - facadeAccessor, + publishedSnapshotAccessor, Logger, ScopeProvider); } protected UmbracoContext GetUmbracoContextNu(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable urlProviders = null) { - // ensure we have a FacadeService - var service = FacadeService as FacadeService; + // ensure we have a PublishedSnapshotService + var service = PublishedSnapshotService as PublishedSnapshotService; var httpContext = GetHttpContextFactory(url, routeData).HttpContext; diff --git a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs index 8f2199c921..5ec5fcb954 100644 --- a/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedXmlTests.cs @@ -19,7 +19,7 @@ using Umbraco.Web.PublishedCache.XmlPublishedCache; namespace Umbraco.Tests.Scoping { [TestFixture] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class ScopedXmlTests : TestWithDatabaseBase { private CacheRefresherComponent _cacheRefresher; @@ -63,7 +63,7 @@ namespace Umbraco.Tests.Scoping // xmlStore.Xml - the actual main xml document // publishedContentCache.GetXml() - the captured xml - private static XmlStore XmlStore => (Current.Container.GetInstance() as FacadeService).XmlStore; + private static XmlStore XmlStore => (Current.Container.GetInstance() as PublishedSnapshotService).XmlStore; private static XmlDocument XmlMaster => XmlStore.Xml; private static XmlDocument XmlInContext => ((PublishedContentCache) Umbraco.Web.Composing.Current.UmbracoContext.ContentCache).GetXml(false); diff --git a/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs b/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs index 4aa4f6871e..19bacce0ad 100644 --- a/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs +++ b/src/Umbraco.Tests/Security/BackOfficeCookieManagerTests.cs @@ -28,7 +28,7 @@ namespace Umbraco.Tests.Security var umbracoContext = new UmbracoContext( Mock.Of(), - Mock.Of(), + Mock.Of(), new WebSecurity(Mock.Of(), Current.Services.UserService), TestObjects.GetUmbracoSettings(), new List()); @@ -45,7 +45,7 @@ namespace Umbraco.Tests.Security { var umbCtx = new UmbracoContext( Mock.Of(), - Mock.Of(), + Mock.Of(), new WebSecurity(Mock.Of(), Current.Services.UserService), TestObjects.GetUmbracoSettings(), new List()); diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index d6fa3252df..90222cdd5b 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -28,7 +28,7 @@ namespace Umbraco.Tests.Services /// as well as configuration. /// [TestFixture, RequiresSTA] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class ContentServiceTests : TestWithSomeContentBase { //TODO Add test to verify there is only ONE newest document/content in cmsDocument table after updating. diff --git a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs index dcaf254658..6d6ba2e071 100644 --- a/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentTypeServiceTests.cs @@ -17,7 +17,7 @@ using Umbraco.Tests.Testing; namespace Umbraco.Tests.Services { [TestFixture, RequiresSTA] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class ContentTypeServiceTests : TestWithSomeContentBase { [Test] diff --git a/src/Umbraco.Tests/Services/MediaServiceTests.cs b/src/Umbraco.Tests/Services/MediaServiceTests.cs index 01643c6c60..0bc2a57ee3 100644 --- a/src/Umbraco.Tests/Services/MediaServiceTests.cs +++ b/src/Umbraco.Tests/Services/MediaServiceTests.cs @@ -17,7 +17,7 @@ using Umbraco.Tests.Testing; namespace Umbraco.Tests.Services { [TestFixture, RequiresSTA] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class MediaServiceTests : TestWithSomeContentBase { [Test] diff --git a/src/Umbraco.Tests/Services/MemberServiceTests.cs b/src/Umbraco.Tests/Services/MemberServiceTests.cs index 310302c887..af867e7b3f 100644 --- a/src/Umbraco.Tests/Services/MemberServiceTests.cs +++ b/src/Umbraco.Tests/Services/MemberServiceTests.cs @@ -22,7 +22,7 @@ using Umbraco.Web.Security.Providers; namespace Umbraco.Tests.Services { [TestFixture, RequiresSTA] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class MemberServiceTests : TestWithSomeContentBase { public override void SetUp() diff --git a/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs b/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs index 8e7166a81b..c30ac09d3d 100644 --- a/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs +++ b/src/Umbraco.Tests/Services/MemberTypeServiceTests.cs @@ -13,7 +13,7 @@ using Umbraco.Tests.Testing; namespace Umbraco.Tests.Services { [TestFixture, RequiresSTA] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, FacadeServiceRepositoryEvents = true)] + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, PublishedRepositoryEvents = true)] public class MemberTypeServiceTests : TestWithSomeContentBase { [Test] diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs index a80c174b0f..b58a9856ca 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs @@ -66,14 +66,14 @@ namespace Umbraco.Tests.TestHelpers "; } - internal FacadeRouter CreateFacadeRouter(IServiceContainer container = null, ContentFinderCollection contentFinders = null) + internal PublishedRouter CreatePublishedRouter(IServiceContainer container = null, ContentFinderCollection contentFinders = null) { - return CreateFacadeRouter(TestObjects.GetUmbracoSettings().WebRouting, container, contentFinders); + return CreatePublishedRouter(TestObjects.GetUmbracoSettings().WebRouting, container, contentFinders); } - internal static FacadeRouter CreateFacadeRouter(IWebRoutingSection webRoutingSection, IServiceContainer container = null, ContentFinderCollection contentFinders = null) + internal static PublishedRouter CreatePublishedRouter(IWebRoutingSection webRoutingSection, IServiceContainer container = null, ContentFinderCollection contentFinders = null) { - return new FacadeRouter( + return new PublishedRouter( webRoutingSection, contentFinders ?? new ContentFinderCollection(Enumerable.Empty()), new TestLastChanceFinder(), diff --git a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs index 31cec1451a..8f14b221ed 100644 --- a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs +++ b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs @@ -122,10 +122,10 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting webSecurity.Setup(x => x.UserHasSectionAccess(It.IsAny(), It.IsAny())) .Returns(() => true); - var facade = new Mock(); - facade.Setup(x => x.MemberCache).Returns(Mock.Of()); - var facadeService = new Mock(); - facadeService.Setup(x => x.CreateFacade(It.IsAny())).Returns(facade.Object); + var publishedSnapshot = new Mock(); + publishedSnapshot.Setup(x => x.MemberCache).Returns(Mock.Of()); + var publishedSnapshotService = new Mock(); + publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot.Object); //var umbracoContextAccessor = new TestUmbracoContextAccessor(); //Umbraco.Web.Composing.Current.UmbracoContextAccessor = umbracoContextAccessor; @@ -135,7 +135,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting var umbCtx = UmbracoContext.EnsureContext( umbracoContextAccessor, httpContext, - facadeService.Object, + publishedSnapshotService.Object, webSecurity.Object, Mock.Of(section => section.WebRouting == Mock.Of(routingSection => routingSection.UrlProviderMode == UrlProviderMode.Auto.ToString())), Enumerable.Empty(), diff --git a/src/Umbraco.Tests/TestHelpers/Stubs/TestFacadeAccessor.cs b/src/Umbraco.Tests/TestHelpers/Stubs/TestFacadeAccessor.cs deleted file mode 100644 index 46ebe9a47f..0000000000 --- a/src/Umbraco.Tests/TestHelpers/Stubs/TestFacadeAccessor.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Umbraco.Web.PublishedCache; - -namespace Umbraco.Tests.TestHelpers.Stubs -{ - public class TestFacadeAccessor : IFacadeAccessor - { - public IFacade Facade { get; set; } - } -} diff --git a/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedSnapshotAccessor.cs b/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedSnapshotAccessor.cs new file mode 100644 index 0000000000..10c8739029 --- /dev/null +++ b/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedSnapshotAccessor.cs @@ -0,0 +1,9 @@ +using Umbraco.Web.PublishedCache; + +namespace Umbraco.Tests.TestHelpers.Stubs +{ + public class TestPublishedSnapshotAccessor : IPublishedSnapshotAccessor + { + public IPublishedShapshot PublishedSnapshot { get; set; } + } +} diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs index c250cb4a9c..aac30c2662 100644 --- a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs +++ b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs @@ -111,20 +111,19 @@ namespace Umbraco.Tests.TestHelpers { var httpContext = Mock.Of(); - //var facadeService = Mock.Of(); - var facadeMock = new Mock(); - facadeMock.Setup(x => x.MemberCache).Returns(Mock.Of()); - var facade = facadeMock.Object; - var facadeServiceMock = new Mock(); - facadeServiceMock.Setup(x => x.CreateFacade(It.IsAny())).Returns(facade); - var facadeService = facadeServiceMock.Object; + var publishedSnapshotMock = new Mock(); + publishedSnapshotMock.Setup(x => x.MemberCache).Returns(Mock.Of()); + var publishedSnapshot = publishedSnapshotMock.Object; + var publishedSnapshotServiceMock = new Mock(); + publishedSnapshotServiceMock.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot); + var publishedSnapshotService = publishedSnapshotServiceMock.Object; var webSecurity = new Mock(null, null).Object; var settings = GetUmbracoSettings(); var urlProviders = Enumerable.Empty(); if (accessor == null) accessor = new TestUmbracoContextAccessor(); - return UmbracoContext.EnsureContext(accessor, httpContext, facadeService, webSecurity, settings, urlProviders, true); + return UmbracoContext.EnsureContext(accessor, httpContext, publishedSnapshotService, webSecurity, settings, urlProviders, true); } public IUmbracoSettingsSection GetUmbracoSettings() diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index 49c9db2ca3..9767cb1393 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -76,7 +76,7 @@ namespace Umbraco.Tests.TestHelpers base.Compose(); Container.Register(); - Container.Register(factory => FacadeService); + Container.Register(factory => PublishedSnapshotService); Container.GetInstance() .Clear() @@ -115,8 +115,8 @@ namespace Umbraco.Tests.TestHelpers AppDomain.CurrentDomain.SetData("DataDirectory", null); // make sure we dispose of the service to unbind events - FacadeService?.Dispose(); - FacadeService = null; + PublishedSnapshotService?.Dispose(); + PublishedSnapshotService = null; } finally { @@ -227,7 +227,7 @@ namespace Umbraco.Tests.TestHelpers } } - protected IFacadeService FacadeService { get; set; } + protected IPublishedSnapshotService PublishedSnapshotService { get; set; } protected override void Initialize() // fixme - should NOT be here! { @@ -235,14 +235,14 @@ namespace Umbraco.Tests.TestHelpers CreateAndInitializeDatabase(); - // ensure we have a FacadeService - if (FacadeService == null) + // ensure we have a PublishedSnapshotService + if (PublishedSnapshotService == null) { - FacadeService = CreateFacadeService(); + PublishedSnapshotService = CreatePublishedSnapshotService(); } } - protected virtual IFacadeService CreateFacadeService() + protected virtual IPublishedSnapshotService CreatePublishedSnapshotService() { var cache = new NullCacheProvider(); @@ -254,14 +254,14 @@ namespace Umbraco.Tests.TestHelpers Current.Logger); // testing=true so XmlStore will not use the file nor the database - //var facadeAccessor = new TestFacadeAccessor(); - var facadeAccessor = new UmbracoContextFacadeAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor); - var service = new FacadeService( + + var publishedSnapshotAccessor = new UmbracoContextPublishedSnapshotAccessor(Umbraco.Web.Composing.Current.UmbracoContextAccessor); + var service = new PublishedSnapshotService( Current.Services, Container.GetInstance(), (ScopeProvider) Current.ScopeProvider, UowProvider, - cache, facadeAccessor, Current.Logger, ContentTypesCache, null, true, Options.FacadeServiceRepositoryEvents); + cache, publishedSnapshotAccessor, Current.Logger, ContentTypesCache, null, true, Options.PublishedRepositoryEvents); // initialize PublishedCacheService content with an Xml source service.XmlStore.GetXmlDocument = () => @@ -340,7 +340,7 @@ namespace Umbraco.Tests.TestHelpers protected UmbracoContext GetUmbracoContext(string url, int templateId = 1234, RouteData routeData = null, bool setSingleton = false, IUmbracoSettingsSection umbracoSettings = null, IEnumerable urlProviders = null) { // ensure we have a PublishedCachesService - var service = FacadeService as FacadeService; + var service = PublishedSnapshotService as PublishedSnapshotService; if (service == null) throw new Exception("Not a proper XmlPublishedCache.PublishedCachesService."); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs b/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs index ced4528cb6..723ce43c6c 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestAttribute.cs @@ -27,8 +27,8 @@ namespace Umbraco.Tests.Testing /// /// Gets or sets a value indicating ... FIXME to be completed /// - public bool FacadeServiceRepositoryEvents { get => _facadeServiceRepositoryEvents.ValueOrDefault(false); set => _facadeServiceRepositoryEvents.Set(value); } - private readonly Settable _facadeServiceRepositoryEvents = new Settable(); + public bool PublishedRepositoryEvents { get => _publishedRepositoryEvents.ValueOrDefault(false); set => _publishedRepositoryEvents.Set(value); } + private readonly Settable _publishedRepositoryEvents = new Settable(); /// /// Gets or sets a value indicating the required logging support. @@ -59,7 +59,7 @@ namespace Umbraco.Tests.Testing base.Merge(other); _autoMapper.Set(attr._autoMapper); - _facadeServiceRepositoryEvents.Set(attr._facadeServiceRepositoryEvents); + _publishedRepositoryEvents.Set(attr._publishedRepositoryEvents); _logger.Set(attr._logger); _database.Set(attr._database); _pluginManager.Set(attr._pluginManager); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 83ecf0e946..1d7eb5aa43 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -224,10 +224,10 @@ - - - - + + + + @@ -243,7 +243,7 @@ - + @@ -280,7 +280,7 @@ - + diff --git a/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs b/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs index 1b5cc4066f..2afeb3ffba 100644 --- a/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/RenderIndexActionSelectorAttributeTests.cs @@ -66,7 +66,7 @@ namespace Umbraco.Tests.Web.Mvc var umbCtx = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, Mock.Of(), - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), @@ -87,7 +87,7 @@ namespace Umbraco.Tests.Web.Mvc var umbCtx = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, Mock.Of(), - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), @@ -108,7 +108,7 @@ namespace Umbraco.Tests.Web.Mvc var umbCtx = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, Mock.Of(), - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), @@ -129,7 +129,7 @@ namespace Umbraco.Tests.Web.Mvc var umbCtx = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, Mock.Of(), - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), diff --git a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs index df1c927fc2..40ae110295 100644 --- a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs @@ -39,7 +39,7 @@ namespace Umbraco.Tests.Web.Mvc var umbracoContext = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, new Mock().Object, - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), @@ -58,7 +58,7 @@ namespace Umbraco.Tests.Web.Mvc var umbCtx = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, new Mock().Object, - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), @@ -75,7 +75,7 @@ namespace Umbraco.Tests.Web.Mvc var umbracoContext = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, new Mock().Object, - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, TestObjects.GetUmbracoSettings(), Enumerable.Empty(), @@ -91,15 +91,15 @@ namespace Umbraco.Tests.Web.Mvc [Test] public void Can_Lookup_Content() { - var facade = new Mock(); - facade.Setup(x => x.MemberCache).Returns(Mock.Of()); - var facadeService = new Mock(); - facadeService.Setup(x => x.CreateFacade(It.IsAny())).Returns(facade.Object); + var publishedSnapshot = new Mock(); + publishedSnapshot.Setup(x => x.MemberCache).Returns(Mock.Of()); + var publishedSnapshotService = new Mock(); + publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot.Object); var umbracoContext = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, new Mock().Object, - facadeService.Object, + publishedSnapshotService.Object, new Mock(null, null).Object, Mock.Of(section => section.WebRouting == Mock.Of(routingSection => routingSection.UrlProviderMode == "AutoLegacy")), Enumerable.Empty(), @@ -134,7 +134,7 @@ namespace Umbraco.Tests.Web.Mvc var umbracoContext = UmbracoContext.EnsureContext( Current.UmbracoContextAccessor, new Mock().Object, - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, Mock.Of(section => section.WebRouting == webRoutingSettings), Enumerable.Empty(), @@ -143,8 +143,8 @@ namespace Umbraco.Tests.Web.Mvc var content = Mock.Of(publishedContent => publishedContent.Id == 12345); var contextBase = umbracoContext.HttpContext; - var facadeRouter = BaseWebTest.CreateFacadeRouter(TestObjects.GetUmbracoSettings().WebRouting); - var frequest = facadeRouter.CreateRequest(umbracoContext, new Uri("http://localhost/test")); + var publishedRouter = BaseWebTest.CreatePublishedRouter(TestObjects.GetUmbracoSettings().WebRouting); + var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/test")); frequest.PublishedContent = content; var routeDefinition = new RouteDefinition diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs index f71d6a7434..4d27bacb6a 100644 --- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs @@ -33,7 +33,7 @@ namespace Umbraco.Tests.Web.Mvc [UmbracoTest(WithApplication = true)] public class UmbracoViewPageTests : UmbracoTestBase { - private FacadeService _service; + private PublishedSnapshotService _service; [TearDown] public override void TearDown() @@ -395,8 +395,8 @@ namespace Umbraco.Tests.Web.Mvc logger, settings, "/dang", 0); - var facadeRouter = BaseWebTest.CreateFacadeRouter(TestObjects.GetUmbracoSettings().WebRouting); - var frequest = facadeRouter.CreateRequest(umbracoContext, new Uri("http://localhost/dang")); + var publishedRouter = BaseWebTest.CreatePublishedRouter(TestObjects.GetUmbracoSettings().WebRouting); + var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/dang")); frequest.Culture = CultureInfo.InvariantCulture; umbracoContext.PublishedContentRequest = frequest; @@ -425,7 +425,7 @@ namespace Umbraco.Tests.Web.Mvc var scopeProvider = TestObjects.GetScopeProvider(Mock.Of()); var uowProvider = TestObjects.GetScopeUnitOfWorkProvider(Mock.Of(), scopeProvider: scopeProvider); var factory = Mock.Of(); - _service = new FacadeService(svcCtx, factory, scopeProvider, uowProvider, cache, Enumerable.Empty(), null, Current.Logger, null, true, false); // no events + _service = new PublishedSnapshotService(svcCtx, factory, scopeProvider, uowProvider, cache, Enumerable.Empty(), null, Current.Logger, null, true, false); // no events var http = GetHttpContextFactory(url, routeData).HttpContext; diff --git a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs index e5aff59f56..b4d870e702 100644 --- a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs @@ -78,7 +78,7 @@ namespace Umbraco.Tests.Web using (var umbCtx = UmbracoContext.EnsureContext( Umbraco.Web.Composing.Current.UmbracoContextAccessor, Mock.Of(), - Mock.Of(), + Mock.Of(), new Mock(null, null).Object, //setup a quick mock of the WebRouting section Mock.Of(section => section.WebRouting == Mock.Of(routingSection => routingSection.UrlProviderMode == "AutoLegacy")), diff --git a/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs b/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs index c909f84ac5..7b53d624a0 100644 --- a/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs +++ b/src/Umbraco.Tests/Web/WebExtensionMethodTests.cs @@ -25,7 +25,7 @@ namespace Umbraco.Tests.Web { var umbCtx = new UmbracoContext( Mock.Of(), - Mock.Of(), + Mock.Of(), new WebSecurity(Mock.Of(), Current.Services.UserService), TestObjects.GetUmbracoSettings(), new List()); @@ -41,7 +41,7 @@ namespace Umbraco.Tests.Web { var umbCtx = new UmbracoContext( Mock.Of(), - Mock.Of(), + Mock.Of(), new WebSecurity(Mock.Of(), Current.Services.UserService), TestObjects.GetUmbracoSettings(), new List()); @@ -67,7 +67,7 @@ namespace Umbraco.Tests.Web { var umbCtx = new UmbracoContext( Mock.Of(), - Mock.Of(), + Mock.Of(), new WebSecurity(Mock.Of(), Current.Services.UserService), TestObjects.GetUmbracoSettings(), new List()); diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.controller.js deleted file mode 100644 index d08ee5a249..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.controller.js +++ /dev/null @@ -1,15 +0,0 @@ -function facadeStatusController($scope, umbRequestHelper, $log, $http, $q, $timeout) { - - // note: must defined 'facaStatusBaseUrl' in BackOfficeController - - umbRequestHelper.resourcePromise( - $http.get(umbRequestHelper.getApiUrl('facadeStatusBaseUrl', 'GetFacadeStatusUrl')), - 'Failed to get facade status url') - .then(function (result) { - $scope.includeUrl = angular.fromJson(result); - }); - - //$scope.includeUrl = 'views/dashboard/developer/xmldataintegrityreport.html'; - -} -angular.module("umbraco").controller("Umbraco.Dashboard.FacadeStatusController", facadeStatusController); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.html deleted file mode 100644 index 7c09ad6fa9..0000000000 --- a/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/facadestatus.html +++ /dev/null @@ -1,9 +0,0 @@ -
-

Facade Status

- -
- Loading... -
- -
-
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.controller.js b/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.controller.js new file mode 100644 index 0000000000..2997369f29 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.controller.js @@ -0,0 +1,15 @@ +function publishedStatusController($scope, umbRequestHelper, $log, $http, $q, $timeout) { + + // note: must defined base url in BackOfficeController + + umbRequestHelper.resourcePromise( + $http.get(umbRequestHelper.getApiUrl('publishedStatusBaseUrl', 'GetPublishedStatusUrl')), + 'Failed to get published status url') + .then(function (result) { + $scope.includeUrl = angular.fromJson(result); + }); + + //$scope.includeUrl = 'views/dashboard/developer/xmldataintegrityreport.html'; + +} +angular.module("umbraco").controller("Umbraco.Dashboard.PublishedStatusController", publishedStatusController); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.html b/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.html new file mode 100644 index 0000000000..29d136d107 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/dashboard/developer/publishedstatus.html @@ -0,0 +1,9 @@ +
+

Published Status

+ +
+ Loading... +
+ +
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/config/Dashboard.Release.config b/src/Umbraco.Web.UI/config/Dashboard.Release.config index 04a9a2935f..c068e4c1de 100644 --- a/src/Umbraco.Web.UI/config/Dashboard.Release.config +++ b/src/Umbraco.Web.UI/config/Dashboard.Release.config @@ -37,9 +37,9 @@ views/dashboard/developer/examinemanagement.html - + - views/dashboard/developer/facadestatus.html + views/dashboard/developer/publishedstatus.html diff --git a/src/Umbraco.Web.UI/config/Dashboard.config b/src/Umbraco.Web.UI/config/Dashboard.config index 960cc4299d..4eb96d424b 100644 --- a/src/Umbraco.Web.UI/config/Dashboard.config +++ b/src/Umbraco.Web.UI/config/Dashboard.config @@ -34,9 +34,9 @@ views/dashboard/developer/examinemanagement.html - + - views/dashboard/developer/facadestatus.html + views/dashboard/developer/publishedstatus.html diff --git a/src/Umbraco.Web/Cache/ContentCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentCacheRefresher.cs index 258c8df86d..021a56d5d9 100644 --- a/src/Umbraco.Web/Cache/ContentCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentCacheRefresher.cs @@ -13,12 +13,12 @@ namespace Umbraco.Web.Cache { public sealed class ContentCacheRefresher : PayloadCacheRefresherBase { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; - public ContentCacheRefresher(CacheHelper cacheHelper, IFacadeService facadeService) + public ContentCacheRefresher(CacheHelper cacheHelper, IPublishedSnapshotService publishedSnapshotService) : base(cacheHelper) { - _facadeService = facadeService; + _publishedSnapshotService = publishedSnapshotService; } #region Define @@ -67,7 +67,7 @@ namespace Umbraco.Web.Cache //if (Suspendable.PageCacheRefresher.CanUpdateDocumentCache) // ... - _facadeService.Notify(payloads, out _, out var publishedChanged); + _publishedSnapshotService.Notify(payloads, out _, out var publishedChanged); if (payloads.Any(x => x.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) || publishedChanged) { diff --git a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs index c3c9db9ddb..210845e419 100644 --- a/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/ContentTypeCacheRefresher.cs @@ -10,13 +10,13 @@ namespace Umbraco.Web.Cache { public sealed class ContentTypeCacheRefresher : PayloadCacheRefresherBase { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; private readonly IdkMap _idkMap; - public ContentTypeCacheRefresher(CacheHelper cacheHelper, IFacadeService facadeService, IdkMap idkMap) + public ContentTypeCacheRefresher(CacheHelper cacheHelper, IPublishedSnapshotService publishedSnapshotService, IdkMap idkMap) : base(cacheHelper) { - _facadeService = facadeService; + _publishedSnapshotService = publishedSnapshotService; _idkMap = idkMap; } @@ -77,7 +77,7 @@ namespace Umbraco.Web.Cache MemberCacheRefresher.RefreshMemberTypes(CacheHelper); // notify - _facadeService.Notify(payloads); + _publishedSnapshotService.Notify(payloads); // now we can trigger the event base.Refresh(payloads); diff --git a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs index 1eaba364a5..9f93718521 100644 --- a/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DataTypeCacheRefresher.cs @@ -12,13 +12,13 @@ namespace Umbraco.Web.Cache { public sealed class DataTypeCacheRefresher : PayloadCacheRefresherBase { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; private readonly IdkMap _idkMap; - public DataTypeCacheRefresher(CacheHelper cacheHelper, IFacadeService facadeService, IdkMap idkMap) + public DataTypeCacheRefresher(CacheHelper cacheHelper, IPublishedSnapshotService publishedSnapshotService, IdkMap idkMap) : base(cacheHelper) { - _facadeService = facadeService; + _publishedSnapshotService = publishedSnapshotService; _idkMap = idkMap; } @@ -66,7 +66,7 @@ namespace Umbraco.Web.Cache MediaPickerValueConverter.ClearCaches(); // notify - _facadeService.Notify(payloads); + _publishedSnapshotService.Notify(payloads); base.Refresh(payloads); } diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs index 8b74b78254..01b974435b 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs @@ -225,9 +225,9 @@ namespace Umbraco.Web.Cache #endregion - #region Facade + #region Published Snapshot - public static void RefreshAllFacade(this DistributedCache dc) + public static void RefreshAllPublishedSnapshot(this DistributedCache dc) { // note: refresh all content & media caches does refresh content types too dc.RefreshAllContentCache(); diff --git a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs index 2ddf38a29b..5e3c0220a8 100644 --- a/src/Umbraco.Web/Cache/DomainCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/DomainCacheRefresher.cs @@ -8,12 +8,12 @@ namespace Umbraco.Web.Cache { public sealed class DomainCacheRefresher : PayloadCacheRefresherBase { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; - public DomainCacheRefresher(CacheHelper cacheHelper, IFacadeService facadeService) + public DomainCacheRefresher(CacheHelper cacheHelper, IPublishedSnapshotService publishedSnapshotService) : base(cacheHelper) { - _facadeService = facadeService; + _publishedSnapshotService = publishedSnapshotService; } #region Define @@ -39,7 +39,7 @@ namespace Umbraco.Web.Cache // the new content... // notify - _facadeService.Notify(payloads); + _publishedSnapshotService.Notify(payloads); // then trigger event base.Refresh(payloads); } diff --git a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs index 5c09e58baf..c1ea750185 100644 --- a/src/Umbraco.Web/Cache/MediaCacheRefresher.cs +++ b/src/Umbraco.Web/Cache/MediaCacheRefresher.cs @@ -14,13 +14,13 @@ namespace Umbraco.Web.Cache { public sealed class MediaCacheRefresher : PayloadCacheRefresherBase { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; private readonly IdkMap _idkMap; - public MediaCacheRefresher(CacheHelper cacheHelper, IFacadeService facadeService, IdkMap idkMap) + public MediaCacheRefresher(CacheHelper cacheHelper, IPublishedSnapshotService publishedSnapshotService, IdkMap idkMap) : base(cacheHelper) { - _facadeService = facadeService; + _publishedSnapshotService = publishedSnapshotService; _idkMap = idkMap; } @@ -41,7 +41,7 @@ namespace Umbraco.Web.Cache public override void Refresh(JsonPayload[] payloads) { bool anythingChanged; - _facadeService.Notify(payloads, out anythingChanged); + _publishedSnapshotService.Notify(payloads, out anythingChanged); if (anythingChanged) { diff --git a/src/Umbraco.Web/Composing/Current.cs b/src/Umbraco.Web/Composing/Current.cs index 275fc119b5..060279aae9 100644 --- a/src/Umbraco.Web/Composing/Current.cs +++ b/src/Umbraco.Web/Composing/Current.cs @@ -98,8 +98,8 @@ namespace Umbraco.Web.Composing public static DistributedCache DistributedCache => Container.GetInstance(); - public static IFacade Facade - => Container.GetInstance().Facade; + public static IPublishedShapshot PublishedSnapshot + => Container.GetInstance().PublishedSnapshot; public static EventMessages EventMessages => Container.GetInstance().GetOrDefault(); @@ -143,8 +143,8 @@ namespace Umbraco.Web.Composing internal static ImageUrlProviderCollection ImageUrlProviders => Container.GetInstance(); - internal static IFacadeService FacadeService - => Container.GetInstance(); + internal static IPublishedSnapshotService PublishedSnapshotService + => Container.GetInstance(); public static ISiteDomainHelper SiteDomainHelper => Container.GetInstance(); diff --git a/src/Umbraco.Web/CompositionExtensions.cs b/src/Umbraco.Web/CompositionExtensions.cs index ab3a333356..881a88c05f 100644 --- a/src/Umbraco.Web/CompositionExtensions.cs +++ b/src/Umbraco.Web/CompositionExtensions.cs @@ -140,32 +140,32 @@ namespace Umbraco.Core.Components } /// - /// Sets the facade service. + /// Sets the published snapshot service. /// - /// The type of the facade service. + /// The type of the published snapshot service. /// The composition. - public static void SetFacadeService(this Composition composition) - where T : IFacadeService + public static void SetPublishedSnapshotService(this Composition composition) + where T : IPublishedSnapshotService { - composition.Container.RegisterSingleton(); + composition.Container.RegisterSingleton(); } /// - /// Sets the facade service. + /// Sets the published snapshot service. /// /// The composition. - /// A function creating a service facade. - public static void SetFacadeService(this Composition composition, Func factory) + /// A function creating a published snapshot service. + public static void SetPublishedSnapshotService(this Composition composition, Func factory) { composition.Container.RegisterSingleton(factory); } /// - /// Sets the facade service. + /// Sets the published snapshot service. /// /// The composition. - /// A facade service. - public static void SetFacadeService(this Composition composition, IFacadeService service) + /// A published snapshot service. + public static void SetPublishedSnapshotService(this Composition composition, IPublishedSnapshotService service) { composition.Container.RegisterSingleton(_ => service); } diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index af2e5d348c..c4a893235c 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -263,8 +263,8 @@ namespace Umbraco.Web.Editors controller => controller.GetByPath("", "")) }, { - "facadeStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( - controller => controller.GetFacadeStatusUrl()) + "publishedStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + controller => controller.GetPublishedStatusUrl()) }, { "nuCacheStatusBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 529fd902e4..a5da00d59b 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -40,12 +40,12 @@ namespace Umbraco.Web.Editors [ContentControllerConfiguration] public class ContentController : ContentControllerBase { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; - public ContentController(IFacadeService facadeService) + public ContentController(IPublishedSnapshotService publishedSnapshotService) { - if (facadeService == null) throw new ArgumentNullException(nameof(facadeService)); - _facadeService = facadeService; + if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService)); + _publishedSnapshotService = publishedSnapshotService; } /// @@ -873,7 +873,7 @@ namespace Umbraco.Web.Editors /// private void UpdatePreviewContext(int contentId) { - _facadeService.RefreshPreview(Request.GetPreviewCookieValue(), contentId); + _publishedSnapshotService.RefreshPreview(Request.GetPreviewCookieValue(), contentId); } /// diff --git a/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/XmlDataIntegrityHealthCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/XmlDataIntegrityHealthCheck.cs index a14d5c10bd..c53793274f 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/XmlDataIntegrityHealthCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/XmlDataIntegrityHealthCheck.cs @@ -18,19 +18,19 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity public class XmlDataIntegrityHealthCheck : HealthCheck { private readonly ILocalizedTextService _textService; - private readonly PublishedCache.XmlPublishedCache.FacadeService _facadeService; + private readonly PublishedCache.XmlPublishedCache.PublishedSnapshotService _publishedSnapshotService; private const string CheckContentXmlTableAction = "checkContentXmlTable"; private const string CheckMediaXmlTableAction = "checkMediaXmlTable"; private const string CheckMembersXmlTableAction = "checkMembersXmlTable"; - public XmlDataIntegrityHealthCheck(ILocalizedTextService textService, IFacadeService facadeService) + public XmlDataIntegrityHealthCheck(ILocalizedTextService textService, IPublishedSnapshotService publishedSnapshotService) { _textService = textService; - _facadeService = facadeService as PublishedCache.XmlPublishedCache.FacadeService; - if (_facadeService == null) - throw new NotSupportedException("Unsupported IFacadeService, only the Xml one is supported."); + _publishedSnapshotService = publishedSnapshotService as PublishedCache.XmlPublishedCache.PublishedSnapshotService; + if (_publishedSnapshotService == null) + throw new NotSupportedException("Unsupported IPublishedSnapshotService, only the Xml one is supported."); } /// @@ -53,13 +53,13 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity switch (action.Alias) { case CheckContentXmlTableAction: - _facadeService.RebuildContentAndPreviewXml(); + _publishedSnapshotService.RebuildContentAndPreviewXml(); return CheckContent(); case CheckMediaXmlTableAction: - _facadeService.RebuildMediaXml(); + _publishedSnapshotService.RebuildMediaXml(); return CheckMedia(); case CheckMembersXmlTableAction: - _facadeService.RebuildMemberXml(); + _publishedSnapshotService.RebuildMemberXml(); return CheckMembers(); default: throw new ArgumentOutOfRangeException(); @@ -68,17 +68,17 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity private HealthCheckStatus CheckMembers() { - return Check(_facadeService.VerifyMemberXml(), CheckMembersXmlTableAction, "healthcheck/xmlDataIntegrityCheckMembers"); + return Check(_publishedSnapshotService.VerifyMemberXml(), CheckMembersXmlTableAction, "healthcheck/xmlDataIntegrityCheckMembers"); } private HealthCheckStatus CheckMedia() { - return Check(_facadeService.VerifyMediaXml(), CheckMediaXmlTableAction, "healthcheck/xmlDataIntegrityCheckMedia"); + return Check(_publishedSnapshotService.VerifyMediaXml(), CheckMediaXmlTableAction, "healthcheck/xmlDataIntegrityCheckMedia"); } private HealthCheckStatus CheckContent() { - return Check(_facadeService.VerifyContentAndPreviewXml(), CheckContentXmlTableAction, "healthcheck/xmlDataIntegrityCheckContent"); + return Check(_publishedSnapshotService.VerifyContentAndPreviewXml(), CheckContentXmlTableAction, "healthcheck/xmlDataIntegrityCheckContent"); } private HealthCheckStatus Check(bool ok, string action, string text) diff --git a/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs b/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs index bb2d6869c6..eb7d02053b 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallPackageController.cs @@ -160,9 +160,9 @@ namespace Umbraco.Web.Install.Controllers installer.LoadConfig(model.PackageFile); installer.InstallCleanUp(model.ManifestId, model.PackageFile); - // library.RefreshContent is obsolete, would need to RefreshAllFacade, + // library.RefreshContent is obsolete, would need to RefreshAll... snapshot, // but it should be managed automatically by services and caches! - //DistributedCache.Instance.RefreshAllFacade(); + //DistributedCache.Instance.RefreshAll...(); return Json(new { diff --git a/src/Umbraco.Web/Install/FilePermissionHelper.cs b/src/Umbraco.Web/Install/FilePermissionHelper.cs index a2c67d34c6..b9252c9e65 100644 --- a/src/Umbraco.Web/Install/FilePermissionHelper.cs +++ b/src/Umbraco.Web/Install/FilePermissionHelper.cs @@ -33,8 +33,8 @@ namespace Umbraco.Web.Install if (EnsureFiles(PermissionFiles, out errors) == false) report["File writing failed"] = errors.ToList(); - if (TestFacade(out errors) == false) - report["Facade environment check failed"] = errors.ToList(); + if (TestPublishedSnapshotService(out errors) == false) + report["Published snapshot environment check failed"] = errors.ToList(); if (EnsureCanCreateSubDirectory(SystemDirectories.Media, out errors) == false) report["Media folder creation failed"] = errors.ToList(); @@ -114,10 +114,10 @@ namespace Umbraco.Web.Install return success; } - public static bool TestFacade(out IEnumerable errors) + public static bool TestPublishedSnapshotService(out IEnumerable errors) { - var facadeService = Current.FacadeService; - return facadeService.EnsureEnvironment(out errors); + var publishedSnapshotService = Current.PublishedSnapshotService; + return publishedSnapshotService.EnsureEnvironment(out errors); } // tries to create a sub-directory diff --git a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs index 53440e1798..89dcd7996f 100644 --- a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs @@ -41,9 +41,9 @@ namespace Umbraco.Web.Install.InstallSteps } // Some upgrade scripts "may modify the database (cmsContentXml...) tables directly" - not sure - // that is still true but the idea is that after an upgrade we want to reset the local facade, on + // that is still true but the idea is that after an upgrade we want to reset the local published snapshot, on // all LB nodes of course, so we need to use the distributed cache, and refresh everything. - Current.DistributedCache.RefreshAllFacade(); + Current.DistributedCache.RefreshAllPublishedSnapshot(); // Update configurationStatus GlobalSettings.ConfigurationStatus = UmbracoVersion.SemanticVersion.ToSemanticString(); diff --git a/src/Umbraco.Web/Install/InstallSteps/StarterKitCleanupStep.cs b/src/Umbraco.Web/Install/InstallSteps/StarterKitCleanupStep.cs index b9fe860c00..5738f2a67c 100644 --- a/src/Umbraco.Web/Install/InstallSteps/StarterKitCleanupStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/StarterKitCleanupStep.cs @@ -29,9 +29,9 @@ namespace Umbraco.Web.Install.InstallSteps installer.LoadConfig(packageFile); installer.InstallCleanUp(manifestId, packageFile); - // library.RefreshContent is obsolete, would need to RefreshAllFacade, + // library.RefreshContent is obsolete, would need to RefreshAll... snapshot, // but it should be managed automatically by services and caches! - //DistributedCache.Instance.RefreshAllFacade(); + //DistributedCache.Instance.RefreshAll...(); } public override bool RequiresExecution(object model) diff --git a/src/Umbraco.Web/Models/ContentExtensions.cs b/src/Umbraco.Web/Models/ContentExtensions.cs index 382a7bbdf8..0fc61875a3 100644 --- a/src/Umbraco.Web/Models/ContentExtensions.cs +++ b/src/Umbraco.Web/Models/ContentExtensions.cs @@ -50,7 +50,7 @@ namespace Umbraco.Web.Models var domainCache = umbracoContext == null ? new PublishedCache.XmlPublishedCache.DomainCache(domainService) // for tests only - : umbracoContext.Facade.DomainCache; // default + : umbracoContext.PublishedShapshot.DomainCache; // default var domainHelper = new DomainHelper(domainCache); Domain domain; diff --git a/src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs b/src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs index 63aa87db53..7f5b9e4b10 100644 --- a/src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs +++ b/src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs @@ -74,7 +74,7 @@ namespace Umbraco.Web.Mvc protected UmbracoContext UmbracoContext => _umbracoContext ?? (_umbracoContext = UmbracoContext.Current); // todo - try lazy property injection? - private FacadeRouter FacadeRouter => Core.Composing.Current.Container.GetInstance(); + private PublishedRouter PublishedRouter => Core.Composing.Current.Container.GetInstance(); /// /// Exposes an UmbracoHelper @@ -92,7 +92,7 @@ namespace Umbraco.Web.Mvc return; } - UmbracoContext.Current.PublishedContentRequest = FacadeRouter.CreateRequest(UmbracoContext.Current); + UmbracoContext.Current.PublishedContentRequest = PublishedRouter.CreateRequest(UmbracoContext.Current); ConfigurePublishedContentRequest(UmbracoContext.Current.PublishedContentRequest, filterContext); } @@ -127,7 +127,7 @@ namespace Umbraco.Web.Mvc request.PublishedContent = (IPublishedContent) result; } - FacadeRouter.PrepareRequest(request); + PublishedRouter.PrepareRequest(request); } } } diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs index fdbdf6119c..11a0ac00d0 100644 --- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Mvc private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly UmbracoContext _umbracoContext; - // fixme - that one could / should accept a FacadeRouter (engine) to work on the FacadeRequest (published content request) + // fixme - that one could / should accept a PublishedRouter (engine) to work on the PublishedRequest (published content request) public RenderRouteHandler(IUmbracoContextAccessor umbracoContextAccessor, IControllerFactory controllerFactory) { if (umbracoContextAccessor == null) throw new ArgumentNullException(nameof(umbracoContextAccessor)); @@ -397,7 +397,7 @@ namespace Umbraco.Web.Mvc if (request.HasTemplate == false && routeDef.HasHijackedRoute == false) { // fixme - better find a way to inject that engine? or at least Current.Engine of some sort! - var engine = Core.Composing.Current.Container.GetInstance(); + var engine = Core.Composing.Current.Container.GetInstance(); request.UpdateOnMissingTemplate(); // request will go 404 // HandleHttpResponseStatus returns a value indicating that the request should diff --git a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs index 41940981f6..304de52212 100644 --- a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs @@ -11,7 +11,7 @@ namespace Umbraco.Web.Mvc public abstract class UmbracoVirtualNodeRouteHandler : IRouteHandler { // todo - try lazy property injection? - private FacadeRouter FacadeRouter => Core.Composing.Current.Container.GetInstance(); + private PublishedRouter PublishedRouter => Core.Composing.Current.Container.GetInstance(); /// /// Returns the UmbracoContext for this route handler @@ -49,7 +49,7 @@ namespace Umbraco.Web.Mvc var found = FindContent(requestContext, umbracoContext); if (found == null) return new NotFoundHandler(); - var request = FacadeRouter.CreateRequest(umbracoContext); + var request = PublishedRouter.CreateRequest(umbracoContext); request.PublishedContent = found; umbracoContext.PublishedContentRequest = request; @@ -90,7 +90,7 @@ namespace Umbraco.Web.Mvc protected virtual void PreparePublishedContentRequest(PublishedContentRequest request) { - FacadeRouter.PrepareRequest(request); + PublishedRouter.PrepareRequest(request); } } } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs index 5b10c6aa83..06a9a235d0 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs @@ -10,7 +10,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { internal class ContentPickerValueConverter : PropertyValueConverterBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private static readonly List PropertiesToExclude = new List { @@ -18,9 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters Constants.Conventions.Content.Redirect.ToLower(CultureInfo.InvariantCulture) }; - public ContentPickerValueConverter(IFacadeAccessor facadeAccessor) + public ContentPickerValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor) { - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; } public override bool IsConverter(PublishedPropertyType propertyType) @@ -31,7 +31,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters => typeof (IPublishedContent); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Snapshot; + => PropertyCacheLevel.Elements; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { @@ -56,7 +56,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters IPublishedContent content; if (inter is int id) { - content = _facadeAccessor.Facade.ContentCache.GetById(id); + content = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(id); if (content != null) return content; } @@ -65,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var udi = inter as GuidUdi; if (udi == null) return null; - content = _facadeAccessor.Facade.ContentCache.GetById(udi.Guid); + content = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(udi.Guid); if (content != null) return content; } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs index 418511e7a0..66bb6649d6 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MacroContainerValueConverter.cs @@ -36,7 +36,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters => typeof (IHtmlString); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; // NOT thread-safe over a request because it modifies the // global UmbracoContext.Current.InPreviewMode status. So it diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs index fd558e7c9b..9135cfe96c 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters => typeof (IHtmlString); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs index d521676eb7..7376549aab 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerLegacyValueConverter.cs @@ -39,7 +39,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => IsMultipleDataType(propertyType.DataTypeId, propertyType.PropertyEditorAlias) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs index 117aef1892..ca833c0bec 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs @@ -18,13 +18,13 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { private readonly ServiceContext _services; private readonly PropertyEditorCollection _propertyEditors; - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - public MediaPickerValueConverter(ServiceContext services, PropertyEditorCollection propertyEditors, IFacadeAccessor facadeAccessor) + public MediaPickerValueConverter(ServiceContext services, PropertyEditorCollection propertyEditors, IPublishedSnapshotAccessor publishedSnapshotAccessor) { _services = services ?? throw new ArgumentNullException(nameof(services)); _propertyEditors = propertyEditors ?? throw new ArgumentException(nameof(propertyEditors)); - _facadeAccessor = facadeAccessor ?? throw new ArgumentNullException(nameof(facadeAccessor)); + _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); } public override bool IsConverter(PublishedPropertyType propertyType) @@ -38,7 +38,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters : typeof (IPublishedContent); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; private bool IsMultipleDataType(int dataTypeId, string propertyEditorAlias) { @@ -97,7 +97,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { var guidUdi = udi as GuidUdi; if (guidUdi == null) continue; - var item = _facadeAccessor.Facade.MediaCache.GetById(guidUdi.Guid); + var item = _publishedSnapshotAccessor.PublishedSnapshot.MediaCache.GetById(guidUdi.Guid); if (item != null) mediaItems.Add(item); } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs index 0c699f8dfe..08c7f06589 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs @@ -10,11 +10,11 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters [DefaultPropertyValueConverter] public class MemberPickerValueConverter : PropertyValueConverterBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - public MemberPickerValueConverter(IFacadeAccessor facadeAccessor) + public MemberPickerValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor) { - _facadeAccessor = facadeAccessor ?? throw new ArgumentNullException(nameof(facadeAccessor)); + _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); } public override bool IsConverter(PublishedPropertyType propertyType) @@ -24,7 +24,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IPublishedContent); @@ -50,7 +50,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters IPublishedContent member; if (source is int id) { - member = _facadeAccessor.Facade.MemberCache.GetById(id); + member = _publishedSnapshotAccessor.PublishedSnapshot.MemberCache.GetById(id); if (member != null) return member; } @@ -58,7 +58,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { var sourceUdi = source as GuidUdi; if (sourceUdi == null) return null; - member = _facadeAccessor.Facade.MemberCache.GetByProviderKey(sourceUdi.Guid); + member = _publishedSnapshotAccessor.PublishedSnapshot.MemberCache.GetByProviderKey(sourceUdi.Guid); if (member != null) return member; } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs index 8c7e901abd..d0906e1a58 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters [DefaultPropertyValueConverter(typeof(MustBeStringValueConverter))] public class MultiNodeTreePickerValueConverter : PropertyValueConverterBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private static readonly List PropertiesToExclude = new List { @@ -28,9 +28,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters Constants.Conventions.Content.Redirect.ToLower(CultureInfo.InvariantCulture) }; - public MultiNodeTreePickerValueConverter(IFacadeAccessor facadeAccessor) + public MultiNodeTreePickerValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor) { - _facadeAccessor = facadeAccessor ?? throw new ArgumentNullException(nameof(facadeAccessor)); + _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); } public override bool IsConverter(PublishedPropertyType propertyType) @@ -40,7 +40,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters } public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; public override Type GetPropertyValueType(PublishedPropertyType propertyType) => typeof (IEnumerable); @@ -89,9 +89,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters foreach (var nodeId in nodeIds) { var multiNodeTreePickerItem = - GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Document, id => _facadeAccessor.Facade.ContentCache.GetById(id)) - ?? GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Media, id => _facadeAccessor.Facade.MediaCache.GetById(id)) - ?? GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Member, id => _facadeAccessor.Facade.MemberCache.GetById(id)); + GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Document, id => _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(id)) + ?? GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Media, id => _publishedSnapshotAccessor.PublishedSnapshot.MediaCache.GetById(id)) + ?? GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Member, id => _publishedSnapshotAccessor.PublishedSnapshot.MemberCache.GetById(id)); if (multiNodeTreePickerItem != null) { @@ -121,9 +121,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var guidUdi = udi as GuidUdi; if (guidUdi == null) continue; var multiNodeTreePickerItem = - GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Document, id => _facadeAccessor.Facade.ContentCache.GetById(guidUdi.Guid)) - ?? GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Media, id => _facadeAccessor.Facade.MediaCache.GetById(guidUdi.Guid)) - ?? GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Member, id => _facadeAccessor.Facade.MemberCache.GetByProviderKey(guidUdi.Guid)); + GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Document, id => _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(guidUdi.Guid)) + ?? GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Media, id => _publishedSnapshotAccessor.PublishedSnapshot.MediaCache.GetById(guidUdi.Guid)) + ?? GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Member, id => _publishedSnapshotAccessor.PublishedSnapshot.MemberCache.GetByProviderKey(guidUdi.Guid)); if (multiNodeTreePickerItem != null) { multiNodeTreePicker.Add(multiNodeTreePickerItem); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs index fed8d81cdf..f4de127ada 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentManyValueConverter.cs @@ -21,8 +21,8 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// /// Initializes a new instance of the class. /// - public NestedContentManyValueConverter(IFacadeAccessor facadeAccessor, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) - : base(facadeAccessor, publishedModelFactory) + public NestedContentManyValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) + : base(publishedSnapshotAccessor, publishedModelFactory) { _proflog = proflog; } @@ -42,7 +42,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; /// public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs index 4e522bd249..a3833ffddf 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentSingleValueConverter.cs @@ -20,8 +20,8 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// /// Initializes a new instance of the class. /// - public NestedContentSingleValueConverter(IFacadeAccessor facadeAccessor, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) - : base(facadeAccessor, publishedModelFactory) + public NestedContentSingleValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor, IPublishedModelFactory publishedModelFactory, ProfilingLogger proflog) + : base(publishedSnapshotAccessor, publishedModelFactory) { _proflog = proflog; } @@ -41,7 +41,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters /// public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; /// public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs index 8b7bde46e3..fc93ab6d38 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs @@ -10,11 +10,11 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { public abstract class NestedContentValueConverterBase : PropertyValueConverterBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - protected NestedContentValueConverterBase(IFacadeAccessor facadeAccessor, IPublishedModelFactory publishedModelFactory) + protected NestedContentValueConverterBase(IPublishedSnapshotAccessor publishedSnapshotAccessor, IPublishedModelFactory publishedModelFactory) { - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; PublishedModelFactory = publishedModelFactory; } @@ -45,7 +45,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters if (string.IsNullOrEmpty(elementTypeAlias)) return null; - var publishedContentType = _facadeAccessor.Facade.ContentCache.GetContentType(elementTypeAlias); + var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetContentType(elementTypeAlias); if (publishedContentType == null) return null; @@ -55,7 +55,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters || !Guid.TryParse(keyo.ToString(), out var key)) key = Guid.Empty; - IPublishedElement element = new PublishedElement(publishedContentType, key, propertyValues, preview, referenceCacheLevel, _facadeAccessor); + IPublishedElement element = new PublishedElement(publishedContentType, key, propertyValues, preview, referenceCacheLevel, _publishedSnapshotAccessor); element = PublishedModelFactory.CreateModel(element); return element; } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs index b487ed6744..74a7ab02ab 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksLegacyValueConverter.cs @@ -42,7 +42,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters => typeof (JArray); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs index 7429ae798b..417dfe8fdd 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs @@ -19,13 +19,13 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters [DefaultPropertyValueConverter(typeof(RelatedLinksLegacyValueConverter), typeof(JsonValueConverter))] public class RelatedLinksValueConverter : PropertyValueConverterBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly ILogger _logger; - public RelatedLinksValueConverter(IFacadeAccessor facadeAccessor, IUmbracoContextAccessor umbracoContextAccessor, ILogger logger) + public RelatedLinksValueConverter(IPublishedSnapshotAccessor publishedSnapshotAccessor, IUmbracoContextAccessor umbracoContextAccessor, ILogger logger) { - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; _umbracoContextAccessor = umbracoContextAccessor; _logger = logger; } @@ -47,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters => typeof (JArray); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Content; + => PropertyCacheLevel.Element; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { @@ -80,7 +80,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var udiAttempt = strLinkId.TryConvertTo(); if (udiAttempt.Success) { - var content = _facadeAccessor.Facade.ContentCache.GetById(udiAttempt.Result.Guid); + var content = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(udiAttempt.Result.Guid); if (content != null) { relatedLink.Id = content.Id; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs index 8eb449b703..26819f323d 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RteMacroRenderingValueConverter.cs @@ -26,8 +26,8 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) { // because that version of RTE converter parses {locallink} and executes macros, its value has - // to be cached at the facade level, because we have no idea what the macros may depend on actually. - return PropertyCacheLevel.Facade; + // to be cached at the published snapshot level, because we have no idea what the macros may depend on actually. + return PropertyCacheLevel.Snapshot; } public RteMacroRenderingValueConverter(IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, CacheHelper appCache) diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs index 4dcafac80b..d9424f855a 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/TextStringValueConverter.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters => typeof (string); public override PropertyCacheLevel GetPropertyCacheLevel(PublishedPropertyType propertyType) - => PropertyCacheLevel.Facade; + => PropertyCacheLevel.Snapshot; public override object ConvertSourceToInter(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) { diff --git a/src/Umbraco.Web/PublishedCache/IFacadeAccessor.cs b/src/Umbraco.Web/PublishedCache/IFacadeAccessor.cs deleted file mode 100644 index 024d73a2d5..0000000000 --- a/src/Umbraco.Web/PublishedCache/IFacadeAccessor.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Umbraco.Web.PublishedCache -{ - /// - /// Provides access to IFacade. - /// - public interface IFacadeAccessor - { - IFacade Facade { get; set; } - } -} diff --git a/src/Umbraco.Web/PublishedCache/IFacade.cs b/src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs similarity index 69% rename from src/Umbraco.Web/PublishedCache/IFacade.cs rename to src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs index 804c01b5f0..a5950fe919 100644 --- a/src/Umbraco.Web/PublishedCache/IFacade.cs +++ b/src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs @@ -4,9 +4,11 @@ using Umbraco.Core.Cache; namespace Umbraco.Web.PublishedCache { /// - /// The Umbraco facade. + /// Specifies a published snapshot. /// - public interface IFacade + /// A published snapshot is a point-in-time capture of the current state of + /// everything that is "published". + public interface IPublishedShapshot { /// /// Gets the . @@ -29,23 +31,23 @@ namespace Umbraco.Web.PublishedCache IDomainCache DomainCache { get; } /// - /// Gets the facade cache. - /// - ICacheProvider FacadeCache { get; } - - /// - /// Gets the snapshot cache. + /// Gets the snapshot-level cache. /// ICacheProvider SnapshotCache { get; } /// - /// Forces the facade preview mode. + /// Gets the elements-level cache. + /// + ICacheProvider ElementsCache { get; } + + /// + /// Forces the preview mode. /// /// The forced preview mode. /// A callback to execute when reverting to previous preview. /// - /// Forcing to false means no preview. Forcing to true means 'full' preview if the facade is not already previewing; - /// otherwise the facade keeps previewing according to whatever settings it is using already. + /// Forcing to false means no preview. Forcing to true means 'full' preview if the snapshot is not already previewing; + /// otherwise the snapshot keeps previewing according to whatever settings it is using already. /// Stops forcing preview when disposed. IDisposable ForcedPreview(bool preview, Action callback = null); } diff --git a/src/Umbraco.Web/PublishedCache/IPublishedSnapshotAccessor.cs b/src/Umbraco.Web/PublishedCache/IPublishedSnapshotAccessor.cs new file mode 100644 index 0000000000..9c0bc5a1e7 --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/IPublishedSnapshotAccessor.cs @@ -0,0 +1,10 @@ +namespace Umbraco.Web.PublishedCache +{ + /// + /// Provides access to the "current" . + /// + public interface IPublishedSnapshotAccessor + { + IPublishedShapshot PublishedSnapshot { get; set; } + } +} diff --git a/src/Umbraco.Web/PublishedCache/IFacadeService.cs b/src/Umbraco.Web/PublishedCache/IPublishedSnapshotService.cs similarity index 80% rename from src/Umbraco.Web/PublishedCache/IFacadeService.cs rename to src/Umbraco.Web/PublishedCache/IPublishedSnapshotService.cs index 75741769c2..40c3538ed9 100644 --- a/src/Umbraco.Web/PublishedCache/IFacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/IPublishedSnapshotService.cs @@ -1,55 +1,49 @@ using System; using System.Collections.Generic; using Umbraco.Core.Models.Membership; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors; using Umbraco.Web.Cache; namespace Umbraco.Web.PublishedCache { /// - /// Creates and manages IFacade. + /// Creates and manages instances. /// - public interface IFacadeService : IDisposable + public interface IPublishedSnapshotService : IDisposable { - #region Facade + #region PublishedSnapshot /* Various places (such as Node) want to access the XML content, today as an XmlDocument * but to migrate to a new cache, they're migrating to an XPathNavigator. Still, they need * to find out how to get that navigator. * - * Because a cache such as the DrippingCache is contextual ie it has a "snapshot" nothing - * and remains consistent over the snapshot, the navigator should come from the "current" - * snapshot. + * Because a cache such as NuCache is contextual i.e. it has a "snapshot" thing and remains + * consistent over the snapshot, the navigator has to come come from the "current" snapshot. * - * The service creates those snapshots in IPublishedCaches objects. - * - * Places such as Node need to be able to find the "current" one so the factory has a - * notion of what is "current". In most cases, the IPublishedCaches object is created - * and registered against an UmbracoContext, and that context is then used as "current". - * - * But for tests we need to have a way to specify what's the "current" object & preview. - * Which is defined in PublishedCachesServiceBase. + * So although everything should be injected... we also need a notion of "the current published + * snapshot". This is provided by the IPublishedSnapshotAccessor. * */ /// - /// Creates a facade. + /// Creates a published snapshot. /// /// A preview token, or null if not previewing. - /// A facade. - IFacade CreateFacade(string previewToken); + /// A published snapshot. + /// If is null, the snapshot is not previewing, else it + /// is previewing, and what is or is not visible in preview depends on the content of the token, + /// which is not specified and depends on the actual published snapshot service implementation. + IPublishedShapshot CreatePublishedSnapshot(string previewToken); /// - /// Gets the facade accessor. + /// Gets the published snapshot accessor. /// - IFacadeAccessor FacadeAccessor { get; } + IPublishedSnapshotAccessor PublishedSnapshotAccessor { get; } /// - /// Ensures that the facade has the proper environment to run. + /// Ensures that the published snapshot has the proper environment to run. /// /// The errors, if any. - /// A value indicating whether the facade has the proper environment to run. + /// A value indicating whether the published snapshot has the proper environment to run. bool EnsureEnvironment(out IEnumerable errors); #endregion diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs index 8cdf582b98..43fdb342c7 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs @@ -17,18 +17,18 @@ namespace Umbraco.Web.PublishedCache.NuCache internal class ContentCache : PublishedCacheBase, IPublishedContentCache, INavigableData, IDisposable { private readonly ContentStore.Snapshot _snapshot; - private readonly ICacheProvider _facadeCache; private readonly ICacheProvider _snapshotCache; + private readonly ICacheProvider _elementsCache; private readonly DomainHelper _domainHelper; #region Constructor - public ContentCache(bool previewDefault, ContentStore.Snapshot snapshot, ICacheProvider facadeCache, ICacheProvider snapshotCache, DomainHelper domainHelper) + public ContentCache(bool previewDefault, ContentStore.Snapshot snapshot, ICacheProvider snapshotCache, ICacheProvider elementsCache, DomainHelper domainHelper) : base(previewDefault) { _snapshot = snapshot; - _facadeCache = facadeCache; _snapshotCache = snapshotCache; + _elementsCache = elementsCache; _domainHelper = domainHelper; } @@ -57,7 +57,7 @@ namespace Umbraco.Web.PublishedCache.NuCache { if (route == null) throw new ArgumentNullException(nameof(route)); - var cache = preview == false || FacadeService.FullCacheWhenPreviewing ? _snapshotCache : _facadeCache; + var cache = preview == false || PublishedSnapshotService.FullCacheWhenPreviewing ? _elementsCache : _snapshotCache; var key = CacheKeys.ContentCacheContentByRoute(route, preview); return cache.GetCacheItem(key, () => GetByRouteInternal(preview, route, hideTopLevelNode)); } @@ -120,7 +120,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public string GetRouteById(bool preview, int contentId) { - var cache = (preview == false || FacadeService.FullCacheWhenPreviewing) ? _snapshotCache : _facadeCache; + var cache = (preview == false || PublishedSnapshotService.FullCacheWhenPreviewing) ? _elementsCache : _snapshotCache; var key = CacheKeys.ContentCacheRouteByContent(contentId, preview); return cache.GetCacheItem(key, () => GetRouteByIdInternal(preview, contentId, null)); } @@ -232,12 +232,12 @@ namespace Umbraco.Web.PublishedCache.NuCache public override IEnumerable GetAtRoot(bool preview) { - if (FacadeService.CacheContentCacheRoots == false) + if (PublishedSnapshotService.CacheContentCacheRoots == false) return GetAtRootNoCache(preview); - var cache = preview == false || FacadeService.FullCacheWhenPreviewing - ? _snapshotCache - : _facadeCache; + var cache = preview == false || PublishedSnapshotService.FullCacheWhenPreviewing + ? _elementsCache + : _snapshotCache; if (cache == null) return GetAtRootNoCache(preview); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs index 7b08644882..a7cc1e950c 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentNode.cs @@ -33,10 +33,10 @@ namespace Umbraco.Web.PublishedCache.NuCache int parentContentId, DateTime createDate, int creatorId, ContentData draftData, ContentData publishedData, - IFacadeAccessor facadeAccessor) + IPublishedSnapshotAccessor publishedSnapshotAccessor) : this(id, uid, level, path, sortOrder, parentContentId, createDate, creatorId) { - SetContentTypeAndData(contentType, draftData, publishedData, facadeAccessor); + SetContentTypeAndData(contentType, draftData, publishedData, publishedSnapshotAccessor); } // 2-phases ctor, phase 1 @@ -58,7 +58,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } // two-phase ctor, phase 2 - public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IFacadeAccessor facadeAccessor) + public void SetContentTypeAndData(PublishedContentType contentType, ContentData draftData, ContentData publishedData, IPublishedSnapshotAccessor publishedSnapshotAccessor) { ContentType = contentType; @@ -66,9 +66,9 @@ namespace Umbraco.Web.PublishedCache.NuCache throw new ArgumentException("Both draftData and publishedData cannot be null at the same time."); if (draftData != null) - Draft = new PublishedContent(this, draftData, facadeAccessor).CreateModel(); + Draft = new PublishedContent(this, draftData, publishedSnapshotAccessor).CreateModel(); if (publishedData != null) - Published = new PublishedContent(this, publishedData, facadeAccessor).CreateModel(); + Published = new PublishedContent(this, publishedData, publishedSnapshotAccessor).CreateModel(); } // clone parent @@ -97,7 +97,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } // clone with new content type - public ContentNode(ContentNode origin, PublishedContentType contentType, IFacadeAccessor facadeAccessor) + public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor) { Id = origin.Id; Uid = origin.Uid; @@ -112,8 +112,8 @@ namespace Umbraco.Web.PublishedCache.NuCache var originDraft = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft); var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published); - Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, facadeAccessor).CreateModel(); - Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, facadeAccessor).CreateModel(); + Draft = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor).CreateModel(); + Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor).CreateModel(); ChildContentIds = origin.ChildContentIds; // can be the *same* list FIXME oh really? } @@ -136,7 +136,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public IPublishedContent Draft; public IPublishedContent Published; - public ContentNode CloneParent(IFacadeAccessor facadeAccessor) + public ContentNode CloneParent(IPublishedSnapshotAccessor publishedSnapshotAccessor) { return new ContentNode(this); } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs index 7d0c0bbbef..82bfc8766a 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentNodeKit.cs @@ -17,9 +17,9 @@ namespace Umbraco.Web.PublishedCache.NuCache public static ContentNodeKit Null { get; } = new ContentNodeKit { ContentTypeId = -1 }; - public void Build(PublishedContentType contentType, IFacadeAccessor facadeAccessor) + public void Build(PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor) { - Node.SetContentTypeAndData(contentType, DraftData, PublishedData, facadeAccessor); + Node.SetContentTypeAndData(contentType, DraftData, PublishedData, publishedSnapshotAccessor); } } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs index 61ed0feb44..175b13da16 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentStore.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // most of the snapshots management code, etc is an exact copy // SnapDictionary has unit tests to ensure it all works correctly - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly ConcurrentDictionary> _contentNodes; private readonly ConcurrentDictionary> _contentRootNodes; private readonly ConcurrentDictionary> _contentTypesById; @@ -42,9 +42,9 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Ctor - public ContentStore(IFacadeAccessor facadeAccessor, ILogger logger, BPlusTree localDb = null) + public ContentStore(IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, BPlusTree localDb = null) { - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; _logger = logger; _localDb = localDb; @@ -275,7 +275,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (node == null) continue; var contentTypeId = node.ContentType.Id; if (index.TryGetValue(contentTypeId, out PublishedContentType contentType) == false) continue; - SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _facadeAccessor)); + SetValueLocked(_contentNodes, node.Id, new ContentNode(node, contentType, _publishedSnapshotAccessor)); } } finally @@ -389,7 +389,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _contentNodes.TryGetValue(id, out LinkedNode link); if (link?.Value == null) continue; - var node = new ContentNode(link.Value, contentType, _facadeAccessor); + var node = new ContentNode(link.Value, contentType, _publishedSnapshotAccessor); SetValueLocked(_contentNodes, id, node); if (_localDb != null) RegisterChange(id, node.ToKit()); } @@ -412,7 +412,7 @@ namespace Umbraco.Web.PublishedCache.NuCache return false; // and use - kit.Build(link.Value, _facadeAccessor); + kit.Build(link.Value, _publishedSnapshotAccessor); return true; } @@ -618,7 +618,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var link = GetParentLink(content); var parent = link.Value; if (link.Gen < _liveGen) - parent = parent.CloneParent(_facadeAccessor); + parent = parent.CloneParent(_publishedSnapshotAccessor); parent.ChildContentIds.Remove(content.Id); if (link.Gen < _liveGen) SetValueLocked(_contentNodes, parent.Id, parent); @@ -648,7 +648,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var link = GetParentLink(content); var parent = link.Value; if (link.Gen < _liveGen) - parent = parent.CloneParent(_facadeAccessor); + parent = parent.CloneParent(_publishedSnapshotAccessor); parent.ChildContentIds.Add(content.Id); if (link.Gen < _liveGen) SetValueLocked(_contentNodes, parent.Id, parent); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs index fe01f8bbc2..d067df1a72 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/MediaCache.cs @@ -13,17 +13,17 @@ namespace Umbraco.Web.PublishedCache.NuCache internal class MediaCache : PublishedCacheBase, IPublishedMediaCache, INavigableData, IDisposable { private readonly ContentStore.Snapshot _snapshot; - private readonly ICacheProvider _facadeCache; private readonly ICacheProvider _snapshotCache; + private readonly ICacheProvider _elementsCache; #region Constructors - public MediaCache(bool previewDefault, ContentStore.Snapshot snapshot, ICacheProvider facadeCache, ICacheProvider snapshotCache) + public MediaCache(bool previewDefault, ContentStore.Snapshot snapshot, ICacheProvider snapshotCache, ICacheProvider elementsCache) : base(previewDefault) { _snapshot = snapshot; - _facadeCache = facadeCache; _snapshotCache = snapshotCache; + _elementsCache = elementsCache; } #endregion @@ -50,12 +50,12 @@ namespace Umbraco.Web.PublishedCache.NuCache public override IEnumerable GetAtRoot(bool preview) { - if (FacadeService.CacheContentCacheRoots == false) + if (PublishedSnapshotService.CacheContentCacheRoots == false) return GetAtRootNoCache(preview); - var cache = preview == false || FacadeService.FullCacheWhenPreviewing - ? _snapshotCache - : _facadeCache; + var cache = preview == false || PublishedSnapshotService.FullCacheWhenPreviewing + ? _elementsCache + : _snapshotCache; if (cache == null) return GetAtRootNoCache(preview); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs index e6570a9b67..4dea257ce9 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/MemberCache.cs @@ -15,37 +15,27 @@ namespace Umbraco.Web.PublishedCache.NuCache { class MemberCache : IPublishedMemberCache, INavigableData { - private readonly IFacadeAccessor _facadeAccessor; - private readonly ICacheProvider _facadeCache; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; + private readonly ICacheProvider _snapshotCache; private readonly IMemberService _memberService; private readonly IDataTypeService _dataTypeService; private readonly PublishedContentTypeCache _contentTypeCache; private readonly bool _previewDefault; - public MemberCache(bool previewDefault, ICacheProvider facadeCache, IMemberService memberService, IDataTypeService dataTypeService, PublishedContentTypeCache contentTypeCache, IFacadeAccessor facadeAccessor) + public MemberCache(bool previewDefault, ICacheProvider snapshotCache, IMemberService memberService, IDataTypeService dataTypeService, PublishedContentTypeCache contentTypeCache, IPublishedSnapshotAccessor publishedSnapshotAccessor) { - _facadeCache = facadeCache; - _facadeAccessor = facadeAccessor; + _snapshotCache = snapshotCache; + _publishedSnapshotAccessor = publishedSnapshotAccessor; _memberService = memberService; _dataTypeService = dataTypeService; _previewDefault = previewDefault; _contentTypeCache = contentTypeCache; } - //private static T GetCacheItem(string cacheKey) - // where T : class - //{ - // var facade = Facade.Current; - // var cache = facade == null ? null : facade.FacadeCache; - // return cache == null - // ? null - // : (T) cache.GetCacheItem(cacheKey); - //} - private T GetCacheItem(string cacheKey, Func getCacheItem) where T : class { - var cache = _facadeCache; + var cache = _snapshotCache; return cache == null ? getCacheItem() : cache.GetCacheItem(cacheKey, getCacheItem); @@ -71,14 +61,14 @@ namespace Umbraco.Web.PublishedCache.NuCache var member = _memberService.GetById(memberId); return member == null ? null - : PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _facadeAccessor); + : PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor); }); } private IPublishedContent /*IPublishedMember*/ GetById(IMember member, bool previewing) { return GetCacheItem(CacheKeys.MemberCacheMember("ById", _previewDefault, member.Id), () => - PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _facadeAccessor)); + PublishedMember.Create(member, GetContentType(member.ContentTypeId), previewing, _publishedSnapshotAccessor)); } public IPublishedContent /*IPublishedMember*/ GetByProviderKey(object key) @@ -113,7 +103,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public IPublishedContent /*IPublishedMember*/ GetByMember(IMember member) { - return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _facadeAccessor); + return PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _publishedSnapshotAccessor); } public IEnumerable GetAtRoot(bool preview) @@ -121,7 +111,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // because members are flat (not a tree) everything is at root // because we're loading everything... let's just not cache? var members = _memberService.GetAllMembers(); - return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _facadeAccessor)); + return members.Select(m => PublishedMember.Create(m, GetContentType(m.ContentTypeId), preview, _publishedSnapshotAccessor)); } public XPathNavigator CreateNavigator() diff --git a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs b/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs index 59b14871bc..1a55fd3b02 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/NuCacheComponent.cs @@ -15,15 +15,15 @@ namespace Umbraco.Web.PublishedCache.NuCache { base.Compose(composition); - // register the NuCache facade service - composition.SetFacadeService(factory => new FacadeService( - new FacadeService.Options(), + // register the NuCache published snapshot service + composition.SetPublishedSnapshotService(factory => new PublishedSnapshotService( + new PublishedSnapshotService.Options(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), - factory.GetInstance(), + factory.GetInstance(), factory.GetInstance(), factory.GetInstance())); @@ -32,7 +32,7 @@ namespace Umbraco.Web.PublishedCache.NuCache //composition.HealthChecks().Add(); } - public void Initialize(IFacadeService service) + public void Initialize(IPublishedSnapshotService service) { // nothing - this just ensures that the service is created at boot time } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Property.cs b/src/Umbraco.Web/PublishedCache/NuCache/Property.cs index 2f0042e386..8a10051620 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/Property.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/Property.cs @@ -10,7 +10,7 @@ namespace Umbraco.Web.PublishedCache.NuCache [XmlType(Namespace = "http://umbraco.org/webservices/")] internal class Property : PublishedPropertyBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly object _sourceValue; private readonly Guid _contentUid; private readonly bool _isPreviewing; @@ -26,12 +26,12 @@ namespace Umbraco.Web.PublishedCache.NuCache private string _recurseCacheKey; // initializes a published content property with no value - public Property(PublishedPropertyType propertyType, PublishedContent content, IFacadeAccessor facadeAccessor, PropertyCacheLevel referenceCacheLevel = PropertyCacheLevel.Content) - : this(propertyType, content, null, facadeAccessor, referenceCacheLevel) + public Property(PublishedPropertyType propertyType, PublishedContent content, IPublishedSnapshotAccessor publishedSnapshotAccessor, PropertyCacheLevel referenceCacheLevel = PropertyCacheLevel.Element) + : this(propertyType, content, null, publishedSnapshotAccessor, referenceCacheLevel) { } // initializes a published content property with a value - public Property(PublishedPropertyType propertyType, PublishedContent content, object sourceValue, IFacadeAccessor facadeAccessor, PropertyCacheLevel referenceCacheLevel = PropertyCacheLevel.Content) + public Property(PublishedPropertyType propertyType, PublishedContent content, object sourceValue, IPublishedSnapshotAccessor publishedSnapshotAccessor, PropertyCacheLevel referenceCacheLevel = PropertyCacheLevel.Element) : base(propertyType, referenceCacheLevel) { _sourceValue = sourceValue; @@ -39,7 +39,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _content = content; _isPreviewing = content.IsPreviewing; _isMember = content.ContentType.ItemType == PublishedItemType.Member; - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; } // clone for previewing as draft a published content that is published and has no draft @@ -51,7 +51,7 @@ namespace Umbraco.Web.PublishedCache.NuCache _content = content; _isPreviewing = true; _isMember = origin._isMember; - _facadeAccessor = origin._facadeAccessor; + _publishedSnapshotAccessor = origin._publishedSnapshotAccessor; } public override bool HasValue => _sourceValue != null @@ -76,7 +76,7 @@ namespace Umbraco.Web.PublishedCache.NuCache private CacheValues GetCacheValues(PropertyCacheLevel cacheLevel) { CacheValues cacheValues; - Facade facade; + PublishedShapshot publishedSnapshot; ICacheProvider cache; switch (cacheLevel) { @@ -84,27 +84,27 @@ namespace Umbraco.Web.PublishedCache.NuCache // never cache anything cacheValues = new CacheValues(); break; - case PropertyCacheLevel.Content: + case PropertyCacheLevel.Element: // cache within the property object itself, ie within the content object cacheValues = _cacheValues ?? (_cacheValues = new CacheValues()); break; - case PropertyCacheLevel.Snapshot: - // cache within the snapshot cache, unless previewing, then use the facade or - // snapshot cache (if we don't want to pollute the snapshot cache with short-lived + case PropertyCacheLevel.Elements: + // cache within the elements cache, unless previewing, then use the snapshot or + // elements cache (if we don't want to pollute the elements cache with short-lived // data) depending on settings - // for members, always cache in the facade cache - never pollute snapshot cache - facade = (Facade) _facadeAccessor.Facade; - cache = facade == null + // for members, always cache in the snapshot cache - never pollute elements cache + publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot; + cache = publishedSnapshot == null ? null - : ((_isPreviewing == false || FacadeService.FullCacheWhenPreviewing) && (_isMember == false) - ? facade.SnapshotCache - : facade.FacadeCache); + : ((_isPreviewing == false || PublishedSnapshotService.FullCacheWhenPreviewing) && (_isMember == false) + ? publishedSnapshot.ElementsCache + : publishedSnapshot.SnapshotCache); cacheValues = GetCacheValues(cache); break; - case PropertyCacheLevel.Facade: - // cache within the facade cache - facade = (Facade) _facadeAccessor.Facade; - cache = facade?.FacadeCache; + case PropertyCacheLevel.Snapshot: + // cache within the snapshot cache + publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot; + cache = publishedSnapshot?.SnapshotCache; cacheValues = GetCacheValues(cache); break; default: @@ -141,7 +141,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (cacheValues.ObjectInitialized) return cacheValues.ObjectValue; // initial reference cache level always is .Content - cacheValues.ObjectValue = PropertyType.ConvertInterToObject(_content, PropertyCacheLevel.Content, GetInterValue(), _isPreviewing); + cacheValues.ObjectValue = PropertyType.ConvertInterToObject(_content, PropertyCacheLevel.Element, GetInterValue(), _isPreviewing); cacheValues.ObjectInitialized = true; return cacheValues.ObjectValue; } @@ -158,7 +158,7 @@ namespace Umbraco.Web.PublishedCache.NuCache if (cacheValues.XPathInitialized) return cacheValues.XPathValue; // initial reference cache level always is .Content - cacheValues.XPathValue = PropertyType.ConvertInterToXPath(_content, PropertyCacheLevel.Content, GetInterValue(), _isPreviewing); + cacheValues.XPathValue = PropertyType.ConvertInterToXPath(_content, PropertyCacheLevel.Element, GetInterValue(), _isPreviewing); cacheValues.XPathInitialized = true; return cacheValues.XPathValue; } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs index b06cc3927f..725ff11101 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs @@ -12,7 +12,7 @@ namespace Umbraco.Web.PublishedCache.NuCache { internal class PublishedContent : PublishedContentBase { - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly ContentNode _contentNode; // ReSharper disable once InconsistentNaming internal readonly ContentData _contentData; // internal for ContentNode cloning @@ -21,11 +21,11 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Constructors - public PublishedContent(ContentNode contentNode, ContentData contentData, IFacadeAccessor facadeAccessor) + public PublishedContent(ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor) { _contentNode = contentNode; _contentData = contentData; - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; _urlName = _contentData.Name.ToUrlSegment(); IsPreviewing = _contentData.Published == false; @@ -37,15 +37,15 @@ namespace Umbraco.Web.PublishedCache.NuCache { object value; return values.TryGetValue(propertyType.PropertyTypeAlias, out value) && value != null - ? new Property(propertyType, this, value, _facadeAccessor) as IPublishedProperty - : new Property(propertyType, this, _facadeAccessor) as IPublishedProperty; + ? new Property(propertyType, this, value, _publishedSnapshotAccessor) as IPublishedProperty + : new Property(propertyType, this, _publishedSnapshotAccessor) as IPublishedProperty; }) .ToArray(); } private string GetProfileNameById(int id) { - var cache = GetCurrentFacadeCache(); + var cache = GetCurrentSnapshotCache(); return cache == null ? GetProfileNameByIdNoCache(id) : (string) cache.GetCacheItem(CacheKeys.ProfileName(id), () => GetProfileNameByIdNoCache(id)); @@ -69,7 +69,7 @@ namespace Umbraco.Web.PublishedCache.NuCache public PublishedContent(ContentNode contentNode, PublishedContent origin) { _contentNode = contentNode; - _facadeAccessor = origin._facadeAccessor; + _publishedSnapshotAccessor = origin._publishedSnapshotAccessor; _contentData = origin._contentData; _urlName = origin._urlName; @@ -84,7 +84,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // clone for previewing as draft a published content that is published and has no draft private PublishedContent(PublishedContent origin) { - _facadeAccessor = origin._facadeAccessor; + _publishedSnapshotAccessor = origin._publishedSnapshotAccessor; _contentNode = origin._contentNode; _contentData = origin._contentData; @@ -100,52 +100,52 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Get Content/Media for Parent/Children // this is for tests purposes - // args are: current facade (may be null), previewing, content id - returns: content + // args are: current published snapshot (may be null), previewing, content id - returns: content - internal static Func GetContentByIdFunc { get; set; } - = (facade, previewing, id) => facade.ContentCache.GetById(previewing, id); + internal static Func GetContentByIdFunc { get; set; } + = (publishedShapshot, previewing, id) => publishedShapshot.ContentCache.GetById(previewing, id); - internal static Func GetMediaByIdFunc { get; set; } - = (facade, previewing, id) => facade.MediaCache.GetById(previewing, id); + internal static Func GetMediaByIdFunc { get; set; } + = (publishedShapshot, previewing, id) => publishedShapshot.MediaCache.GetById(previewing, id); private IPublishedContent GetContentById(bool previewing, int id) { - return GetContentByIdFunc(_facadeAccessor.Facade, previewing, id); + return GetContentByIdFunc(_publishedSnapshotAccessor.PublishedSnapshot, previewing, id); } private IEnumerable GetContentByIds(bool previewing, IEnumerable ids) { - var facade = _facadeAccessor.Facade; + var publishedSnapshot = _publishedSnapshotAccessor.PublishedSnapshot; // beware! the loop below CANNOT be converted to query such as: - //return ids.Select(x => _getContentByIdFunc(facade, previewing, x)).Where(x => x != null); - // because it would capture the facade and cause all sorts of issues + //return ids.Select(x => _getContentByIdFunc(publishedSnapshot, previewing, x)).Where(x => x != null); + // because it would capture the published snapshot and cause all sorts of issues // - // we WANT to get the actual current facade each time we run + // we WANT to get the actual current published snapshot each time we run // ReSharper disable once LoopCanBeConvertedToQuery foreach (var id in ids) { - var content = GetContentByIdFunc(facade, previewing, id); + var content = GetContentByIdFunc(publishedSnapshot, previewing, id); if (content != null) yield return content; } } private IPublishedContent GetMediaById(bool previewing, int id) { - return GetMediaByIdFunc(_facadeAccessor.Facade, previewing, id); + return GetMediaByIdFunc(_publishedSnapshotAccessor.PublishedSnapshot, previewing, id); } private IEnumerable GetMediaByIds(bool previewing, IEnumerable ids) { - var facade = _facadeAccessor.Facade; + var publishedShapshot = _publishedSnapshotAccessor.PublishedSnapshot; // see note above for content // ReSharper disable once LoopCanBeConvertedToQuery foreach (var id in ids) { - var content = GetMediaByIdFunc(facade, previewing, id); + var content = GetMediaByIdFunc(publishedShapshot, previewing, id); if (content != null) yield return content; } } @@ -206,7 +206,7 @@ namespace Umbraco.Web.PublishedCache.NuCache get { var cache = GetAppropriateCache(); - if (cache == null || FacadeService.CachePublishedContentChildren == false) + if (cache == null || PublishedSnapshotService.CachePublishedContentChildren == false) return GetChildren(); // note: ToArray is important here, we want to cache the result, not the function! @@ -268,19 +268,19 @@ namespace Umbraco.Web.PublishedCache.NuCache // beware what you use that one for - you don't want to cache its result private ICacheProvider GetAppropriateCache() { - var facade = (Facade) _facadeAccessor.Facade; - var cache = facade == null + var publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot; + var cache = publishedSnapshot == null ? null - : ((IsPreviewing == false || FacadeService.FullCacheWhenPreviewing) && (ItemType != PublishedItemType.Member) - ? facade.SnapshotCache - : facade.FacadeCache); + : ((IsPreviewing == false || PublishedSnapshotService.FullCacheWhenPreviewing) && (ItemType != PublishedItemType.Member) + ? publishedSnapshot.ElementsCache + : publishedSnapshot.SnapshotCache); return cache; } - private ICacheProvider GetCurrentFacadeCache() + private ICacheProvider GetCurrentSnapshotCache() { - var facade = (Facade) _facadeAccessor.Facade; - return facade?.FacadeCache; + var publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot; + return publishedSnapshot?.SnapshotCache; } #endregion diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs index e9261f8961..9b325331b9 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedMember.cs @@ -15,13 +15,13 @@ namespace Umbraco.Web.PublishedCache.NuCache { private readonly IMember _member; - private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IFacadeAccessor facadeAccessor) - : base(contentNode, contentData, facadeAccessor) + private PublishedMember(IMember member, ContentNode contentNode, ContentData contentData, IPublishedSnapshotAccessor publishedSnapshotAccessor) + : base(contentNode, contentData, publishedSnapshotAccessor) { _member = member; } - public static IPublishedContent Create(IMember member, PublishedContentType contentType, bool previewing, IFacadeAccessor facadeAccessor) + public static IPublishedContent Create(IMember member, PublishedContentType contentType, bool previewing, IPublishedSnapshotAccessor publishedSnapshotAccessor) { var d = new ContentData { @@ -38,12 +38,12 @@ namespace Umbraco.Web.PublishedCache.NuCache member.Level, member.Path, member.SortOrder, member.ParentId, member.CreateDate, member.CreatorId); - return new PublishedMember(member, n, d, facadeAccessor).CreateModel(); + return new PublishedMember(member, n, d, publishedSnapshotAccessor).CreateModel(); } private static Dictionary GetPropertyValues(PublishedContentType contentType, IMember member) { - // see node in FacadeService + // see node in PublishedSnapshotService // we do not (want to) support ConvertDbToXml/String //var propertyEditorResolver = PropertyEditorResolver.Current; diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Facade.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs similarity index 61% rename from src/Umbraco.Web/PublishedCache/NuCache/Facade.cs rename to src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs index 2a993036a3..1e64f0ccb8 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/Facade.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs @@ -4,30 +4,30 @@ using Umbraco.Core.Cache; namespace Umbraco.Web.PublishedCache.NuCache { - // implements the facade - internal class Facade : IFacade, IDisposable + // implements published snapshot + internal class PublishedShapshot : IPublishedShapshot, IDisposable { - private readonly FacadeService _service; + private readonly PublishedSnapshotService _service; private bool _defaultPreview; - private FacadeElements _elements; + private PublishedSnapshotElements _elements; #region Constructors - public Facade(FacadeService service, bool defaultPreview) + public PublishedShapshot(PublishedSnapshotService service, bool defaultPreview) { _service = service; _defaultPreview = defaultPreview; - FacadeCache = new ObjectCacheRuntimeCacheProvider(); + SnapshotCache = new ObjectCacheRuntimeCacheProvider(); } - public class FacadeElements : IDisposable + public class PublishedSnapshotElements : IDisposable { public ContentCache ContentCache; public MediaCache MediaCache; public MemberCache MemberCache; public DomainCache DomainCache; - public ICacheProvider FacadeCache; public ICacheProvider SnapshotCache; + public ICacheProvider ElementsCache; public void Dispose() { @@ -36,11 +36,11 @@ namespace Umbraco.Web.PublishedCache.NuCache } } - private FacadeElements Elements => _elements ?? (_elements = _service.GetElements(_defaultPreview)); + private PublishedSnapshotElements Elements => _elements ?? (_elements = _service.GetElements(_defaultPreview)); public void Resync() { - // no lock - facades are single-thread + // no lock - published snapshots are single-thread _elements?.Dispose(); _elements = null; } @@ -49,13 +49,13 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Caches - public ICacheProvider FacadeCache { get; } + public ICacheProvider SnapshotCache { get; } - public ICacheProvider SnapshotCache => Elements.SnapshotCache; + public ICacheProvider ElementsCache => Elements.ElementsCache; #endregion - #region IFacade + #region IPublishedSnapshot public IPublishedContentCache ContentCache => Elements.ContentCache; @@ -72,24 +72,24 @@ namespace Umbraco.Web.PublishedCache.NuCache private class ForcedPreviewObject : DisposableObject { - private readonly Facade _facade; + private readonly PublishedShapshot _publishedShapshot; private readonly bool _origPreview; private readonly Action _callback; - public ForcedPreviewObject(Facade facade, bool preview, Action callback) + public ForcedPreviewObject(PublishedShapshot publishedShapshot, bool preview, Action callback) { - _facade = facade; + _publishedShapshot = publishedShapshot; _callback = callback; // save and force - _origPreview = facade._defaultPreview; - facade._defaultPreview = preview; + _origPreview = publishedShapshot._defaultPreview; + publishedShapshot._defaultPreview = preview; } protected override void DisposeResources() { // restore - _facade._defaultPreview = _origPreview; + _publishedShapshot._defaultPreview = _origPreview; _callback?.Invoke(_origPreview); } } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs similarity index 92% rename from src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs rename to src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index c86572e47c..6e735c0255 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/FacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -31,7 +31,7 @@ using Database = Umbraco.Web.PublishedCache.NuCache.DataSource.Database; namespace Umbraco.Web.PublishedCache.NuCache { - class FacadeService : FacadeServiceBase + class PublishedSnapshotService : PublishedSnapshotServiceBase { private readonly ServiceContext _serviceContext; private readonly IPublishedContentTypeFactory _publishedContentTypeFactory; @@ -60,13 +60,13 @@ namespace Umbraco.Web.PublishedCache.NuCache public static readonly bool FullCacheWhenPreviewing = true; // define constant - determines whether to cache the published content - // objects (in the snapshot cache, or facade cache, depending on preview) + // objects (in the elements cache, or snapshot cache, depending on preview) // or to refetch them all the time. caching is faster but uses more // memory. not sure what we want. public static readonly bool CachePublishedContentChildren = true; // define constant - determines whether to cache the content cache root - // objects (in the snapshot cache, or facade cache, depending on preview) + // objects (in the elements cache, or snapshot cache, depending on preview) // or to refecth them all the time. caching is faster but uses more // memory - not sure what we want. public static readonly bool CacheContentCacheRoots = true; @@ -75,10 +75,10 @@ namespace Umbraco.Web.PublishedCache.NuCache //private static int _singletonCheck; - public FacadeService(Options options, MainDom mainDom, IRuntimeState runtime, + public PublishedSnapshotService(Options options, MainDom mainDom, IRuntimeState runtime, ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, - IScopeUnitOfWorkProvider uowProvider, IFacadeAccessor facadeAccessor, ILogger logger, IScopeProvider scopeProvider) - : base(facadeAccessor) + IScopeUnitOfWorkProvider uowProvider, IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, IScopeProvider scopeProvider) + : base(publishedSnapshotAccessor) { //if (Interlocked.Increment(ref _singletonCheck) > 1) // throw new Exception("Singleton must be instancianted only once!"); @@ -100,7 +100,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // content (and content types) from database cannot be consistent (see notes in "Handle // Notifications" region), so // - notifications will be ignored - // - trying to obtain a facade from the service will throw + // - trying to obtain a published snapshot from the service will throw if (runtime.Level != RuntimeLevel.Run) return; @@ -133,13 +133,13 @@ namespace Umbraco.Web.PublishedCache.NuCache // stores are created with a db so they can write to it, but they do not read from it, // stores need to be populated, happens in OnResolutionFrozen which uses _localDbExists to // figure out whether it can read the dbs or it should populate them from sql - _contentStore = new ContentStore(facadeAccessor, logger, _localContentDb); - _mediaStore = new ContentStore(facadeAccessor, logger, _localMediaDb); + _contentStore = new ContentStore(publishedSnapshotAccessor, logger, _localContentDb); + _mediaStore = new ContentStore(publishedSnapshotAccessor, logger, _localMediaDb); } else { - _contentStore = new ContentStore(facadeAccessor, logger); - _mediaStore = new ContentStore(facadeAccessor, logger); + _contentStore = new ContentStore(publishedSnapshotAccessor, logger); + _mediaStore = new ContentStore(publishedSnapshotAccessor, logger); } _domainStore = new SnapDictionary(); @@ -170,7 +170,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } catch (Exception e) { - _logger.Error("Panic, exception while loading cache data.", e); + _logger.Error("Panic, exception while loading cache data.", e); } // finaly, cache is ready! @@ -224,13 +224,13 @@ namespace Umbraco.Web.PublishedCache.NuCache public class Options { - // disabled: prevents the facade from updating and exposing changes - // or even creating a new facade to see changes, uses old cache = bad + // disabled: prevents the published snapshot from updating and exposing changes + // or even creating a new published snapshot to see changes, uses old cache = bad // - //// indicates that the facade cache should reuse the application request cache - //// otherwise a new cache object would be created for the facade specifically, + //// indicates that the snapshot cache should reuse the application request cache + //// otherwise a new cache object would be created for the snapshot specifically, //// which is the default - web boot manager uses this to optimze facades - //public bool FacadeCacheIsApplicationRequestCache; + //public bool PublishedSnapshotCacheIsApplicationRequestCache; public bool IgnoreLocalDb; } @@ -280,12 +280,12 @@ namespace Umbraco.Web.PublishedCache.NuCache _localContentDb?.Clear(); - _logger.Debug("Loading content from database..."); + _logger.Debug("Loading content from database..."); var sw = Stopwatch.StartNew(); var kits = _dataSource.GetAllContentSources(uow); _contentStore.SetAll(kits); sw.Stop(); - _logger.Debug("Loaded content from database (" + sw.ElapsedMilliseconds + "ms)."); + _logger.Debug("Loaded content from database (" + sw.ElapsedMilliseconds + "ms)."); } private void LoadContentFromLocalDbLocked(IScopeUnitOfWork uow) @@ -294,12 +294,12 @@ namespace Umbraco.Web.PublishedCache.NuCache .Select(x => _publishedContentTypeFactory.CreateContentType(PublishedItemType.Content, x)); _contentStore.UpdateContentTypes(null, contentTypes, null); - _logger.Debug("Loading content from local db..."); + _logger.Debug("Loading content from local db..."); var sw = Stopwatch.StartNew(); var kits = _localContentDb.Select(x => x.Value).OrderBy(x => x.Node.Level); _contentStore.SetAll(kits); sw.Stop(); - _logger.Debug("Loaded content from local db (" + sw.ElapsedMilliseconds + "ms)."); + _logger.Debug("Loaded content from local db (" + sw.ElapsedMilliseconds + "ms)."); } // keep these around - might be useful @@ -348,12 +348,12 @@ namespace Umbraco.Web.PublishedCache.NuCache _localMediaDb?.Clear(); - _logger.Debug("Loading media from database..."); + _logger.Debug("Loading media from database..."); var sw = Stopwatch.StartNew(); var kits = _dataSource.GetAllMediaSources(uow); _mediaStore.SetAll(kits); sw.Stop(); - _logger.Debug("Loaded media from database (" + sw.ElapsedMilliseconds + "ms)."); + _logger.Debug("Loaded media from database (" + sw.ElapsedMilliseconds + "ms)."); } private void LoadMediaFromLocalDbLocked(IScopeUnitOfWork uow) @@ -362,12 +362,12 @@ namespace Umbraco.Web.PublishedCache.NuCache .Select(x => _publishedContentTypeFactory.CreateContentType(PublishedItemType.Media, x)); _mediaStore.UpdateContentTypes(null, mediaTypes, null); - _logger.Debug("Loading media from local db..."); + _logger.Debug("Loading media from local db..."); var sw = Stopwatch.StartNew(); var kits = _localMediaDb.Select(x => x.Value); _mediaStore.SetAll(kits); sw.Stop(); - _logger.Debug("Loaded media from local db (" + sw.ElapsedMilliseconds + "ms)."); + _logger.Debug("Loaded media from local db (" + sw.ElapsedMilliseconds + "ms)."); } // keep these around - might be useful @@ -484,7 +484,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // note: if the service is not ready, ie _isReady is false, then notifications are ignored - // SetUmbracoVersionStep issues a DistributedCache.Instance.RefreshAllFacade() call which should cause + // SetUmbracoVersionStep issues a DistributedCache.Instance.RefreshAll...() call which should cause // the entire content, media etc caches to reload from database -- and then the app restarts -- however, // at the time SetUmbracoVersionStep runs, Umbraco is not fully initialized and therefore some property // value converters, etc are not registered, and rebuilding the NuCache may not work properly. @@ -518,7 +518,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } if (draftChanged || publishedChanged) - ((Facade)CurrentFacade).Resync(); + ((PublishedShapshot)CurrentPublishedShapshot).Resync(); } private void NotifyLocked(IEnumerable payloads, out bool draftChanged, out bool publishedChanged) @@ -537,7 +537,7 @@ namespace Umbraco.Web.PublishedCache.NuCache foreach (var payload in payloads) { - _logger.Debug($"Notified {payload.ChangeTypes} for content {payload.Id}"); + _logger.Debug($"Notified {payload.ChangeTypes} for content {payload.Id}"); if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) { @@ -615,7 +615,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } if (anythingChanged) - ((Facade)CurrentFacade).Resync(); + ((PublishedShapshot)CurrentPublishedShapshot).Resync(); } private void NotifyLocked(IEnumerable payloads, out bool anythingChanged) @@ -630,7 +630,7 @@ namespace Umbraco.Web.PublishedCache.NuCache foreach (var payload in payloads) { - _logger.Debug($"Notified {payload.ChangeTypes} for media {payload.Id}"); + _logger.Debug($"Notified {payload.ChangeTypes} for media {payload.Id}"); if (payload.ChangeTypes.HasType(TreeChangeTypes.RefreshAll)) { @@ -704,7 +704,7 @@ namespace Umbraco.Web.PublishedCache.NuCache Notify(_contentStore, payloads, RefreshContentTypesLocked); Notify(_mediaStore, payloads, RefreshMediaTypesLocked); - ((Facade)CurrentFacade).Resync(); + ((PublishedShapshot)CurrentPublishedShapshot).Resync(); } private void Notify(ContentStore store, ContentTypeCacheRefresher.JsonPayload[] payloads, Action, IEnumerable, IEnumerable, IEnumerable> action) @@ -749,7 +749,7 @@ namespace Umbraco.Web.PublishedCache.NuCache var idsA = payloads.Select(x => x.Id).ToArray(); foreach (var payload in payloads) - _logger.Debug($"Notified {(payload.Removed ? "Removed" : "Refreshed")} for data type {payload.Id}"); + _logger.Debug($"Notified {(payload.Removed ? "Removed" : "Refreshed")} for data type {payload.Id}"); using (_contentStore.GetWriter(_scopeProvider)) using (_mediaStore.GetWriter(_scopeProvider)) @@ -775,7 +775,7 @@ namespace Umbraco.Web.PublishedCache.NuCache } } - ((Facade) CurrentFacade).Resync(); + ((PublishedShapshot) CurrentPublishedShapshot).Resync(); } public override void Notify(DomainCacheRefresher.JsonPayload[] payloads) @@ -918,35 +918,35 @@ namespace Umbraco.Web.PublishedCache.NuCache #endregion - #region Create, Get Facade + #region Create, Get Published Snapshot private long _contentGen, _mediaGen, _domainGen; - private ICacheProvider _snapshotCache; + private ICacheProvider _elementsCache; - public override IFacade CreateFacade(string previewToken) + public override IPublishedShapshot CreatePublishedSnapshot(string previewToken) { // no cache, no joy if (_isReady == false) - throw new InvalidOperationException("The facade service has not properly initialized."); + throw new InvalidOperationException("The published snapshot service has not properly initialized."); var preview = previewToken.IsNullOrWhiteSpace() == false; - return new Facade(this, preview); + return new PublishedShapshot(this, preview); } - public Facade.FacadeElements GetElements(bool previewDefault) + public PublishedShapshot.PublishedSnapshotElements GetElements(bool previewDefault) { - // note: using ObjectCacheRuntimeCacheProvider for snapshot and facade caches + // note: using ObjectCacheRuntimeCacheProvider for elements and snapshot caches // is not recommended because it creates an inner MemoryCache which is a heavy // thing - better use a StaticCacheProvider which "just" creates a concurrent // dictionary - // for facade cache, StaticCacheProvider MAY be OK but it is not thread-safe, + // for snapshot cache, StaticCacheProvider MAY be OK but it is not thread-safe, // nothing like that... - // for snapshot cache, StaticCacheProvider is a No-No, use something better. + // for elements cache, StaticCacheProvider is a No-No, use something better. ContentStore.Snapshot contentSnap, mediaSnap; SnapDictionary.Snapshot domainSnap; - ICacheProvider snapshotCache; + ICacheProvider elementsCache; lock (_storesLock) { var scopeContext = _scopeProvider.Context; @@ -956,14 +956,14 @@ namespace Umbraco.Web.PublishedCache.NuCache contentSnap = _contentStore.CreateSnapshot(); mediaSnap = _mediaStore.CreateSnapshot(); domainSnap = _domainStore.CreateSnapshot(); - snapshotCache = _snapshotCache; + elementsCache = _elementsCache; } else { contentSnap = _contentStore.LiveSnapshot; mediaSnap = _mediaStore.LiveSnapshot; domainSnap = _domainStore.Test.LiveSnapshot; - snapshotCache = _snapshotCache; + elementsCache = _elementsCache; // this is tricky // we are returning elements composed from live snapshots, which we need to replace @@ -972,36 +972,36 @@ namespace Umbraco.Web.PublishedCache.NuCache // elements // just need to make sure nothing gets elements in another enlisted action... so using // a MaxValue to make sure this one runs last, and it should be ok - scopeContext.Enlist("Umbraco.Web.PublishedCache.NuCache.FacadeService.Resync", () => this, (completed, svc) => + scopeContext.Enlist("Umbraco.Web.PublishedCache.NuCache.PublishedSnapshotService.Resync", () => this, (completed, svc) => { - ((Facade) svc.CurrentFacade).Resync(); + ((PublishedShapshot) svc.CurrentPublishedShapshot).Resync(); }, int.MaxValue); } // create a new snapshot cache if snapshots are different gens - if (contentSnap.Gen != _contentGen || mediaSnap.Gen != _mediaGen || domainSnap.Gen != _domainGen || _snapshotCache == null) + if (contentSnap.Gen != _contentGen || mediaSnap.Gen != _mediaGen || domainSnap.Gen != _domainGen || _elementsCache == null) { _contentGen = contentSnap.Gen; _mediaGen = mediaSnap.Gen; _domainGen = domainSnap.Gen; - snapshotCache = _snapshotCache = new DictionaryCacheProvider(); + elementsCache = _elementsCache = new DictionaryCacheProvider(); } } - var facadeCache = new StaticCacheProvider(); + var snapshotCache = new StaticCacheProvider(); var memberTypeCache = new PublishedContentTypeCache(null, null, _serviceContext.MemberTypeService, _publishedContentTypeFactory, _logger); var domainCache = new DomainCache(domainSnap); - return new Facade.FacadeElements + return new PublishedShapshot.PublishedSnapshotElements { - ContentCache = new ContentCache(previewDefault, contentSnap, facadeCache, snapshotCache, new DomainHelper(domainCache)), - MediaCache = new MediaCache(previewDefault, mediaSnap, facadeCache, snapshotCache), - MemberCache = new MemberCache(previewDefault, facadeCache, _serviceContext.MemberService, _serviceContext.DataTypeService, memberTypeCache, FacadeAccessor), + ContentCache = new ContentCache(previewDefault, contentSnap, snapshotCache, elementsCache, new DomainHelper(domainCache)), + MediaCache = new MediaCache(previewDefault, mediaSnap, snapshotCache, elementsCache), + MemberCache = new MemberCache(previewDefault, snapshotCache, _serviceContext.MemberService, _serviceContext.DataTypeService, memberTypeCache, PublishedSnapshotAccessor), DomainCache = domainCache, - FacadeCache = facadeCache, - SnapshotCache = snapshotCache + SnapshotCache = snapshotCache, + ElementsCache = elementsCache }; } @@ -1029,7 +1029,7 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Handle Repository Events For Database PreCache // note: if the service is not ready, ie _isReady is false, then we still handle repository events, - // because we can, we do not need a working facade to do it - the only reason why it could cause an + // because we can, we do not need a working published snapshot to do it - the only reason why it could cause an // issue is if the database table is not ready, but that should be prevented by migrations. // we need them to be "repository" events ie to trigger from within the repository transaction, diff --git a/src/Umbraco.Web/PublishedCache/NuCache/notes.txt b/src/Umbraco.Web/PublishedCache/NuCache/notes.txt index ef145bf0fd..ff2d8dd48b 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/notes.txt +++ b/src/Umbraco.Web/PublishedCache/NuCache/notes.txt @@ -1,6 +1,10 @@ NuCache Documentation ====================== +NOTE - RENAMING +Facade = PublishedSnapshot +and everything needs to be renamed accordingly + HOW IT WORKS ------------- diff --git a/src/Umbraco.Web/PublishedCache/PublishedElement.cs b/src/Umbraco.Web/PublishedCache/PublishedElement.cs index 3cbdb890be..e5b26453a4 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedElement.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedElement.cs @@ -17,14 +17,14 @@ namespace Umbraco.Web.PublishedCache internal class PublishedElement : IPublishedElement { // initializes a new instance of the PublishedElement class - // within the context of a facade service (eg a published content property value) + // within the context of a published snapshot service (eg a published content property value) public PublishedElement(PublishedContentType contentType, Guid key, Dictionary values, bool previewing, - PropertyCacheLevel referenceCacheLevel, IFacadeAccessor facadeAccessor) + PropertyCacheLevel referenceCacheLevel, IPublishedSnapshotAccessor publishedSnapshotAccessor) { if (key == Guid.Empty) throw new ArgumentException("Empty guid."); if (values == null) throw new ArgumentNullException(nameof(values)); - if (referenceCacheLevel != PropertyCacheLevel.None && facadeAccessor == null) - throw new ArgumentNullException("A facade accessor is required when referenceCacheLevel != None.", nameof(facadeAccessor)); + if (referenceCacheLevel != PropertyCacheLevel.None && publishedSnapshotAccessor == null) + throw new ArgumentNullException("A published snapshot accessor is required when referenceCacheLevel != None.", nameof(publishedSnapshotAccessor)); ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType)); Key = key; @@ -36,13 +36,13 @@ namespace Umbraco.Web.PublishedCache .Select(propertyType => { values.TryGetValue(propertyType.PropertyTypeAlias, out var value); - return (IPublishedProperty) new PublishedElementPropertyBase(propertyType, this, previewing, referenceCacheLevel, value, facadeAccessor); + return (IPublishedProperty) new PublishedElementPropertyBase(propertyType, this, previewing, referenceCacheLevel, value, publishedSnapshotAccessor); }) .ToArray(); } // initializes a new instance of the PublishedElement class - // without any context, so it's purely 'standalone' and should NOT interfere with the facade service + // without any context, so it's purely 'standalone' and should NOT interfere with the published snapshot service // + using an initial reference cache level of .None ensures that everything will be // cached at .Content level - and that reference cache level will propagate to all // properties diff --git a/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs b/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs index af9f6fe774..91681558ac 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedElementPropertyBase.cs @@ -9,7 +9,7 @@ namespace Umbraco.Web.PublishedCache { private readonly object _locko = new object(); private readonly object _sourceValue; - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; protected readonly IPublishedElement Element; protected readonly bool IsPreviewing; @@ -26,11 +26,11 @@ namespace Umbraco.Web.PublishedCache // so making it configureable. private const bool FullCacheWhenPreviewing = true; - public PublishedElementPropertyBase(PublishedPropertyType propertyType, IPublishedElement element, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null, IFacadeAccessor facadeAccessor = null) + public PublishedElementPropertyBase(PublishedPropertyType propertyType, IPublishedElement element, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null, IPublishedSnapshotAccessor publishedSnapshotAccessor = null) : base(propertyType, referenceCacheLevel) { _sourceValue = sourceValue; - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; Element = element; IsPreviewing = previewing; IsMember = propertyType.ContentType.ItemType == PublishedItemType.Member; @@ -55,7 +55,7 @@ namespace Umbraco.Web.PublishedCache public static string PropertyCacheValues(Guid contentUid, string typeAlias, bool previewing) { - return "Facade.Property.CacheValues[" + (previewing ? "D:" : "P:") + contentUid + ":" + typeAlias + "]"; + return "PublishedSnapshot.Property.CacheValues[" + (previewing ? "D:" : "P:") + contentUid + ":" + typeAlias + "]"; } private void GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel) @@ -69,9 +69,9 @@ namespace Umbraco.Web.PublishedCache // don't change the reference. // // examples: - // currently (reference) caching at facade, property specifies - // snapshot, ok to use content. OTOH, currently caching at snapshot, - // property specifies facade, need to use facade. + // currently (reference) caching at published snapshot, property specifies + // elements, ok to use element. OTOH, currently caching at elements, + // property specifies snapshot, need to use snapshot. // if (PropertyType.CacheLevel > ReferenceCacheLevel || PropertyType.CacheLevel == PropertyCacheLevel.None) { @@ -80,22 +80,22 @@ namespace Umbraco.Web.PublishedCache } else { - cacheLevel = PropertyCacheLevel.Content; + cacheLevel = PropertyCacheLevel.Element; referenceCacheLevel = ReferenceCacheLevel; } } private ICacheProvider GetSnapshotCache() { - // cache within the snapshot cache, unless previewing, then use the facade or - // snapshot cache (if we don't want to pollute the snapshot cache with short-lived + // cache within the snapshot cache, unless previewing, then use the snapshot or + // elements cache (if we don't want to pollute the elements cache with short-lived // data) depending on settings - // for members, always cache in the facade cache - never pollute snapshot cache - var facade = _facadeAccessor?.Facade; - if (facade == null) return null; + // for members, always cache in the snapshot cache - never pollute elements cache + var publishedSnapshot = _publishedSnapshotAccessor?.PublishedSnapshot; + if (publishedSnapshot == null) return null; return (IsPreviewing == false || FullCacheWhenPreviewing) && IsMember == false - ? facade.SnapshotCache - : facade.FacadeCache; + ? publishedSnapshot.ElementsCache + : publishedSnapshot.SnapshotCache; } private CacheValues GetCacheValues(PropertyCacheLevel cacheLevel) @@ -107,18 +107,18 @@ namespace Umbraco.Web.PublishedCache // never cache anything cacheValues = new CacheValues(); break; - case PropertyCacheLevel.Content: + case PropertyCacheLevel.Element: // cache within the property object itself, ie within the content object cacheValues = _cacheValues ?? (_cacheValues = new CacheValues()); break; - case PropertyCacheLevel.Snapshot: - // cache within the snapshot cache, depending... + case PropertyCacheLevel.Elements: + // cache within the elements cache, depending... var snapshotCache = GetSnapshotCache(); cacheValues = (CacheValues) snapshotCache?.GetCacheItem(ValuesCacheKey, () => new CacheValues()) ?? new CacheValues(); break; - case PropertyCacheLevel.Facade: - // cache within the facade cache - var facadeCache = _facadeAccessor?.Facade?.FacadeCache; + case PropertyCacheLevel.Snapshot: + // cache within the snapshot cache + var facadeCache = _publishedSnapshotAccessor?.PublishedSnapshot?.SnapshotCache; cacheValues = (CacheValues) facadeCache?.GetCacheItem(ValuesCacheKey, () => new CacheValues()) ?? new CacheValues(); break; default: diff --git a/src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs b/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs similarity index 64% rename from src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs rename to src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs index e21e54aa5e..08a754153c 100644 --- a/src/Umbraco.Web/PublishedCache/FacadeServiceBase.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedSnapshotServiceBase.cs @@ -4,20 +4,20 @@ using Umbraco.Web.Cache; namespace Umbraco.Web.PublishedCache { - abstract class FacadeServiceBase : IFacadeService + abstract class PublishedSnapshotServiceBase : IPublishedSnapshotService { - protected FacadeServiceBase(IFacadeAccessor facadeAccessor) + protected PublishedSnapshotServiceBase(IPublishedSnapshotAccessor publishedSnapshotAccessor) { - FacadeAccessor = facadeAccessor; + PublishedSnapshotAccessor = publishedSnapshotAccessor; } - public IFacadeAccessor FacadeAccessor { get; } + public IPublishedSnapshotAccessor PublishedSnapshotAccessor { get; } - // note: NOT setting _facadeAccessor.Facade here because it is the + // note: NOT setting _publishedSnapshotAccessor.PublishedSnapshot here because it is the // responsibility of the caller to manage what the 'current' facade is - public abstract IFacade CreateFacade(string previewToken); + public abstract IPublishedShapshot CreatePublishedSnapshot(string previewToken); - protected IFacade CurrentFacade => FacadeAccessor.Facade; + protected IPublishedShapshot CurrentPublishedShapshot => PublishedSnapshotAccessor.PublishedSnapshot; public abstract bool EnsureEnvironment(out IEnumerable errors); diff --git a/src/Umbraco.Web/PublishedCache/UmbracoContextFacadeAccessor.cs b/src/Umbraco.Web/PublishedCache/UmbracoContextPublishedSnapshotAccessor.cs similarity index 67% rename from src/Umbraco.Web/PublishedCache/UmbracoContextFacadeAccessor.cs rename to src/Umbraco.Web/PublishedCache/UmbracoContextPublishedSnapshotAccessor.cs index 8cdd67fa37..cc4b09f657 100644 --- a/src/Umbraco.Web/PublishedCache/UmbracoContextFacadeAccessor.cs +++ b/src/Umbraco.Web/PublishedCache/UmbracoContextPublishedSnapshotAccessor.cs @@ -2,22 +2,22 @@ namespace Umbraco.Web.PublishedCache { - public class UmbracoContextFacadeAccessor : IFacadeAccessor + public class UmbracoContextPublishedSnapshotAccessor : IPublishedSnapshotAccessor { private readonly IUmbracoContextAccessor _umbracoContextAccessor; - public UmbracoContextFacadeAccessor(IUmbracoContextAccessor umbracoContextAccessor) + public UmbracoContextPublishedSnapshotAccessor(IUmbracoContextAccessor umbracoContextAccessor) { _umbracoContextAccessor = umbracoContextAccessor; } - public IFacade Facade + public IPublishedShapshot PublishedSnapshot { get { var umbracoContext = _umbracoContextAccessor.UmbracoContext; if (umbracoContext == null) throw new Exception("The IUmbracoContextAccessor could not provide an UmbracoContext."); - return umbracoContext.Facade; + return umbracoContext.PublishedShapshot; } set diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/Facade.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs similarity index 82% rename from src/Umbraco.Web/PublishedCache/XmlPublishedCache/Facade.cs rename to src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs index 03a36d8094..b21a1e80d4 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/Facade.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs @@ -1,21 +1,19 @@ using System; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PublishedCache.XmlPublishedCache { /// - /// Implements a facade. + /// Implements a published snapshot. /// - class Facade : IFacade + class PublishedShapshot : IPublishedShapshot { /// - /// Initializes a new instance of the class with a content cache + /// Initializes a new instance of the class with a content cache /// and a media cache. /// - public Facade( + public PublishedShapshot( PublishedContentCache contentCache, PublishedMediaCache mediaCache, PublishedMemberCache memberCache, @@ -40,10 +38,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache public IDomainCache DomainCache { get; } /// - public ICacheProvider FacadeCache => null; + public ICacheProvider SnapshotCache => null; /// - public ICacheProvider SnapshotCache => null; + public ICacheProvider ElementsCache => null; /// public IDisposable ForcedPreview(bool preview, Action callback = null) diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedSnapshotService.cs similarity index 88% rename from src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs rename to src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedSnapshotService.cs index 4826e215ea..ab8c361acc 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/FacadeService.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedSnapshotService.cs @@ -16,9 +16,9 @@ using Umbraco.Web.Cache; namespace Umbraco.Web.PublishedCache.XmlPublishedCache { /// - /// Implements a facade service. + /// Implements a published snapshot service. /// - internal class FacadeService : FacadeServiceBase + internal class PublishedSnapshotService : PublishedSnapshotServiceBase { private readonly XmlStore _xmlStore; private readonly RoutesCache _routesCache; @@ -32,51 +32,51 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache #region Constructors // used in WebBootManager + tests - public FacadeService(ServiceContext serviceContext, + public PublishedSnapshotService(ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IScopeProvider scopeProvider, IScopeUnitOfWorkProvider uowProvider, ICacheProvider requestCache, IEnumerable segmentProviders, - IFacadeAccessor facadeAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, MainDom mainDom, bool testing = false, bool enableRepositoryEvents = true) - : this(serviceContext, publishedContentTypeFactory, scopeProvider, uowProvider, requestCache, segmentProviders, facadeAccessor, logger, null, mainDom, testing, enableRepositoryEvents) + : this(serviceContext, publishedContentTypeFactory, scopeProvider, uowProvider, requestCache, segmentProviders, publishedSnapshotAccessor, logger, null, mainDom, testing, enableRepositoryEvents) { } // used in some tests - internal FacadeService(ServiceContext serviceContext, + internal PublishedSnapshotService(ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IScopeProvider scopeProvider, IScopeUnitOfWorkProvider uowProvider, ICacheProvider requestCache, - IFacadeAccessor facadeAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, PublishedContentTypeCache contentTypeCache, MainDom mainDom, bool testing, bool enableRepositoryEvents) - : this(serviceContext, publishedContentTypeFactory, scopeProvider, uowProvider, requestCache, Enumerable.Empty(), facadeAccessor, logger, contentTypeCache, mainDom, testing, enableRepositoryEvents) + : this(serviceContext, publishedContentTypeFactory, scopeProvider, uowProvider, requestCache, Enumerable.Empty(), publishedSnapshotAccessor, logger, contentTypeCache, mainDom, testing, enableRepositoryEvents) { } - private FacadeService(ServiceContext serviceContext, + private PublishedSnapshotService(ServiceContext serviceContext, IPublishedContentTypeFactory publishedContentTypeFactory, IScopeProvider scopeProvider, IScopeUnitOfWorkProvider uowProvider, ICacheProvider requestCache, IEnumerable segmentProviders, - IFacadeAccessor facadeAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, PublishedContentTypeCache contentTypeCache, MainDom mainDom, bool testing, bool enableRepositoryEvents) - : base(facadeAccessor) + : base(publishedSnapshotAccessor) { _routesCache = new RoutesCache(); _contentTypeCache = contentTypeCache ?? new PublishedContentTypeCache(serviceContext.ContentTypeService, serviceContext.MediaTypeService, serviceContext.MemberTypeService, publishedContentTypeFactory, logger); - _xmlStore = new XmlStore(serviceContext, scopeProvider, uowProvider, _routesCache, _contentTypeCache, segmentProviders, facadeAccessor, mainDom, testing, enableRepositoryEvents); + _xmlStore = new XmlStore(serviceContext, scopeProvider, uowProvider, _routesCache, _contentTypeCache, segmentProviders, publishedSnapshotAccessor, mainDom, testing, enableRepositoryEvents); _domainService = serviceContext.DomainService; _memberService = serviceContext.MemberService; @@ -117,7 +117,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache #region Caches - public override IFacade CreateFacade(string previewToken) + public override IPublishedShapshot CreatePublishedSnapshot(string previewToken) { // use _requestCache to store recursive properties lookup, etc. both in content // and media cache. Life span should be the current request. Or, ideally @@ -126,7 +126,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache var domainCache = new DomainCache(_domainService); - return new Facade( + return new PublishedShapshot( new PublishedContentCache(_xmlStore, domainCache, _requestCache, _contentTypeCache, _routesCache, previewToken), new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache), new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache), diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlCacheComponent.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlCacheComponent.cs index b8c761eff8..c6ae22b132 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlCacheComponent.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlCacheComponent.cs @@ -20,14 +20,14 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache base.Compose(composition); // register the XML facade service - composition.SetFacadeService(factory => new FacadeService( + composition.SetPublishedSnapshotService(factory => new PublishedSnapshotService( factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance(), factory.GetInstance().RequestCache, factory.GetInstance(), - factory.GetInstance(), + factory.GetInstance(), factory.GetInstance(), factory.GetInstance())); @@ -35,7 +35,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache composition.HealthChecks().Add(); } - public void Initialize(IFacadeService service) + public void Initialize(IPublishedSnapshotService service) { // nothing - this just ensures that the service is created at boot time } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs index 535571007b..24457468fe 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedContent.cs @@ -32,7 +32,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache private readonly XmlNode _xmlNode; private readonly bool _isPreviewing; - private readonly ICacheProvider _cacheProvider; // at facade/request level (see PublishedContentCache) + private readonly ICacheProvider _cacheProvider; // at snapshot/request level (see PublishedContentCache) private readonly PublishedContentTypeCache _contentTypeCache; private bool _nodeInitialized; diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs index 6e2b000a1e..b23919f0c5 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlPublishedProperty.cs @@ -45,7 +45,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache if (_objectValueComputed) return _objectValue; var inter = PropertyType.ConvertSourceToInter(_content, _sourceValue, _isPreviewing); // initial reference cache level always is .Content - _objectValue = PropertyType.ConvertInterToObject(_content, PropertyCacheLevel.Content, inter, _isPreviewing); + _objectValue = PropertyType.ConvertInterToObject(_content, PropertyCacheLevel.Element, inter, _isPreviewing); _objectValueComputed = true; return _objectValue; } diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs index 80b0c98cd4..225402045b 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache /// Represents the Xml storage for the Xml published cache. /// /// - /// One instance of is instanciated by the and + /// One instance of is instanciated by the and /// then passed to all instances that are created (one per request). /// This class should *not* be public. /// @@ -47,7 +47,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache private volatile bool _released; private bool _withRepositoryEvents; - private readonly IFacadeAccessor _facadeAccessor; + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly PublishedContentTypeCache _contentTypeCache; private readonly RoutesCache _routesCache; private readonly ServiceContext _serviceContext; // fixme WHY @@ -61,15 +61,15 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache /// /// The default constructor will boot the cache, load data from file or database, /// wire events in order to manage changes, etc. public XmlStore(ServiceContext serviceContext, IScopeProvider scopeProvider, IScopeUnitOfWorkProvider uowProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache, - IEnumerable segmentProviders, IFacadeAccessor facadeAccessor, MainDom mainDom) - : this(serviceContext, scopeProvider, uowProvider, routesCache, contentTypeCache, segmentProviders, facadeAccessor, mainDom, false, false) + IEnumerable segmentProviders, IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom) + : this(serviceContext, scopeProvider, uowProvider, routesCache, contentTypeCache, segmentProviders, publishedSnapshotAccessor, mainDom, false, false) { } // internal for unit tests // no file nor db, no config check // fixme - er, we DO have a DB? internal XmlStore(ServiceContext serviceContext, IScopeProvider scopeProvider, IScopeUnitOfWorkProvider uowProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache, - IEnumerable segmentProviders, IFacadeAccessor facadeAccessor, MainDom mainDom, + IEnumerable segmentProviders, IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom, bool testing, bool enableRepositoryEvents) { if (testing == false) @@ -80,7 +80,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache _uowProvider = uowProvider; _routesCache = routesCache; _contentTypeCache = contentTypeCache; - _facadeAccessor = facadeAccessor; + _publishedSnapshotAccessor = publishedSnapshotAccessor; InitializeSerializers(segmentProviders); @@ -593,17 +593,17 @@ AND (umbracoNode.id=@id)"; // should we have async versions that would do: ? // var releaser = await _xmlLock.LockAsync(); // - // fixme - not sure about the "resync current facade" thing here, see 7.6... + // fixme - not sure about the "resync current published snapshot" thing here, see 7.6... // gets a locked safe read access to the main xml private SafeXmlReaderWriter GetSafeXmlReader() { return SafeXmlReaderWriter.Get(_scopeProvider, _xmlLock, _xml, - ResyncCurrentFacade, + ResyncCurrentPublishedSnapshot, (xml, registerXmlChange) => { SetXmlLocked(xml, registerXmlChange); - ResyncCurrentFacade(xml); + ResyncCurrentPublishedSnapshot(xml); }, false); } @@ -611,11 +611,11 @@ AND (umbracoNode.id=@id)"; private SafeXmlReaderWriter GetSafeXmlWriter() { return SafeXmlReaderWriter.Get(_scopeProvider, _xmlLock, _xml, - ResyncCurrentFacade, + ResyncCurrentPublishedSnapshot, (xml, registerXmlChange) => { SetXmlLocked(xml, registerXmlChange); - ResyncCurrentFacade(xml); + ResyncCurrentPublishedSnapshot(xml); }, true); } @@ -1241,12 +1241,12 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder"; // ignore media and member types - we're not caching them } - private void ResyncCurrentFacade(XmlDocument xml) + private void ResyncCurrentPublishedSnapshot(XmlDocument xml) { - var facade = (Facade) _facadeAccessor.Facade; - if (facade == null) return; - ((PublishedContentCache) facade.ContentCache).Resync(xml); - ((PublishedMediaCache) facade.MediaCache).Resync(); + var publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot; + if (publishedSnapshot == null) return; + ((PublishedContentCache) publishedSnapshot.ContentCache).Resync(xml); + ((PublishedMediaCache) publishedSnapshot.MediaCache).Resync(); // not trying to resync members or domains, which are not cached really } diff --git a/src/Umbraco.Web/Routing/AliasUrlProvider.cs b/src/Umbraco.Web/Routing/AliasUrlProvider.cs index 9215719712..8179bbed03 100644 --- a/src/Umbraco.Web/Routing/AliasUrlProvider.cs +++ b/src/Umbraco.Web/Routing/AliasUrlProvider.cs @@ -63,7 +63,7 @@ namespace Umbraco.Web.Routing if (string.IsNullOrWhiteSpace(umbracoUrlName)) return Enumerable.Empty(); - var domainHelper = new DomainHelper(umbracoContext.Facade.DomainCache); + var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.DomainCache); var n = node; var domainUris = domainHelper.DomainsForNode(n.Id, current, false); diff --git a/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs b/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs index f4a3bc5d42..fc357e098a 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs @@ -54,7 +54,7 @@ namespace Umbraco.Web.Routing } if (node != null) { - var d = DomainHelper.FindWildcardDomainInPath(frequest.UmbracoContext.Facade.DomainCache.GetAll(true), node.Path, null); + var d = DomainHelper.FindWildcardDomainInPath(frequest.UmbracoContext.PublishedShapshot.DomainCache.GetAll(true), node.Path, null); if (d != null) errorCulture = d.Culture; } diff --git a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs index f88379ae16..ef68115d0b 100644 --- a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs +++ b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs @@ -55,7 +55,7 @@ namespace Umbraco.Web.Routing return null; } - var domainHelper = new DomainHelper(umbracoContext.Facade.DomainCache); + var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.DomainCache); // extract domainUri and path // route is / or / @@ -97,7 +97,7 @@ namespace Umbraco.Web.Routing return null; } - var domainHelper = new DomainHelper(umbracoContext.Facade.DomainCache); + var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.DomainCache); // extract domainUri and path // route is / or / diff --git a/src/Umbraco.Web/Routing/Domain.cs b/src/Umbraco.Web/Routing/Domain.cs index f74422d25d..b9116c6b51 100644 --- a/src/Umbraco.Web/Routing/Domain.cs +++ b/src/Umbraco.Web/Routing/Domain.cs @@ -3,7 +3,7 @@ namespace Umbraco.Web.Routing { /// - /// Represents a facade domain. + /// Represents a published snapshot domain. /// public class Domain { diff --git a/src/Umbraco.Web/Routing/DomainAndUri.cs b/src/Umbraco.Web/Routing/DomainAndUri.cs index 00157a63e3..8aaeec52ef 100644 --- a/src/Umbraco.Web/Routing/DomainAndUri.cs +++ b/src/Umbraco.Web/Routing/DomainAndUri.cs @@ -4,7 +4,7 @@ using Umbraco.Core; namespace Umbraco.Web.Routing { /// - /// Represents a facade domain with its normalized uri. + /// Represents a published snapshot domain with its normalized uri. /// /// /// In Umbraco it is valid to create domains with name such as example.com, https://www.example.com, example.com/foo/. diff --git a/src/Umbraco.Web/Routing/DomainHelper.cs b/src/Umbraco.Web/Routing/DomainHelper.cs index 0b45407cab..79ccb9fbd4 100644 --- a/src/Umbraco.Web/Routing/DomainHelper.cs +++ b/src/Umbraco.Web/Routing/DomainHelper.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using Umbraco.Core; using Umbraco.Web.Composing; -using Umbraco.Web.PublishedCache; // Facade +using Umbraco.Web.PublishedCache; // published snapshot namespace Umbraco.Web.Routing { diff --git a/src/Umbraco.Web/Routing/PublishedContentRequest.cs b/src/Umbraco.Web/Routing/PublishedContentRequest.cs index d50ee8baba..60f71bc051 100644 --- a/src/Umbraco.Web/Routing/PublishedContentRequest.cs +++ b/src/Umbraco.Web/Routing/PublishedContentRequest.cs @@ -10,7 +10,7 @@ using RenderingEngine = Umbraco.Core.RenderingEngine; namespace Umbraco.Web.Routing { - // todo - rename to FacadeRequest as soon as acceptable + // todo - rename to PublishedRequest as soon as acceptable /// /// Represents a request for one specified Umbraco IPublishedContent to be rendered @@ -18,7 +18,7 @@ namespace Umbraco.Web.Routing /// public class PublishedContentRequest { - private readonly FacadeRouter _facadeRouter; + private readonly PublishedRouter _publishedRouter; private bool _readonly; // after prepared private bool _readonlyUri; // after preparing @@ -34,13 +34,13 @@ namespace Umbraco.Web.Routing /// /// Initializes a new instance of the class. /// - /// The facade router. + /// The published router. /// The Umbraco context. /// The request Uri. - internal PublishedContentRequest(FacadeRouter facadeRouter, UmbracoContext umbracoContext, Uri uri = null) + internal PublishedContentRequest(PublishedRouter publishedRouter, UmbracoContext umbracoContext, Uri uri = null) { UmbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext)); - _facadeRouter = facadeRouter ?? throw new ArgumentNullException(nameof(facadeRouter)); + _publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter)); Uri = uri ?? umbracoContext.CleanedUmbracoUrl; RenderingEngine = RenderingEngine.Unknown; } @@ -77,7 +77,7 @@ namespace Umbraco.Web.Routing /// public void Prepare() { - _facadeRouter.PrepareRequest(this); + _publishedRouter.PrepareRequest(this); } #region Events @@ -240,7 +240,7 @@ namespace Umbraco.Web.Routing _template = value; RenderingEngine = RenderingEngine.Unknown; // reset if (_template != null) - RenderingEngine = _facadeRouter.FindTemplateRenderingEngine(_template.Alias); + RenderingEngine = _publishedRouter.FindTemplateRenderingEngine(_template.Alias); } } @@ -271,7 +271,7 @@ namespace Umbraco.Web.Routing // NOTE - can we stil get it with whitespaces in it due to old legacy bugs? alias = alias.Replace(" ", ""); - var model = _facadeRouter.GetTemplate(alias); + var model = _publishedRouter.GetTemplate(alias); if (model == null) return false; @@ -309,7 +309,7 @@ namespace Umbraco.Web.Routing { var __readonly = _readonly; _readonly = false; - _facadeRouter.UpdateRequestOnMissingTemplate(this); + _publishedRouter.UpdateRequestOnMissingTemplate(this); _readonly = __readonly; } diff --git a/src/Umbraco.Web/Routing/FacadeRouter.cs b/src/Umbraco.Web/Routing/PublishedRouter.cs similarity index 85% rename from src/Umbraco.Web/Routing/FacadeRouter.cs rename to src/Umbraco.Web/Routing/PublishedRouter.cs index 1016cf0d6f..1b87ddc863 100644 --- a/src/Umbraco.Web/Routing/FacadeRouter.cs +++ b/src/Umbraco.Web/Routing/PublishedRouter.cs @@ -18,19 +18,10 @@ using RenderingEngine = Umbraco.Core.RenderingEngine; namespace Umbraco.Web.Routing { - // this provides the logic to published content requests - // there is only one instance of this class and it has all - // the dependencies injected - - internal class FacadeRouter + // fixme - make this public + // fixme - making sense to have an interface? + internal class PublishedRouter { - // fixme - coupling PublishedContentRequest & PublishedContentRequestEngine - // is bad - // could be entirely stateless! and unique! or merged into the request entirely! - // depends on whether we want the request to be a simple DTO = yes - - // fixme - maybe we should be initialized with UmbracoContext accessor instead? - private readonly IWebRoutingSection _webRoutingSection; private readonly ContentFinderCollection _contentFinders; private readonly IContentLastChanceFinder _contentLastChanceFinder; @@ -39,9 +30,9 @@ namespace Umbraco.Web.Routing private readonly ILogger _logger; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public FacadeRouter( + public PublishedRouter( IWebRoutingSection webRoutingSection, ContentFinderCollection contentFinders, IContentLastChanceFinder contentLastChanceFinder, @@ -49,9 +40,7 @@ namespace Umbraco.Web.Routing ProfilingLogger proflog, Func> getRolesForLogin = null) { - if (webRoutingSection == null) throw new ArgumentNullException(nameof(webRoutingSection)); // fixme usage? - - _webRoutingSection = webRoutingSection; + _webRoutingSection = webRoutingSection ?? throw new ArgumentNullException(nameof(webRoutingSection)); // fixme usage? _contentFinders = contentFinders ?? throw new ArgumentNullException(nameof(contentFinders)); _contentLastChanceFinder = contentLastChanceFinder ?? throw new ArgumentNullException(nameof(contentLastChanceFinder)); _services = services ?? throw new ArgumentNullException(nameof(services)); @@ -274,16 +263,16 @@ namespace Umbraco.Web.Routing // note - we are not handling schemes nor ports here. - _logger.Debug("{0}Uri=\"{1}\"", () => tracePrefix, () => request.Uri); + _logger.Debug("{0}Uri=\"{1}\"", () => tracePrefix, () => request.Uri); // try to find a domain matching the current request - var domainAndUri = DomainHelper.DomainForUri(request.UmbracoContext.Facade.DomainCache.GetAll(false), request.Uri); + var domainAndUri = DomainHelper.DomainForUri(request.UmbracoContext.PublishedShapshot.DomainCache.GetAll(false), request.Uri); // handle domain - always has a contentId and a culture if (domainAndUri != null) { // matching an existing domain - _logger.Debug("{0}Matches domain=\"{1}\", rootId={2}, culture=\"{3}\"", + _logger.Debug("{0}Matches domain=\"{1}\", rootId={2}, culture=\"{3}\"", () => tracePrefix, () => domainAndUri.Name, () => domainAndUri.ContentId, @@ -302,13 +291,13 @@ namespace Umbraco.Web.Routing else { // not matching any existing domain - _logger.Debug("{0}Matches no domain", () => tracePrefix); + _logger.Debug("{0}Matches no domain", () => tracePrefix); var defaultLanguage = _services.LocalizationService.GetAllLanguages().FirstOrDefault(); request.Culture = defaultLanguage == null ? CultureInfo.CurrentUICulture : new CultureInfo(defaultLanguage.IsoCode); } - _logger.Debug("{0}Culture=\"{1}\"", () => tracePrefix, () => request.Culture.Name); + _logger.Debug("{0}Culture=\"{1}\"", () => tracePrefix, () => request.Culture.Name); return request.Domain != null; } @@ -324,20 +313,20 @@ namespace Umbraco.Web.Routing return; var nodePath = request.PublishedContent.Path; - _logger.Debug("{0}Path=\"{1}\"", () => tracePrefix, () => nodePath); + _logger.Debug("{0}Path=\"{1}\"", () => tracePrefix, () => nodePath); var rootNodeId = request.HasDomain ? request.Domain.ContentId : (int?)null; - var domain = DomainHelper.FindWildcardDomainInPath(request.UmbracoContext.Facade.DomainCache.GetAll(true), nodePath, rootNodeId); + var domain = DomainHelper.FindWildcardDomainInPath(request.UmbracoContext.PublishedShapshot.DomainCache.GetAll(true), nodePath, rootNodeId); // always has a contentId and a culture if (domain != null) { request.Culture = domain.Culture; - _logger.Debug("{0}Got domain on node {1}, set culture to \"{2}\".", () => tracePrefix, + _logger.Debug("{0}Got domain on node {1}, set culture to \"{2}\".", () => tracePrefix, () => domain.ContentId, () => request.Culture.Name); } else { - _logger.Debug("{0}No match.", () => tracePrefix); + _logger.Debug("{0}No match.", () => tracePrefix); } } @@ -411,7 +400,7 @@ namespace Umbraco.Web.Routing private void FindPublishedContentAndTemplate(PublishedContentRequest request) { const string tracePrefix = "FindPublishedContentAndTemplate: "; - _logger.Debug("{0}Path=\"{1}\"", () => tracePrefix, () => request.Uri.AbsolutePath); + _logger.Debug("{0}Path=\"{1}\"", () => tracePrefix, () => request.Uri.AbsolutePath); // run the document finders FindPublishedContent(request); @@ -447,14 +436,14 @@ namespace Umbraco.Web.Routing // the first successful finder, if any, will set this.PublishedContent, and may also set this.Template // some finders may implement caching - using (_profilingLogger.DebugDuration( + using (_profilingLogger.DebugDuration( $"{tracePrefix}Begin finders", $"{tracePrefix}End finders, {(request.HasPublishedContent ? "a document was found" : "no document was found")}")) { //iterate but return on first one that finds it var found = _contentFinders.Any(finder => { - _logger.Debug("Finder " + finder.GetType().FullName); + _logger.Debug("Finder " + finder.GetType().FullName); return finder.TryFindContent(request); }); } @@ -480,22 +469,22 @@ namespace Umbraco.Web.Routing const int maxLoop = 8; do { - _logger.Debug("{0}{1}", () => tracePrefix, () => (i == 0 ? "Begin" : "Loop")); + _logger.Debug("{0}{1}", () => tracePrefix, () => (i == 0 ? "Begin" : "Loop")); // handle not found if (request.HasPublishedContent == false) { request.Is404 = true; - _logger.Debug("{0}No document, try last chance lookup", () => tracePrefix); + _logger.Debug("{0}No document, try last chance lookup", () => tracePrefix); // if it fails then give up, there isn't much more that we can do if (_contentLastChanceFinder.TryFindContent(request) == false) { - _logger.Debug("{0}Failed to find a document, give up", () => tracePrefix); + _logger.Debug("{0}Failed to find a document, give up", () => tracePrefix); break; } - _logger.Debug("{0}Found a document", () => tracePrefix); + _logger.Debug("{0}Found a document", () => tracePrefix); } // follow internal redirects as long as it's not running out of control ie infinite loop of some sort @@ -517,11 +506,11 @@ namespace Umbraco.Web.Routing if (i == maxLoop || j == maxLoop) { - _logger.Debug("{0}Looks like we're running into an infinite loop, abort", () => tracePrefix); + _logger.Debug("{0}Looks like we're running into an infinite loop, abort", () => tracePrefix); request.PublishedContent = null; } - _logger.Debug("{0}End", () => tracePrefix); + _logger.Debug("{0}End", () => tracePrefix); } /// @@ -568,23 +557,23 @@ namespace Umbraco.Web.Routing if (valid == false) { // bad redirect - log and display the current page (legacy behavior) - _logger.Debug($"{tracePrefix}Failed to redirect to id={request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).SourceValue}: value is not an int nor a GuidUdi."); + _logger.Debug($"{tracePrefix}Failed to redirect to id={request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).SourceValue}: value is not an int nor a GuidUdi."); } if (internalRedirectNode == null) { - _logger.Debug($"{tracePrefix}Failed to redirect to id={request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).SourceValue}: no such published document."); + _logger.Debug($"{tracePrefix}Failed to redirect to id={request.PublishedContent.GetProperty(Constants.Conventions.Content.InternalRedirectId).SourceValue}: no such published document."); } else if (internalRedirectId == request.PublishedContent.Id) { // redirect to self - _logger.Debug($"{tracePrefix}Redirecting to self, ignore"); + _logger.Debug($"{tracePrefix}Redirecting to self, ignore"); } else { request.SetInternalRedirectPublishedContent(internalRedirectNode); // don't use .PublishedContent here redirect = true; - _logger.Debug($"{tracePrefix}Redirecting to id={internalRedirectId}"); + _logger.Debug($"{tracePrefix}Redirecting to id={internalRedirectId}"); } return redirect; @@ -607,34 +596,34 @@ namespace Umbraco.Web.Routing if (publicAccessAttempt) { - _logger.Debug("{0}Page is protected, check for access", () => tracePrefix); + _logger.Debug("{0}Page is protected, check for access", () => tracePrefix); var membershipHelper = new MembershipHelper(request.UmbracoContext); if (membershipHelper.IsLoggedIn() == false) { - _logger.Debug("{0}Not logged in, redirect to login page", () => tracePrefix); + _logger.Debug("{0}Not logged in, redirect to login page", () => tracePrefix); var loginPageId = publicAccessAttempt.Result.LoginNodeId; if (loginPageId != request.PublishedContent.Id) - request.PublishedContent = request.UmbracoContext.Facade.ContentCache.GetById(loginPageId); + request.PublishedContent = request.UmbracoContext.PublishedShapshot.ContentCache.GetById(loginPageId); } else if (_services.PublicAccessService.HasAccess(request.PublishedContent.Id, _services.ContentService, GetRolesForLogin(membershipHelper.CurrentUserName)) == false) { - _logger.Debug("{0}Current member has not access, redirect to error page", () => tracePrefix); + _logger.Debug("{0}Current member has not access, redirect to error page", () => tracePrefix); var errorPageId = publicAccessAttempt.Result.NoAccessNodeId; if (errorPageId != request.PublishedContent.Id) - request.PublishedContent = request.UmbracoContext.Facade.ContentCache.GetById(errorPageId); + request.PublishedContent = request.UmbracoContext.PublishedShapshot.ContentCache.GetById(errorPageId); } else { - _logger.Debug("{0}Current member has access", () => tracePrefix); + _logger.Debug("{0}Current member has access", () => tracePrefix); } } else { - _logger.Debug("{0}Page is not protected", () => tracePrefix); + _logger.Debug("{0}Page is not protected", () => tracePrefix); } } @@ -685,16 +674,16 @@ namespace Umbraco.Web.Routing if (templateId > 0) { - _logger.Debug("{0}Look for template id={1}", () => tracePrefix, () => templateId); + _logger.Debug("{0}Look for template id={1}", () => tracePrefix, () => templateId); var template = _services.FileService.GetTemplate(templateId); if (template == null) throw new InvalidOperationException("The template with Id " + templateId + " does not exist, the page cannot render"); request.TemplateModel = template; - _logger.Debug("{0}Got template id={1} alias=\"{2}\"", () => tracePrefix, () => template.Id, () => template.Alias); + _logger.Debug("{0}Got template id={1} alias=\"{2}\"", () => tracePrefix, () => template.Id, () => template.Alias); } else { - _logger.Debug("{0}No specified template.", () => tracePrefix); + _logger.Debug("{0}No specified template.", () => tracePrefix); } } else @@ -706,24 +695,24 @@ namespace Umbraco.Web.Routing // ignore if the alias does not match - just trace if (request.HasTemplate) - _logger.Debug("{0}Has a template already, but also an alternate template.", () => tracePrefix); - _logger.Debug("{0}Look for alternate template alias=\"{1}\"", () => tracePrefix, () => altTemplate); + _logger.Debug("{0}Has a template already, but also an alternate template.", () => tracePrefix); + _logger.Debug("{0}Look for alternate template alias=\"{1}\"", () => tracePrefix, () => altTemplate); var template = _services.FileService.GetTemplate(altTemplate); if (template != null) { request.TemplateModel = template; - _logger.Debug("{0}Got template id={1} alias=\"{2}\"", () => tracePrefix, () => template.Id, () => template.Alias); + _logger.Debug("{0}Got template id={1} alias=\"{2}\"", () => tracePrefix, () => template.Id, () => template.Alias); } else { - _logger.Debug("{0}The template with alias=\"{1}\" does not exist, ignoring.", () => tracePrefix, () => altTemplate); + _logger.Debug("{0}The template with alias=\"{1}\" does not exist, ignoring.", () => tracePrefix, () => altTemplate); } } if (request.HasTemplate == false) { - _logger.Debug("{0}No template was found.", () => tracePrefix); + _logger.Debug("{0}No template was found.", () => tracePrefix); // initial idea was: if we're not already 404 and UmbracoSettings.HandleMissingTemplateAs404 is true // then reset _pcr.Document to null to force a 404. @@ -736,7 +725,7 @@ namespace Umbraco.Web.Routing } else { - _logger.Debug("{0}Running with template id={1} alias=\"{2}\"", () => tracePrefix, () => request.TemplateModel.Id, () => request.TemplateModel.Alias); + _logger.Debug("{0}Running with template id={1} alias=\"{2}\"", () => tracePrefix, () => request.TemplateModel.Id, () => request.TemplateModel.Alias); } } diff --git a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs index 0e6967daf7..089e046ea5 100644 --- a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs +++ b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs @@ -75,7 +75,7 @@ namespace Umbraco.Web.Routing var uri = new Uri(url.TrimEnd('/'), UriKind.RelativeOrAbsolute); if (uri.IsAbsoluteUri == false) uri = uri.MakeAbsolute(UmbracoContext.Current.CleanedUmbracoUrl); uri = UriUtility.UriToUmbraco(uri); - var r = Core.Composing.Current.Container.GetInstance(); // fixme inject or ? + var r = Core.Composing.Current.Container.GetInstance(); // fixme inject or ? var pcr = r.CreateRequest(UmbracoContext.Current, uri); r.TryRouteRequest(pcr); diff --git a/src/Umbraco.Web/Security/MembershipHelper.cs b/src/Umbraco.Web/Security/MembershipHelper.cs index 0413fb4561..8dae7d15e5 100644 --- a/src/Umbraco.Web/Security/MembershipHelper.cs +++ b/src/Umbraco.Web/Security/MembershipHelper.cs @@ -55,7 +55,7 @@ namespace Umbraco.Web.Security private ILogger Logger { get; set; } [Inject] - private FacadeRouter Router { get; set; } + private PublishedRouter Router { get; set; } #region Constructors @@ -94,7 +94,7 @@ namespace Umbraco.Web.Security _umbracoContext = umbracoContext; _membershipProvider = membershipProvider; _roleProvider = roleProvider; - _memberCache = umbracoContext.Facade.MemberCache; + _memberCache = umbracoContext.PublishedShapshot.MemberCache; // helpers are *not* instanciated by the container so we have to // get our dependencies injected manually, through properties. diff --git a/src/Umbraco.Web/Strategies/DatabaseServerRegistrarAndMessengerComponent.cs b/src/Umbraco.Web/Strategies/DatabaseServerRegistrarAndMessengerComponent.cs index 890d300c4a..14f83c44eb 100644 --- a/src/Umbraco.Web/Strategies/DatabaseServerRegistrarAndMessengerComponent.cs +++ b/src/Umbraco.Web/Strategies/DatabaseServerRegistrarAndMessengerComponent.cs @@ -72,11 +72,11 @@ namespace Umbraco.Web.Strategies //rebuild the xml cache file if the server is not synced () => { - // rebuild the facade caches entirely, if the server is not synced - // this is equivalent to DistributedCache RefreshAllFacade but local only - // (we really should have a way to reuse RefreshAllFacade... locally) + // rebuild the published snapshot caches entirely, if the server is not synced + // this is equivalent to DistributedCache RefreshAll... but local only + // (we really should have a way to reuse RefreshAll... locally) // note: refresh all content & media caches does refresh content types too - var svc = Current.FacadeService; + var svc = Current.PublishedSnapshotService; bool ignored1, ignored2; svc.Notify(new[] { new DomainCacheRefresher.JsonPayload(0, DomainChangeTypes.RefreshAll) }); svc.Notify(new[] { new ContentCacheRefresher.JsonPayload(0, TreeChangeTypes.RefreshAll) }, out ignored1, out ignored2); diff --git a/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs index 5be87edd72..de2a66c645 100644 --- a/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs +++ b/src/Umbraco.Web/Strategies/Migrations/ClearMediaXmlCacheForDeletedItemsAfterUpgrade.cs @@ -3,7 +3,6 @@ using Umbraco.Core; using Umbraco.Core.Events; using Umbraco.Core.Logging; using Umbraco.Core.Persistence.Migrations; -using Umbraco.Core.Configuration; namespace Umbraco.Web.Strategies.Migrations { diff --git a/src/Umbraco.Web/Strategies/Migrations/RebuildXmlCachesAfterUpgrade.cs b/src/Umbraco.Web/Strategies/Migrations/RebuildXmlCachesAfterUpgrade.cs index fcc7d1f792..9bbf6b5f1c 100644 --- a/src/Umbraco.Web/Strategies/Migrations/RebuildXmlCachesAfterUpgrade.cs +++ b/src/Umbraco.Web/Strategies/Migrations/RebuildXmlCachesAfterUpgrade.cs @@ -38,7 +38,7 @@ namespace Umbraco.Web.Strategies.Migrations //var mediaService = (MediaService) ApplicationContext.Current.Services.MediaService; //mediaService.RebuildXmlStructures(); - var svc = Current.FacadeService as FacadeService; + var svc = Current.PublishedSnapshotService as PublishedSnapshotService; svc?.RebuildMediaXml(); // note: not re-indexing medias? @@ -50,7 +50,7 @@ namespace Umbraco.Web.Strategies.Migrations //var contentService = (ContentService) ApplicationContext.Current.Services.ContentService; //contentService.RebuildXmlStructures(); - var svc = Current.FacadeService as FacadeService; + var svc = Current.PublishedSnapshotService as PublishedSnapshotService; svc?.RebuildContentAndPreviewXml(); } } diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs index d601203992..afccef92f4 100644 --- a/src/Umbraco.Web/Templates/TemplateRenderer.cs +++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs @@ -41,7 +41,7 @@ namespace Umbraco.Web.Templates } // todo - inject! - private FacadeRouter FacadeRouter => Core.Composing.Current.Container.GetInstance(); + private PublishedRouter PublishedRouter => Core.Composing.Current.Container.GetInstance(); /// @@ -62,7 +62,7 @@ namespace Umbraco.Web.Templates // important to use CleanedUmbracoUrl - lowercase path-only version of the current url, though this isn't going to matter // terribly much for this implementation since we are just creating a doc content request to modify it's properties manually. // fixme - previously that would create an aengine... - var contentRequest = FacadeRouter.CreateRequest(_umbracoContext); + var contentRequest = PublishedRouter.CreateRequest(_umbracoContext); var doc = contentRequest.UmbracoContext.ContentCache.GetById(PageId); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index dca465f8c0..a2b2ee3b2d 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -260,11 +260,11 @@ - + - - - + + + @@ -276,8 +276,8 @@ - - + + @@ -292,10 +292,10 @@ - + - - + + @@ -351,7 +351,7 @@ - + @@ -1020,7 +1020,7 @@ - + diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index 43aed630e9..c86fb60a6c 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -15,7 +15,7 @@ namespace Umbraco.Web /// public class UmbracoContext : DisposableObject, IDisposeOnRequestEnd { - private readonly Lazy _facade; + private readonly Lazy _publishedSnapshot; private string _previewToken; private bool? _previewing; @@ -25,7 +25,7 @@ namespace Umbraco.Web /// Ensures that there is a "current" UmbracoContext. /// /// An http context. - /// A facade service. + /// A published snapshot service. /// A security helper. /// The umbraco settings. /// Some url providers. @@ -48,7 +48,7 @@ namespace Umbraco.Web // UmbracoModule BeginRequest (since it's a request it has an UmbracoContext) // in BeginRequest so *late* ie *after* the HttpApplication has started (+ init? check!) // WebRuntimeComponent (and I'm not quite sure why) - // -> because an UmbracoContext seems to be required by UrlProvider to get the "current" facade? + // -> because an UmbracoContext seems to be required by UrlProvider to get the "current" published snapshot? // note: at startup not sure we have an HttpContext.Current // at startup not sure we have an httpContext.Request => hard to tell "current" url // should we have a post-boot event of some sort for ppl that *need* ?! @@ -58,7 +58,7 @@ namespace Umbraco.Web public static UmbracoContext EnsureContext( IUmbracoContextAccessor umbracoContextAccessor, HttpContextBase httpContext, - IFacadeService facadeService, + IPublishedSnapshotService publishedSnapshotService, WebSecurity webSecurity, IUmbracoSettingsSection umbracoSettings, IEnumerable urlProviders, @@ -66,7 +66,7 @@ namespace Umbraco.Web { if (umbracoContextAccessor == null) throw new ArgumentNullException(nameof(umbracoContextAccessor)); if (httpContext == null) throw new ArgumentNullException(nameof(httpContext)); - if (facadeService == null) throw new ArgumentNullException(nameof(facadeService)); + if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService)); if (webSecurity == null) throw new ArgumentNullException(nameof(webSecurity)); if (umbracoSettings == null) throw new ArgumentNullException(nameof(umbracoSettings)); if (urlProviders == null) throw new ArgumentNullException(nameof(urlProviders)); @@ -78,7 +78,7 @@ namespace Umbraco.Web // create & assign to accessor, dispose existing if any umbracoContextAccessor.UmbracoContext?.Dispose(); - return umbracoContextAccessor.UmbracoContext = new UmbracoContext(httpContext, facadeService, webSecurity, umbracoSettings, urlProviders); + return umbracoContextAccessor.UmbracoContext = new UmbracoContext(httpContext, publishedSnapshotService, webSecurity, umbracoSettings, urlProviders); } // initializes a new instance of the UmbracoContext class @@ -87,13 +87,13 @@ namespace Umbraco.Web // warn: does *not* manage setting any IUmbracoContextAccessor internal UmbracoContext( HttpContextBase httpContext, - IFacadeService facadeService, + IPublishedSnapshotService publishedSnapshotService, WebSecurity webSecurity, IUmbracoSettingsSection umbracoSettings, IEnumerable urlProviders) { if (httpContext == null) throw new ArgumentNullException(nameof(httpContext)); - if (facadeService == null) throw new ArgumentNullException(nameof(facadeService)); + if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService)); if (webSecurity == null) throw new ArgumentNullException(nameof(webSecurity)); if (umbracoSettings == null) throw new ArgumentNullException(nameof(umbracoSettings)); if (urlProviders == null) throw new ArgumentNullException(nameof(urlProviders)); @@ -114,7 +114,7 @@ namespace Umbraco.Web Security = webSecurity; // beware - we cannot expect a current user here, so detecting preview mode must be a lazy thing - _facade = new Lazy(() => facadeService.CreateFacade(PreviewToken)); + _publishedSnapshot = new Lazy(() => publishedSnapshotService.CreatePublishedSnapshot(PreviewToken)); // set the urls... // NOTE: The request will not be available during app startup so we can only set this to an absolute URL of localhost, this @@ -165,22 +165,22 @@ namespace Umbraco.Web internal Uri CleanedUmbracoUrl { get; } /// - /// Gets the facade. + /// Gets the published snapshot. /// - public IFacade Facade => _facade.Value; + public IPublishedShapshot PublishedShapshot => _publishedSnapshot.Value; // for unit tests - internal bool HasFacade => _facade.IsValueCreated; + internal bool HasPublishedSnapshot => _publishedSnapshot.IsValueCreated; /// /// Gets the published content cache. /// - public IPublishedContentCache ContentCache => Facade.ContentCache; + public IPublishedContentCache ContentCache => PublishedShapshot.ContentCache; /// /// Gets the published media cache. /// - public IPublishedMediaCache MediaCache => Facade.MediaCache; + public IPublishedMediaCache MediaCache => PublishedShapshot.MediaCache; /// /// Boolean value indicating whether the current request is a front-end umbraco request @@ -280,12 +280,12 @@ namespace Umbraco.Web } // say we render a macro or RTE in a give 'preview' mode that might not be the 'current' one, - // then due to the way it all works at the moment, the 'current' facade need to be in the proper + // then due to the way it all works at the moment, the 'current' published snapshot need to be in the proper // default 'preview' mode - somehow we have to force it. and that could be recursive. internal IDisposable ForcedPreview(bool preview) { InPreviewMode = preview; - return Facade.ForcedPreview(preview, orig => InPreviewMode = orig); + return PublishedShapshot.ForcedPreview(preview, orig => InPreviewMode = orig); } private HttpRequestBase GetRequestFromContext() @@ -313,8 +313,8 @@ namespace Umbraco.Web // help caches release resources // (but don't create caches just to dispose them) // context is not multi-threaded - if (_facade.IsValueCreated) - _facade.Value.DisposeIfDisposable(); + if (_publishedSnapshot.IsValueCreated) + _publishedSnapshot.Value.DisposeIfDisposable(); } } } diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index d81c7ef32d..ed2553b446 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -40,7 +40,7 @@ namespace Umbraco.Web public IUmbracoContextAccessor UmbracoContextAccessor { get; set; } [Inject] - public IFacadeService FacadeService { get; set; } + public IPublishedSnapshotService PublishedSnapshotService { get; set; } [Inject] public IUserService UserService { get; set; } @@ -55,7 +55,7 @@ namespace Umbraco.Web public ILogger Logger { get; set; } [Inject] - internal FacadeRouter FacadeRouter { get; set; } + internal PublishedRouter PublishedRouter { get; set; } [Inject] internal IUmbracoDatabaseFactory DatabaseFactory { get; set; } @@ -97,7 +97,7 @@ namespace Umbraco.Web UmbracoContext.EnsureContext( UmbracoContextAccessor, httpContext, - FacadeService, + PublishedSnapshotService, new WebSecurity(httpContext, UserService), UmbracoConfig.For.UmbracoSettings(), UrlProviders, @@ -152,9 +152,9 @@ namespace Umbraco.Web // instanciate, prepare and process the published content request // important to use CleanedUmbracoUrl - lowercase path-only version of the current url - var request = FacadeRouter.CreateRequest(umbracoContext); + var request = PublishedRouter.CreateRequest(umbracoContext); umbracoContext.PublishedContentRequest = request; - FacadeRouter.PrepareRequest(request); + PublishedRouter.PrepareRequest(request); // HandleHttpResponseStatus returns a value indicating that the request should // not be processed any further, eg because it has been redirect. then, exit. diff --git a/src/Umbraco.Web/WebApi/Binders/ContentItemBaseBinder.cs b/src/Umbraco.Web/WebApi/Binders/ContentItemBaseBinder.cs index 72c26d2caf..b0b524e66b 100644 --- a/src/Umbraco.Web/WebApi/Binders/ContentItemBaseBinder.cs +++ b/src/Umbraco.Web/WebApi/Binders/ContentItemBaseBinder.cs @@ -109,15 +109,6 @@ namespace Umbraco.Web.WebApi.Binders var httpContext = (HttpContextBase) request.Properties["MS_HttpContext"]; HttpContext.Current = httpContext.ApplicationInstance.Context; - // and then we don't need this anymore - //UmbracoContext.EnsureContext( - // httpContext, ApplicationContext.Current, - // FacadeServiceResolver.Current.Service, - // new WebSecurity(httpContext, ApplicationContext.Current), - // Core.Configuration.UmbracoConfig.For.UmbracoSettings(), - // UrlProviderResolver.Current.Providers, - // false); - var content = request.Content; var result = await content.ReadAsMultipartAsync(provider); diff --git a/src/Umbraco.Web/WebRuntimeComponent.cs b/src/Umbraco.Web/WebRuntimeComponent.cs index 6e205a56ac..b1f6481782 100644 --- a/src/Umbraco.Web/WebRuntimeComponent.cs +++ b/src/Umbraco.Web/WebRuntimeComponent.cs @@ -74,8 +74,8 @@ namespace Umbraco.Web // is per-request so only one wrapper is created per request composition.Container.Register(factory => new HttpContextWrapper(factory.GetInstance().HttpContext), new PerRequestLifeTime()); - // register the facade accessor - the "current" facade is in the umbraco context - composition.Container.RegisterSingleton(); + // register the published snapshot accessor - the "current" published snapshot is in the umbraco context + composition.Container.RegisterSingleton(); // register a per-request UmbracoContext object // no real need to be per request but assuming it is faster @@ -182,8 +182,8 @@ namespace Umbraco.Web // auto-register views composition.Container.RegisterAuto(typeof(UmbracoViewPage<>)); - // register facade router - composition.Container.Register(); + // register published router + composition.Container.Register(); composition.Container.Register(_ => UmbracoConfig.For.UmbracoSettings().WebRouting); // register preview SignalR hub @@ -195,7 +195,7 @@ namespace Umbraco.Web IUmbracoContextAccessor umbracoContextAccessor, SurfaceControllerTypeCollection surfaceControllerTypes, UmbracoApiControllerTypeCollection apiControllerTypes, - IFacadeService facadeService, + IPublishedSnapshotService publishedSnapshotService, IUserService userService, UrlProviderCollection urlProviders) { @@ -244,7 +244,7 @@ namespace Umbraco.Web UmbracoContext.EnsureContext( umbracoContextAccessor, new HttpContextWrapper(HttpContext.Current), - facadeService, + publishedSnapshotService, new WebSecurity(httpContext, userService), UmbracoConfig.For.UmbracoSettings(), urlProviders); diff --git a/src/Umbraco.Web/WebServices/FacadeStatusController.cs b/src/Umbraco.Web/WebServices/FacadeStatusController.cs deleted file mode 100644 index 821a335827..0000000000 --- a/src/Umbraco.Web/WebServices/FacadeStatusController.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Web.Http; -using Umbraco.Core; -using Umbraco.Core.Logging; -using Umbraco.Core.Services; -using Umbraco.Web.PublishedCache; -using Umbraco.Web.WebApi; - -namespace Umbraco.Web.WebServices -{ - public class FacadeStatusController : UmbracoAuthorizedApiController - { - private readonly IFacadeService _facadeService; - - public FacadeStatusController(IFacadeService facadeService) - { - if (facadeService == null) throw new ArgumentNullException(nameof(facadeService)); - _facadeService = facadeService; - } - - [HttpGet] - public string GetFacadeStatusUrl() - { - if (_facadeService is Umbraco.Web.PublishedCache.XmlPublishedCache.FacadeService) - return "views/dashboard/developer/xmldataintegrityreport.html"; - //if (service is PublishedCache.PublishedNoCache.FacadeService) - // return "views/dashboard/developer/nocache.html"; - if (_facadeService is PublishedCache.NuCache.FacadeService) - return "views/dashboard/developer/nucache.html"; - throw new NotSupportedException("Not supported: " + _facadeService.GetType().FullName); - } - } -} diff --git a/src/Umbraco.Web/WebServices/NuCacheStatusController.cs b/src/Umbraco.Web/WebServices/NuCacheStatusController.cs index c4d626569e..d1c9c0451e 100644 --- a/src/Umbraco.Web/WebServices/NuCacheStatusController.cs +++ b/src/Umbraco.Web/WebServices/NuCacheStatusController.cs @@ -10,19 +10,19 @@ namespace Umbraco.Web.WebServices { public class NuCacheStatusController : UmbracoAuthorizedApiController { - private readonly IFacadeService _facadeService; + private readonly IPublishedSnapshotService _publishedSnapshotService; - public NuCacheStatusController(IFacadeService facadeService) + public NuCacheStatusController(IPublishedSnapshotService publishedSnapshotService) { - if (facadeService == null) throw new ArgumentNullException(nameof(facadeService)); - _facadeService = facadeService; + if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService)); + _publishedSnapshotService = publishedSnapshotService; } - private FacadeService FacadeService + private PublishedSnapshotService PublishedSnapshotService { get { - var svc = _facadeService as FacadeService; + var svc = _publishedSnapshotService as PublishedSnapshotService; if (svc == null) throw new NotSupportedException("Not running NuCache."); return svc; @@ -33,7 +33,7 @@ namespace Umbraco.Web.WebServices public string RebuildDbCache() { // fixme - should wrap in a service scope once we have them - var service = FacadeService; + var service = PublishedSnapshotService; service.RebuildContentDbCache(); service.RebuildMediaDbCache(); service.RebuildMemberDbCache(); @@ -43,14 +43,14 @@ namespace Umbraco.Web.WebServices [HttpGet] public string GetStatus() { - var service = FacadeService; + var service = PublishedSnapshotService; return service.GetStatus(); } [HttpGet] public string Collect() { - var service = FacadeService; + var service = PublishedSnapshotService; GC.Collect(); service.Collect(); return service.GetStatus(); @@ -59,7 +59,7 @@ namespace Umbraco.Web.WebServices [HttpPost] public void ReloadCache() { - Current.DistributedCache.RefreshAllFacade(); + Current.DistributedCache.RefreshAllPublishedSnapshot(); } } } diff --git a/src/Umbraco.Web/WebServices/PublishedStatusController.cs b/src/Umbraco.Web/WebServices/PublishedStatusController.cs new file mode 100644 index 0000000000..d5846cce10 --- /dev/null +++ b/src/Umbraco.Web/WebServices/PublishedStatusController.cs @@ -0,0 +1,32 @@ +using System; +using System.Web.Http; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.WebApi; + +namespace Umbraco.Web.WebServices +{ + public class PublishedStatusController : UmbracoAuthorizedApiController + { + private readonly IPublishedSnapshotService _publishedSnapshotService; + + public PublishedStatusController(IPublishedSnapshotService publishedSnapshotService) + { + _publishedSnapshotService = publishedSnapshotService ?? throw new ArgumentNullException(nameof(publishedSnapshotService)); + } + + [HttpGet] + public string GetPublishedStatusUrl() + { + if (_publishedSnapshotService is PublishedCache.XmlPublishedCache.PublishedSnapshotService) + return "views/dashboard/developer/xmldataintegrityreport.html"; + + //if (service is PublishedCache.PublishedNoCache.PublishedSnapshotService) + // return "views/dashboard/developer/nocache.html"; + + if (_publishedSnapshotService is PublishedCache.NuCache.PublishedSnapshotService) + return "views/dashboard/developer/nucache.html"; + + throw new NotSupportedException("Not supported: " + _publishedSnapshotService.GetType().FullName); + } + } +} diff --git a/src/Umbraco.Web/WebServices/XmlDataIntegrityController.cs b/src/Umbraco.Web/WebServices/XmlDataIntegrityController.cs index 56f1e27d34..5c16c83e57 100644 --- a/src/Umbraco.Web/WebServices/XmlDataIntegrityController.cs +++ b/src/Umbraco.Web/WebServices/XmlDataIntegrityController.cs @@ -10,52 +10,52 @@ namespace Umbraco.Web.WebServices [ValidateAngularAntiForgeryToken] public class XmlDataIntegrityController : UmbracoAuthorizedApiController { - private readonly FacadeService _facadeService; + private readonly PublishedSnapshotService _publishedSnapshotService; - public XmlDataIntegrityController(IFacadeService facadeService) + public XmlDataIntegrityController(IPublishedSnapshotService publishedSnapshotService) { - if (facadeService == null) throw new ArgumentNullException(nameof(facadeService)); - _facadeService = facadeService as FacadeService; - if (_facadeService == null) throw new NotSupportedException("Unsupported IFacadeService, only the Xml one is supported."); + if (publishedSnapshotService == null) throw new ArgumentNullException(nameof(publishedSnapshotService)); + _publishedSnapshotService = publishedSnapshotService as PublishedSnapshotService; + if (_publishedSnapshotService == null) throw new NotSupportedException("Unsupported IPublishedSnapshotService, only the Xml one is supported."); } [HttpPost] public bool FixContentXmlTable() { - _facadeService.RebuildContentAndPreviewXml(); - return _facadeService.VerifyContentAndPreviewXml(); + _publishedSnapshotService.RebuildContentAndPreviewXml(); + return _publishedSnapshotService.VerifyContentAndPreviewXml(); } [HttpPost] public bool FixMediaXmlTable() { - _facadeService.RebuildMediaXml(); - return _facadeService.VerifyMediaXml(); + _publishedSnapshotService.RebuildMediaXml(); + return _publishedSnapshotService.VerifyMediaXml(); } [HttpPost] public bool FixMembersXmlTable() { - _facadeService.RebuildMemberXml(); - return _facadeService.VerifyMemberXml(); + _publishedSnapshotService.RebuildMemberXml(); + return _publishedSnapshotService.VerifyMemberXml(); } [HttpGet] public bool CheckContentXmlTable() { - return _facadeService.VerifyContentAndPreviewXml(); + return _publishedSnapshotService.VerifyContentAndPreviewXml(); } [HttpGet] public bool CheckMediaXmlTable() { - return _facadeService.VerifyMediaXml(); + return _publishedSnapshotService.VerifyMediaXml(); } [HttpGet] public bool CheckMembersXmlTable() { - return _facadeService.VerifyMemberXml(); + return _publishedSnapshotService.VerifyMemberXml(); } } } diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs index 8db1e5e246..071c4cab10 100644 --- a/src/Umbraco.Web/umbraco.presentation/library.cs +++ b/src/Umbraco.Web/umbraco.presentation/library.cs @@ -1132,7 +1132,7 @@ namespace umbraco } // legacy would access the raw XML from content.Instance ie a static thing - // now that we use a FacadeService, we need to have a "context" to handle a cache. + // now that we use a PublishedSnapshotService, we need to have a "context" to handle a cache. // UmbracoContext does it for most cases but in some cases we might not have an // UmbracoContext. For backward compatibility, try to do something here... internal static PublishedContentCache GetSafeContentCache() @@ -1145,9 +1145,9 @@ namespace umbraco } else { - var facade = Current.Facade - ?? Current.FacadeService.CreateFacade(null); - contentCache = facade.ContentCache as PublishedContentCache; + var publishedSnapshot = Current.PublishedSnapshot + ?? Current.PublishedSnapshotService.CreatePublishedSnapshot(null); + contentCache = publishedSnapshot.ContentCache as PublishedContentCache; } if (contentCache == null) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs index 77b0a15da1..984d22cb88 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/installer.aspx.cs @@ -219,9 +219,9 @@ namespace umbraco.presentation.developer.packages //making sure that publishing actions performed from the cms layer gets pushed to the presentation - // library.RefreshContent is obsolete, would need to RefreshAllFacade, + // library.RefreshContent is obsolete, would need to RefreshAll..., // but it should be managed automatically by services and caches! - //DistributedCache.Instance.RefreshAllFacade(); + //DistributedCache.Instance.RefreshAll...(); if (string.IsNullOrEmpty(_installer.Control) == false) { diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs index 692eb581e3..7f528b2a7b 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/Preview.aspx.cs @@ -18,8 +18,8 @@ namespace umbraco.presentation.dialogs var user = UmbracoContext.Security.CurrentUser; var contentId = Request.GetItemAs("id"); - var facadeService = Current.FacadeService; - var previewToken = facadeService.EnterPreview(user, contentId); + var publishedSnapshotService = Current.PublishedSnapshotService; + var previewToken = publishedSnapshotService.EnterPreview(user, contentId); UmbracoContext.HttpContext.Response.Cookies.Set(new HttpCookie(Constants.Web.PreviewCookieName, previewToken)); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/endPreview.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/endPreview.aspx.cs index b341a42cdd..822f346705 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/endPreview.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/endPreview.aspx.cs @@ -15,7 +15,7 @@ namespace umbraco.presentation var request = (new HttpRequestWrapper(Request)); var previewToken = request.GetPreviewCookieValue(); - var service = Current.FacadeService; + var service = Current.PublishedSnapshotService; service.ExitPreview(previewToken); HttpContext.Current.ExpireCookie(Constants.Web.PreviewCookieName);