From 829d995154433d4f91a540bf1fd830978343229f Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 31 Oct 2017 12:50:30 +0100 Subject: [PATCH] Simplicity --- src/Umbraco.Compat7/Web/Models/RenderModel.cs | 2 +- .../ContentLastChangeFinderResolver.cs | 2 +- .../Published/ConvertersTests.cs | 8 +- .../Published/NestedContentTests.cs | 2 +- .../PublishedContentTestElements.cs | 8 +- ...EngineTests.cs => PublishedRouterTests.cs} | 2 +- src/Umbraco.Tests/Routing/RoutesCacheTests.cs | 2 +- .../TestControllerActivatorBase.cs | 2 +- .../TestHelpers/Stubs/TestLastChanceFinder.cs | 2 +- .../TestHelpers/TestObjects-Mocks.cs | 2 +- src/Umbraco.Tests/Umbraco.Tests.csproj | 2 +- .../Web/Mvc/SurfaceControllerTests.cs | 4 +- .../Web/Mvc/UmbracoViewPageTests.cs | 2 +- src/Umbraco.Web/HtmlHelperRenderExtensions.cs | 4 +- src/Umbraco.Web/Macros/MacroRenderer.cs | 6 +- src/Umbraco.Web/Models/ContentExtensions.cs | 2 +- .../EnsurePublishedContentRequestAttribute.cs | 8 +- src/Umbraco.Web/Mvc/RenderMvcController.cs | 16 +- src/Umbraco.Web/Mvc/RenderRouteHandler.cs | 12 +- src/Umbraco.Web/Mvc/RouteDefinition.cs | 2 +- src/Umbraco.Web/Mvc/SurfaceController.cs | 2 +- src/Umbraco.Web/Mvc/UmbracoPageResult.cs | 2 +- .../Mvc/UmbracoViewPageOfTModel.cs | 8 +- .../Mvc/UmbracoVirtualNodeRouteHandler.cs | 12 +- .../ContentPickerValueConverter.cs | 4 +- .../MediaPickerValueConverter.cs | 2 +- .../MemberPickerValueConverter.cs | 4 +- .../MultiNodeTreePickerValueConverter.cs | 12 +- .../NestedContentValueConverterBase.cs | 2 +- .../RelatedLinksValueConverter.cs | 2 +- .../PublishedCache/IPublishedShapshot.cs | 8 +- .../NuCache/PublishedContent.cs | 4 +- .../NuCache/PublishedShapshot.cs | 8 +- .../XmlPublishedCache/PublishedShapshot.cs | 16 +- .../XmlPublishedCache/XmlStore.cs | 4 +- src/Umbraco.Web/Routing/AliasUrlProvider.cs | 2 +- .../Routing/ContentFinderByIdPath.cs | 2 +- .../Routing/ContentFinderByLegacy404.cs | 4 +- .../Routing/ContentFinderByNiceUrl.cs | 4 +- .../ContentFinderByNiceUrlAndTemplate.cs | 2 +- .../Routing/ContentFinderByPageIdQuery.cs | 2 +- .../Routing/ContentFinderByProfile.cs | 2 +- .../Routing/ContentFinderByRedirectUrl.cs | 2 +- .../Routing/ContentFinderByUrlAlias.cs | 2 +- .../Routing/CustomRouteUrlProvider.cs | 8 +- src/Umbraco.Web/Routing/DefaultUrlProvider.cs | 4 +- src/Umbraco.Web/Routing/IContentFinder.cs | 2 +- .../PublishedContentNotFoundHandler.cs | 2 +- ...dContentRequest.cs => PublishedRequest.cs} | 1036 ++++++++--------- src/Umbraco.Web/Routing/PublishedRouter.cs | 40 +- src/Umbraco.Web/Security/MembershipHelper.cs | 4 +- src/Umbraco.Web/Templates/TemplateRenderer.cs | 30 +- src/Umbraco.Web/Umbraco.Web.csproj | 2 +- src/Umbraco.Web/UmbracoComponentRenderer.cs | 8 +- src/Umbraco.Web/UmbracoContext.cs | 8 +- src/Umbraco.Web/UmbracoHelper.cs | 2 +- src/Umbraco.Web/UmbracoModule.cs | 6 +- .../umbraco.presentation/default.aspx.cs | 4 +- .../umbraco.presentation/library.cs | 2 +- src/Umbraco.Web/umbraco.presentation/page.cs | 4 +- 60 files changed, 681 insertions(+), 683 deletions(-) rename src/Umbraco.Tests/PublishedContent/{PublishedContentRequestEngineTests.cs => PublishedRouterTests.cs} (98%) rename src/Umbraco.Web/Routing/{PublishedContentRequest.cs => PublishedRequest.cs} (96%) diff --git a/src/Umbraco.Compat7/Web/Models/RenderModel.cs b/src/Umbraco.Compat7/Web/Models/RenderModel.cs index bc0a58cab9..c843d48388 100644 --- a/src/Umbraco.Compat7/Web/Models/RenderModel.cs +++ b/src/Umbraco.Compat7/Web/Models/RenderModel.cs @@ -23,7 +23,7 @@ namespace Umbraco.Web.Models throw new InvalidOperationException("Cannot construct a RenderModel without specifying a CultureInfo when no UmbracoContext has been initialized"); } Content = content; - CurrentCulture = UmbracoContext.Current.PublishedContentRequest.Culture; + CurrentCulture = UmbracoContext.Current.PublishedRequest.Culture; } /// diff --git a/src/Umbraco.Compat7/Web/Routing/ContentLastChangeFinderResolver.cs b/src/Umbraco.Compat7/Web/Routing/ContentLastChangeFinderResolver.cs index cb13a1b11e..bb46f79bf4 100644 --- a/src/Umbraco.Compat7/Web/Routing/ContentLastChangeFinderResolver.cs +++ b/src/Umbraco.Compat7/Web/Routing/ContentLastChangeFinderResolver.cs @@ -31,7 +31,7 @@ namespace Umbraco.Web.Routing _inner = inner; } - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { return _inner.TryFindContent(frequest); } diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs index 1b63af6850..4ca9cea82f 100644 --- a/src/Umbraco.Tests/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests/Published/ConvertersTests.cs @@ -69,7 +69,7 @@ namespace Umbraco.Tests.Published var cacheContent = new Dictionary(); cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null); var publishedSnapshotMock = new Mock(); - publishedSnapshotMock.Setup(x => x.ContentCache).Returns(cacheMock.Object); + publishedSnapshotMock.Setup(x => x.Content).Returns(cacheMock.Object); var publishedSnapshotAccessorMock = new Mock(); publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshotMock.Object); var publishedSnapshotAccessor = publishedSnapshotAccessorMock.Object; @@ -122,7 +122,7 @@ namespace Umbraco.Tests.Published => int.TryParse(source as string, out int i) ? i : -1; public object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) - => _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById((int) inter); + => _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById((int) inter); public object ConvertInterToXPath(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) => ((int) inter).ToString(); @@ -154,7 +154,7 @@ namespace Umbraco.Tests.Published var cacheContent = new Dictionary(); cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null); var publishedSnapshotMock = new Mock(); - publishedSnapshotMock.Setup(x => x.ContentCache).Returns(cacheMock.Object); + publishedSnapshotMock.Setup(x => x.Content).Returns(cacheMock.Object); var publishedSnapshotAccessorMock = new Mock(); publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshotMock.Object); Current.Container.Register(f => publishedSnapshotAccessorMock.Object); @@ -257,7 +257,7 @@ namespace Umbraco.Tests.Published public override object ConvertInterToObject(IPublishedElement owner, PublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) { - return ((int[]) inter).Select(x => (PublishedSnapshotTestObjects.TestContentModel1) _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(x)).ToArray(); + return ((int[]) inter).Select(x => (PublishedSnapshotTestObjects.TestContentModel1) _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(x)).ToArray(); } } diff --git a/src/Umbraco.Tests/Published/NestedContentTests.cs b/src/Umbraco.Tests/Published/NestedContentTests.cs index 9de718bc35..35b8ba9895 100644 --- a/src/Umbraco.Tests/Published/NestedContentTests.cs +++ b/src/Umbraco.Tests/Published/NestedContentTests.cs @@ -91,7 +91,7 @@ namespace Umbraco.Tests.Published // mocked published snapshot returns a content cache publishedSnapshot - .Setup(x => x.ContentCache) + .Setup(x => x.Content) .Returns(contentCache.Object); var publishedSnapshotAccessor = new Mock(); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs index 53b26b73bc..b707467449 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestElements.cs @@ -16,13 +16,13 @@ namespace Umbraco.Tests.PublishedContent public readonly SolidPublishedContentCache InnerContentCache = new SolidPublishedContentCache(); public readonly SolidPublishedContentCache InnerMediaCache = new SolidPublishedContentCache(); - public IPublishedContentCache ContentCache => InnerContentCache; + public IPublishedContentCache Content => InnerContentCache; - public IPublishedMediaCache MediaCache => InnerMediaCache; + public IPublishedMediaCache Media => InnerMediaCache; - public IPublishedMemberCache MemberCache => null; + public IPublishedMemberCache Members => null; - public IDomainCache DomainCache => null; + public IDomainCache Domains => null; public IDisposable ForcedPreview(bool forcedPreview, Action callback = null) { diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs similarity index 98% rename from src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs rename to src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs index 3defbff700..6fc8cbce35 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentRequestEngineTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs @@ -10,7 +10,7 @@ using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.PublishedContent { [TestFixture] - public class PublishedContentRequestEngineTests : BaseWebTest + public class PublishedRouterTests : BaseWebTest { [Test] public void ConfigureRequest_Returns_False_Without_HasPublishedContent() diff --git a/src/Umbraco.Tests/Routing/RoutesCacheTests.cs b/src/Umbraco.Tests/Routing/RoutesCacheTests.cs index e12d8523a6..4b04ebb50d 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.PublishedShapshot.ContentCache as PublishedContentCache; + var cache = umbracoContext.PublishedShapshot.Content 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/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs index 8f14b221ed..646aa048c9 100644 --- a/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs +++ b/src/Umbraco.Tests/TestHelpers/ControllerTesting/TestControllerActivatorBase.cs @@ -123,7 +123,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting .Returns(() => true); var publishedSnapshot = new Mock(); - publishedSnapshot.Setup(x => x.MemberCache).Returns(Mock.Of()); + publishedSnapshot.Setup(x => x.Members).Returns(Mock.Of()); var publishedSnapshotService = new Mock(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot.Object); diff --git a/src/Umbraco.Tests/TestHelpers/Stubs/TestLastChanceFinder.cs b/src/Umbraco.Tests/TestHelpers/Stubs/TestLastChanceFinder.cs index 56821f7884..6a43f6180d 100644 --- a/src/Umbraco.Tests/TestHelpers/Stubs/TestLastChanceFinder.cs +++ b/src/Umbraco.Tests/TestHelpers/Stubs/TestLastChanceFinder.cs @@ -4,7 +4,7 @@ namespace Umbraco.Tests.TestHelpers.Stubs { internal class TestLastChanceFinder : IContentLastChanceFinder { - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { return false; } diff --git a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs index aac30c2662..e5261dfdfc 100644 --- a/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs +++ b/src/Umbraco.Tests/TestHelpers/TestObjects-Mocks.cs @@ -112,7 +112,7 @@ namespace Umbraco.Tests.TestHelpers var httpContext = Mock.Of(); var publishedSnapshotMock = new Mock(); - publishedSnapshotMock.Setup(x => x.MemberCache).Returns(Mock.Of()); + publishedSnapshotMock.Setup(x => x.Members).Returns(Mock.Of()); var publishedSnapshot = publishedSnapshotMock.Object; var publishedSnapshotServiceMock = new Mock(); publishedSnapshotServiceMock.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 1d7eb5aa43..98159d6a25 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -419,7 +419,7 @@ - + diff --git a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs index 40ae110295..ea33f5d81e 100644 --- a/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/SurfaceControllerTests.cs @@ -92,7 +92,7 @@ namespace Umbraco.Tests.Web.Mvc public void Can_Lookup_Content() { var publishedSnapshot = new Mock(); - publishedSnapshot.Setup(x => x.MemberCache).Returns(Mock.Of()); + publishedSnapshot.Setup(x => x.Members).Returns(Mock.Of()); var publishedSnapshotService = new Mock(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(publishedSnapshot.Object); @@ -149,7 +149,7 @@ namespace Umbraco.Tests.Web.Mvc var routeDefinition = new RouteDefinition { - PublishedContentRequest = frequest + PublishedRequest = frequest }; var routeData = new RouteData(); diff --git a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs index 4d27bacb6a..8a60a0c8fd 100644 --- a/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs +++ b/src/Umbraco.Tests/Web/Mvc/UmbracoViewPageTests.cs @@ -399,7 +399,7 @@ namespace Umbraco.Tests.Web.Mvc var frequest = publishedRouter.CreateRequest(umbracoContext, new Uri("http://localhost/dang")); frequest.Culture = CultureInfo.InvariantCulture; - umbracoContext.PublishedContentRequest = frequest; + umbracoContext.PublishedRequest = frequest; var context = new ViewContext(); context.RouteData = new RouteData(); diff --git a/src/Umbraco.Web/HtmlHelperRenderExtensions.cs b/src/Umbraco.Web/HtmlHelperRenderExtensions.cs index 938bc0bb27..dd34dea6b5 100644 --- a/src/Umbraco.Web/HtmlHelperRenderExtensions.cs +++ b/src/Umbraco.Web/HtmlHelperRenderExtensions.cs @@ -919,8 +919,8 @@ namespace Umbraco.Web string noPreviewLinks = @""; // Get page value - int pageId = umbCtx.PublishedContentRequest.UmbracoPage.PageID; - string[] path = umbCtx.PublishedContentRequest.UmbracoPage.SplitPath; + int pageId = umbCtx.PublishedRequest.UmbracoPage.PageID; + string[] path = umbCtx.PublishedRequest.UmbracoPage.SplitPath; string result = string.Empty; string cssPath = CanvasDesignerUtility.GetStylesheetPath(path, false); diff --git a/src/Umbraco.Web/Macros/MacroRenderer.cs b/src/Umbraco.Web/Macros/MacroRenderer.cs index 7d60777b86..5b7c14ac05 100644 --- a/src/Umbraco.Web/Macros/MacroRenderer.cs +++ b/src/Umbraco.Web/Macros/MacroRenderer.cs @@ -367,8 +367,8 @@ namespace Umbraco.Web.Macros // ensure that we are running against a published node (ie available in XML) // that may not be the case if the macro is embedded in a RTE of an unpublished document - if (UmbracoContext.Current.PublishedContentRequest == null - || UmbracoContext.Current.PublishedContentRequest.HasPublishedContent == false) + if (UmbracoContext.Current.PublishedRequest == null + || UmbracoContext.Current.PublishedRequest.HasPublishedContent == false) return Attempt.Fail(new MacroContent { Text = "[macro]" }); var textService = Current.Services.TextService; @@ -443,7 +443,7 @@ namespace Umbraco.Web.Macros private static MacroContent ExecutePartialView(MacroModel macro) { var engine = new PartialViewMacroEngine(); - var content = UmbracoContext.Current.PublishedContentRequest.PublishedContent; + var content = UmbracoContext.Current.PublishedRequest.PublishedContent; return engine.Execute(macro, content); } diff --git a/src/Umbraco.Web/Models/ContentExtensions.cs b/src/Umbraco.Web/Models/ContentExtensions.cs index 0fc61875a3..4a016a895b 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.PublishedShapshot.DomainCache; // default + : umbracoContext.PublishedShapshot.Domains; // 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 7f5b9e4b10..92625afdde 100644 --- a/src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs +++ b/src/Umbraco.Web/Mvc/EnsurePublishedContentRequestAttribute.cs @@ -87,13 +87,13 @@ namespace Umbraco.Web.Mvc base.OnActionExecuted(filterContext); //First we need to check if the pcr has been set, if it has we're going to ignore this and not actually do anything - if (UmbracoContext.Current.PublishedContentRequest != null) + if (UmbracoContext.Current.PublishedRequest != null) { return; } - UmbracoContext.Current.PublishedContentRequest = PublishedRouter.CreateRequest(UmbracoContext.Current); - ConfigurePublishedContentRequest(UmbracoContext.Current.PublishedContentRequest, filterContext); + UmbracoContext.Current.PublishedRequest = PublishedRouter.CreateRequest(UmbracoContext.Current); + ConfigurePublishedContentRequest(UmbracoContext.Current.PublishedRequest, filterContext); } /// @@ -102,7 +102,7 @@ namespace Umbraco.Web.Mvc /// /// /// - protected virtual void ConfigurePublishedContentRequest(PublishedContentRequest request, ActionExecutedContext filterContext) + protected virtual void ConfigurePublishedContentRequest(PublishedRequest request, ActionExecutedContext filterContext) { if (_contentId.HasValue) { diff --git a/src/Umbraco.Web/Mvc/RenderMvcController.cs b/src/Umbraco.Web/Mvc/RenderMvcController.cs index 888b9534d2..e7f336dcde 100644 --- a/src/Umbraco.Web/Mvc/RenderMvcController.cs +++ b/src/Umbraco.Web/Mvc/RenderMvcController.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.Mvc [PreRenderViewActionFilter] public class RenderMvcController : UmbracoController, IRenderMvcController { - private PublishedContentRequest _publishedContentRequest; + private PublishedRequest _publishedRequest; public RenderMvcController() { @@ -26,28 +26,28 @@ namespace Umbraco.Web.Mvc /// /// Gets the Umbraco context. /// - public override UmbracoContext UmbracoContext => PublishedContentRequest.UmbracoContext; + public override UmbracoContext UmbracoContext => PublishedRequest.UmbracoContext; /// /// Gets the current content item. /// - protected IPublishedContent CurrentPage => PublishedContentRequest.PublishedContent; + protected IPublishedContent CurrentPage => PublishedRequest.PublishedContent; /// /// Gets the current published content request. /// - protected internal virtual PublishedContentRequest PublishedContentRequest + protected internal virtual PublishedRequest PublishedRequest { get { - if (_publishedContentRequest != null) - return _publishedContentRequest; + if (_publishedRequest != null) + return _publishedRequest; if (RouteData.DataTokens.ContainsKey(Core.Constants.Web.PublishedDocumentRequestDataToken) == false) { throw new InvalidOperationException("DataTokens must contain an 'umbraco-doc-request' key with a PublishedContentRequest object"); } - _publishedContentRequest = (PublishedContentRequest)RouteData.DataTokens[Core.Constants.Web.PublishedDocumentRequestDataToken]; - return _publishedContentRequest; + _publishedRequest = (PublishedRequest)RouteData.DataTokens[Core.Constants.Web.PublishedDocumentRequestDataToken]; + return _publishedRequest; } } diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs index 11a0ac00d0..b9446d3aa7 100644 --- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs @@ -67,7 +67,7 @@ namespace Umbraco.Web.Mvc { throw new NullReferenceException("There is not current UmbracoContext, it must be initialized before the RenderRouteHandler executes"); } - var request = UmbracoContext.PublishedContentRequest; + var request = UmbracoContext.PublishedRequest; if (request == null) { throw new NullReferenceException("There is not current PublishedContentRequest, it must be initialized before the RenderRouteHandler executes"); @@ -90,7 +90,7 @@ namespace Umbraco.Web.Mvc /// /// /// - internal void SetupRouteDataForRequest(ContentModel contentModel, RequestContext requestContext, PublishedContentRequest frequest) + internal void SetupRouteDataForRequest(ContentModel contentModel, RequestContext requestContext, PublishedRequest frequest) { //put essential data into the data tokens, the 'umbraco' key is required to be there for the view engine requestContext.RouteData.DataTokens.Add(Core.Constants.Web.UmbracoDataToken, contentModel); //required for the RenderModelBinder and view engine @@ -272,7 +272,7 @@ namespace Umbraco.Web.Mvc /// /// /// - internal virtual RouteDefinition GetUmbracoRouteDefinition(RequestContext requestContext, PublishedContentRequest request) + internal virtual RouteDefinition GetUmbracoRouteDefinition(RequestContext requestContext, PublishedRequest request) { if (requestContext == null) throw new ArgumentNullException(nameof(requestContext)); if (request == null) throw new ArgumentNullException(nameof(request)); @@ -284,7 +284,7 @@ namespace Umbraco.Web.Mvc { ControllerName = defaultControllerName, ControllerType = defaultControllerType, - PublishedContentRequest = request, + PublishedRequest = request, ActionName = ((Route)requestContext.RouteData.Route).Defaults["action"].ToString(), HasHijackedRoute = false }; @@ -338,7 +338,7 @@ namespace Umbraco.Web.Mvc return def; } - internal IHttpHandler GetHandlerOnMissingTemplate(PublishedContentRequest request) + internal IHttpHandler GetHandlerOnMissingTemplate(PublishedRequest request) { if (request == null) throw new ArgumentNullException(nameof(request)); @@ -370,7 +370,7 @@ namespace Umbraco.Web.Mvc /// /// /// - internal IHttpHandler GetHandlerForRoute(RequestContext requestContext, PublishedContentRequest request) + internal IHttpHandler GetHandlerForRoute(RequestContext requestContext, PublishedRequest request) { if (requestContext == null) throw new ArgumentNullException(nameof(requestContext)); if (request == null) throw new ArgumentNullException(nameof(request)); diff --git a/src/Umbraco.Web/Mvc/RouteDefinition.cs b/src/Umbraco.Web/Mvc/RouteDefinition.cs index 7a9a37cfe5..6d0a5e102b 100644 --- a/src/Umbraco.Web/Mvc/RouteDefinition.cs +++ b/src/Umbraco.Web/Mvc/RouteDefinition.cs @@ -21,7 +21,7 @@ namespace Umbraco.Web.Mvc /// /// The current RenderModel found for the request /// - public PublishedContentRequest PublishedContentRequest { get; set; } + public PublishedRequest PublishedRequest { get; set; } /// /// Gets/sets whether the current request has a hijacked route/user controller routed for it diff --git a/src/Umbraco.Web/Mvc/SurfaceController.cs b/src/Umbraco.Web/Mvc/SurfaceController.cs index c7a06f06e8..043841f279 100644 --- a/src/Umbraco.Web/Mvc/SurfaceController.cs +++ b/src/Umbraco.Web/Mvc/SurfaceController.cs @@ -140,7 +140,7 @@ namespace Umbraco.Web.Mvc throw routeDefAttempt.Exception; var routeDef = routeDefAttempt.Result; - return routeDef.PublishedContentRequest.PublishedContent; + return routeDef.PublishedRequest.PublishedContent; } } diff --git a/src/Umbraco.Web/Mvc/UmbracoPageResult.cs b/src/Umbraco.Web/Mvc/UmbracoPageResult.cs index 05d4b83e58..98bd66e48e 100644 --- a/src/Umbraco.Web/Mvc/UmbracoPageResult.cs +++ b/src/Umbraco.Web/Mvc/UmbracoPageResult.cs @@ -39,7 +39,7 @@ namespace Umbraco.Web.Mvc //Special case, if it is webforms but we're posting to an MVC surface controller, then we // need to return the webforms result instead - if (routeDef.PublishedContentRequest.RenderingEngine == RenderingEngine.WebForms) + if (routeDef.PublishedRequest.RenderingEngine == RenderingEngine.WebForms) { EnsureViewContextForWebForms(context); var webFormsHandler = RenderRouteHandler.GetWebFormsHandler(); diff --git a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs b/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs index 7532ef7732..6857c0ce46 100644 --- a/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs +++ b/src/Umbraco.Web/Mvc/UmbracoViewPageOfTModel.cs @@ -62,7 +62,7 @@ namespace Umbraco.Web.Mvc /// /// Gets the public content request. /// - internal PublishedContentRequest PublishedContentRequest + internal PublishedRequest PublishedRequest { get { @@ -73,14 +73,14 @@ namespace Umbraco.Web.Mvc // try view context if (ViewContext.RouteData.DataTokens.ContainsKey(token)) - return (PublishedContentRequest) ViewContext.RouteData.DataTokens.GetRequiredObject(token); + return (PublishedRequest) ViewContext.RouteData.DataTokens.GetRequiredObject(token); // child action, try parent view context if (ViewContext.IsChildAction && ViewContext.ParentActionViewContext.RouteData.DataTokens.ContainsKey(token)) - return (PublishedContentRequest) ViewContext.ParentActionViewContext.RouteData.DataTokens.GetRequiredObject(token); + return (PublishedRequest) ViewContext.ParentActionViewContext.RouteData.DataTokens.GetRequiredObject(token); // fallback to UmbracoContext - return UmbracoContext.PublishedContentRequest; + return UmbracoContext.PublishedRequest; } } diff --git a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs index 304de52212..ab474fa699 100644 --- a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeRouteHandler.cs @@ -51,17 +51,17 @@ namespace Umbraco.Web.Mvc var request = PublishedRouter.CreateRequest(umbracoContext); request.PublishedContent = found; - umbracoContext.PublishedContentRequest = request; + umbracoContext.PublishedRequest = request; //allows inheritors to change the pcr - PreparePublishedContentRequest(umbracoContext.PublishedContentRequest); + PreparePublishedContentRequest(umbracoContext.PublishedRequest); //create the render model - var renderModel = new ContentModel(umbracoContext.PublishedContentRequest.PublishedContent); + var renderModel = new ContentModel(umbracoContext.PublishedRequest.PublishedContent); //assigns the required tokens to the request requestContext.RouteData.DataTokens.Add(Core.Constants.Web.UmbracoDataToken, renderModel); - requestContext.RouteData.DataTokens.Add(Core.Constants.Web.PublishedDocumentRequestDataToken, umbracoContext.PublishedContentRequest); + requestContext.RouteData.DataTokens.Add(Core.Constants.Web.PublishedDocumentRequestDataToken, umbracoContext.PublishedRequest); requestContext.RouteData.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbracoContext); //this is used just for a flag that this is an umbraco custom route requestContext.RouteData.DataTokens.Add(Core.Constants.Web.CustomRouteDataToken, true); @@ -74,7 +74,7 @@ namespace Umbraco.Web.Mvc { ActionName = requestContext.RouteData.GetRequiredString("action"), ControllerName = requestContext.RouteData.GetRequiredString("controller"), - PublishedContentRequest = umbracoContext.PublishedContentRequest + PublishedRequest = umbracoContext.PublishedRequest }; //set the special data token to the current route definition @@ -88,7 +88,7 @@ namespace Umbraco.Web.Mvc protected abstract IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext); - protected virtual void PreparePublishedContentRequest(PublishedContentRequest request) + protected virtual void PreparePublishedContentRequest(PublishedRequest request) { PublishedRouter.PrepareRequest(request); } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs index 06a9a235d0..62094941ed 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/ContentPickerValueConverter.cs @@ -56,7 +56,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters IPublishedContent content; if (inter is int id) { - content = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(id); + content = _publishedSnapshotAccessor.PublishedSnapshot.Content.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 = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(udi.Guid); + content = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(udi.Guid); if (content != null) return content; } diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs index ca833c0bec..8e2df90b53 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs @@ -97,7 +97,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters { var guidUdi = udi as GuidUdi; if (guidUdi == null) continue; - var item = _publishedSnapshotAccessor.PublishedSnapshot.MediaCache.GetById(guidUdi.Guid); + var item = _publishedSnapshotAccessor.PublishedSnapshot.Media.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 08c7f06589..08764b5389 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs @@ -50,7 +50,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters IPublishedContent member; if (source is int id) { - member = _publishedSnapshotAccessor.PublishedSnapshot.MemberCache.GetById(id); + member = _publishedSnapshotAccessor.PublishedSnapshot.Members.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 = _publishedSnapshotAccessor.PublishedSnapshot.MemberCache.GetByProviderKey(sourceUdi.Guid); + member = _publishedSnapshotAccessor.PublishedSnapshot.Members.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 d0906e1a58..bdeeafa465 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/MultiNodeTreePickerValueConverter.cs @@ -89,9 +89,9 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters foreach (var nodeId in nodeIds) { var multiNodeTreePickerItem = - 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)); + GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Document, id => _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(id)) + ?? GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Media, id => _publishedSnapshotAccessor.PublishedSnapshot.Media.GetById(id)) + ?? GetPublishedContent(nodeId, ref objectType, UmbracoObjectTypes.Member, id => _publishedSnapshotAccessor.PublishedSnapshot.Members.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 => _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)); + GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Document, id => _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(guidUdi.Guid)) + ?? GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Media, id => _publishedSnapshotAccessor.PublishedSnapshot.Media.GetById(guidUdi.Guid)) + ?? GetPublishedContent(udi, ref objectType, UmbracoObjectTypes.Member, id => _publishedSnapshotAccessor.PublishedSnapshot.Members.GetByProviderKey(guidUdi.Guid)); if (multiNodeTreePickerItem != null) { multiNodeTreePicker.Add(multiNodeTreePickerItem); diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs index fc93ab6d38..80c32d5ca8 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/NestedContentValueConverterBase.cs @@ -45,7 +45,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters if (string.IsNullOrEmpty(elementTypeAlias)) return null; - var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetContentType(elementTypeAlias); + var publishedContentType = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetContentType(elementTypeAlias); if (publishedContentType == null) return null; diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs index 417dfe8fdd..92b79fba66 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/RelatedLinksValueConverter.cs @@ -80,7 +80,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters var udiAttempt = strLinkId.TryConvertTo(); if (udiAttempt.Success) { - var content = _publishedSnapshotAccessor.PublishedSnapshot.ContentCache.GetById(udiAttempt.Result.Guid); + var content = _publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(udiAttempt.Result.Guid); if (content != null) { relatedLink.Id = content.Id; diff --git a/src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs b/src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs index a5950fe919..6e859d0f02 100644 --- a/src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs +++ b/src/Umbraco.Web/PublishedCache/IPublishedShapshot.cs @@ -13,22 +13,22 @@ namespace Umbraco.Web.PublishedCache /// /// Gets the . /// - IPublishedContentCache ContentCache { get; } + IPublishedContentCache Content { get; } /// /// Gets the . /// - IPublishedMediaCache MediaCache { get; } + IPublishedMediaCache Media { get; } /// /// Gets the . /// - IPublishedMemberCache MemberCache { get; } + IPublishedMemberCache Members { get; } /// /// Gets the . /// - IDomainCache DomainCache { get; } + IDomainCache Domains { get; } /// /// Gets the snapshot-level cache. diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs index 725ff11101..e8530b78f8 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs @@ -103,10 +103,10 @@ namespace Umbraco.Web.PublishedCache.NuCache // args are: current published snapshot (may be null), previewing, content id - returns: content internal static Func GetContentByIdFunc { get; set; } - = (publishedShapshot, previewing, id) => publishedShapshot.ContentCache.GetById(previewing, id); + = (publishedShapshot, previewing, id) => publishedShapshot.Content.GetById(previewing, id); internal static Func GetMediaByIdFunc { get; set; } - = (publishedShapshot, previewing, id) => publishedShapshot.MediaCache.GetById(previewing, id); + = (publishedShapshot, previewing, id) => publishedShapshot.Media.GetById(previewing, id); private IPublishedContent GetContentById(bool previewing, int id) { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs index 1e64f0ccb8..b21834f7b4 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedShapshot.cs @@ -57,13 +57,13 @@ namespace Umbraco.Web.PublishedCache.NuCache #region IPublishedSnapshot - public IPublishedContentCache ContentCache => Elements.ContentCache; + public IPublishedContentCache Content => Elements.ContentCache; - public IPublishedMediaCache MediaCache => Elements.MediaCache; + public IPublishedMediaCache Media => Elements.MediaCache; - public IPublishedMemberCache MemberCache => Elements.MemberCache; + public IPublishedMemberCache Members => Elements.MemberCache; - public IDomainCache DomainCache => Elements.DomainCache; + public IDomainCache Domains => Elements.DomainCache; public IDisposable ForcedPreview(bool preview, Action callback = null) { diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs index b21a1e80d4..e0417bdebf 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedShapshot.cs @@ -19,23 +19,23 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache PublishedMemberCache memberCache, DomainCache domainCache) { - ContentCache = contentCache; - MediaCache = mediaCache; - MemberCache = memberCache; - DomainCache = domainCache; + Content = contentCache; + Media = mediaCache; + Members = memberCache; + Domains = domainCache; } /// - public IPublishedContentCache ContentCache { get; } + public IPublishedContentCache Content { get; } /// - public IPublishedMediaCache MediaCache { get; } + public IPublishedMediaCache Media { get; } /// - public IPublishedMemberCache MemberCache { get; } + public IPublishedMemberCache Members { get; } /// - public IDomainCache DomainCache { get; } + public IDomainCache Domains { get; } /// public ICacheProvider SnapshotCache => null; diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs index 225402045b..342b8b65d4 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/XmlStore.cs @@ -1245,8 +1245,8 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder"; { var publishedSnapshot = (PublishedShapshot) _publishedSnapshotAccessor.PublishedSnapshot; if (publishedSnapshot == null) return; - ((PublishedContentCache) publishedSnapshot.ContentCache).Resync(xml); - ((PublishedMediaCache) publishedSnapshot.MediaCache).Resync(); + ((PublishedContentCache) publishedSnapshot.Content).Resync(xml); + ((PublishedMediaCache) publishedSnapshot.Media).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 8179bbed03..95268f6f8a 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.PublishedShapshot.DomainCache); + var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.Domains); var n = node; var domainUris = domainHelper.DomainsForNode(n.Id, current, false); diff --git a/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs b/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs index 19893415fe..4257d61203 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs @@ -33,7 +33,7 @@ namespace Umbraco.Web.Routing /// /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { if (frequest.UmbracoContext != null && frequest.UmbracoContext.InPreviewMode == false diff --git a/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs b/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs index fc357e098a..77144bcdb1 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Routing /// /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { _logger.Debug("Looking for a page to handle 404."); @@ -54,7 +54,7 @@ namespace Umbraco.Web.Routing } if (node != null) { - var d = DomainHelper.FindWildcardDomainInPath(frequest.UmbracoContext.PublishedShapshot.DomainCache.GetAll(true), node.Path, null); + var d = DomainHelper.FindWildcardDomainInPath(frequest.UmbracoContext.PublishedShapshot.Domains.GetAll(true), node.Path, null); if (d != null) errorCulture = d.Culture; } diff --git a/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs b/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs index 45aad8ed5d..b4d36e66e9 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing /// /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. - public virtual bool TryFindContent(PublishedContentRequest frequest) + public virtual bool TryFindContent(PublishedRequest frequest) { string route; if (frequest.HasDomain) @@ -42,7 +42,7 @@ namespace Umbraco.Web.Routing /// The document request. /// The route. /// The document node, or null. - protected IPublishedContent FindContent(PublishedContentRequest docreq, string route) + protected IPublishedContent FindContent(PublishedRequest docreq, string route) { Logger.Debug("Test route \"{0}\"", () => route); diff --git a/src/Umbraco.Web/Routing/ContentFinderByNiceUrlAndTemplate.cs b/src/Umbraco.Web/Routing/ContentFinderByNiceUrlAndTemplate.cs index ab4a796b9b..e0d21f0fa8 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByNiceUrlAndTemplate.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByNiceUrlAndTemplate.cs @@ -26,7 +26,7 @@ namespace Umbraco.Web.Routing /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. /// If successful, also assigns the template. - public override bool TryFindContent(PublishedContentRequest frequest) + public override bool TryFindContent(PublishedRequest frequest) { IPublishedContent node = null; var path = frequest.Uri.GetAbsolutePathDecoded(); diff --git a/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs b/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs index 62edf358b3..481bb4d905 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs @@ -9,7 +9,7 @@ /// public class ContentFinderByPageIdQuery : IContentFinder { - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { int pageId; if (int.TryParse(frequest.UmbracoContext.HttpContext.Request["umbPageID"], out pageId)) diff --git a/src/Umbraco.Web/Routing/ContentFinderByProfile.cs b/src/Umbraco.Web/Routing/ContentFinderByProfile.cs index 38eaef8fcf..42507c7cda 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByProfile.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByProfile.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing /// /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. - public override bool TryFindContent(PublishedContentRequest frequest) + public override bool TryFindContent(PublishedRequest frequest) { IPublishedContent node = null; var path = frequest.Uri.GetAbsolutePathDecoded(); diff --git a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs index 7612c2c2ed..f79293186d 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByRedirectUrl.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Routing /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. /// Optionally, can also assign the template or anything else on the document request, although that is not required. - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { var route = frequest.HasDomain ? frequest.Domain.ContentId + DomainHelper.PathRelativeToDomain(frequest.Domain.Uri, frequest.Uri.GetAbsolutePathDecoded()) diff --git a/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs b/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs index bff17afb64..0408055710 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Routing /// /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. - public bool TryFindContent(PublishedContentRequest frequest) + public bool TryFindContent(PublishedRequest frequest) { IPublishedContent node = null; diff --git a/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs b/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs index e8d83430f8..251ddf9cdd 100644 --- a/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs +++ b/src/Umbraco.Web/Routing/CustomRouteUrlProvider.cs @@ -21,8 +21,8 @@ namespace Umbraco.Web.Routing public string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode) { if (umbracoContext == null) return null; - if (umbracoContext.PublishedContentRequest == null) return null; - if (umbracoContext.PublishedContentRequest.PublishedContent == null) return null; + if (umbracoContext.PublishedRequest == null) return null; + if (umbracoContext.PublishedRequest.PublishedContent == null) return null; if (umbracoContext.HttpContext == null) return null; if (umbracoContext.HttpContext.Request == null) return null; if (umbracoContext.HttpContext.Request.RequestContext == null) return null; @@ -30,8 +30,8 @@ namespace Umbraco.Web.Routing if (umbracoContext.HttpContext.Request.RequestContext.RouteData.DataTokens == null) return null; if (umbracoContext.HttpContext.Request.RequestContext.RouteData.DataTokens.ContainsKey(Umbraco.Core.Constants.Web.CustomRouteDataToken) == false) return null; //ok so it's a custom route with published content assigned, check if the id being requested for is the same id as the assigned published content - return id == umbracoContext.PublishedContentRequest.PublishedContent.Id - ? umbracoContext.PublishedContentRequest.PublishedContent.Url + return id == umbracoContext.PublishedRequest.PublishedContent.Id + ? umbracoContext.PublishedRequest.PublishedContent.Url : null; } diff --git a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs index ef68115d0b..087fd12dad 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.PublishedShapshot.DomainCache); + var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.Domains); // extract domainUri and path // route is / or / @@ -97,7 +97,7 @@ namespace Umbraco.Web.Routing return null; } - var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.DomainCache); + var domainHelper = new DomainHelper(umbracoContext.PublishedShapshot.Domains); // extract domainUri and path // route is / or / diff --git a/src/Umbraco.Web/Routing/IContentFinder.cs b/src/Umbraco.Web/Routing/IContentFinder.cs index b917896a03..bf905a54ba 100644 --- a/src/Umbraco.Web/Routing/IContentFinder.cs +++ b/src/Umbraco.Web/Routing/IContentFinder.cs @@ -11,6 +11,6 @@ /// The PublishedContentRequest. /// A value indicating whether an Umbraco document was found and assigned. /// Optionally, can also assign the template or anything else on the document request, although that is not required. - bool TryFindContent(PublishedContentRequest frequest); + bool TryFindContent(PublishedRequest frequest); } } diff --git a/src/Umbraco.Web/Routing/PublishedContentNotFoundHandler.cs b/src/Umbraco.Web/Routing/PublishedContentNotFoundHandler.cs index 9c18ff5ef9..7038725dff 100644 --- a/src/Umbraco.Web/Routing/PublishedContentNotFoundHandler.cs +++ b/src/Umbraco.Web/Routing/PublishedContentNotFoundHandler.cs @@ -28,7 +28,7 @@ namespace Umbraco.Web.Routing response.Clear(); - var frequest = UmbracoContext.Current.PublishedContentRequest; + var frequest = UmbracoContext.Current.PublishedRequest; var reason = "Cannot render the page at url '{0}'."; if (frequest.HasPublishedContent == false) reason = "No umbraco document matches the url '{0}'."; diff --git a/src/Umbraco.Web/Routing/PublishedContentRequest.cs b/src/Umbraco.Web/Routing/PublishedRequest.cs similarity index 96% rename from src/Umbraco.Web/Routing/PublishedContentRequest.cs rename to src/Umbraco.Web/Routing/PublishedRequest.cs index 60f71bc051..492837104d 100644 --- a/src/Umbraco.Web/Routing/PublishedContentRequest.cs +++ b/src/Umbraco.Web/Routing/PublishedRequest.cs @@ -1,519 +1,517 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Web; -using umbraco; -using Umbraco.Core.Configuration; -using Umbraco.Core.Models; -using Umbraco.Core.Models.PublishedContent; -using RenderingEngine = Umbraco.Core.RenderingEngine; - -namespace Umbraco.Web.Routing -{ - // todo - rename to PublishedRequest as soon as acceptable - - /// - /// Represents a request for one specified Umbraco IPublishedContent to be rendered - /// by one specified template, using one specified Culture and RenderingEngine. - /// - public class PublishedContentRequest - { - private readonly PublishedRouter _publishedRouter; - - private bool _readonly; // after prepared - private bool _readonlyUri; // after preparing - private Uri _uri; // clean uri, no virtual dir, no trailing slash nor .aspx, nothing - private ITemplate _template; // template model if any else null - private bool _is404; - private DomainAndUri _domain; - private CultureInfo _culture; - private IPublishedContent _publishedContent; - private IPublishedContent _initialPublishedContent; // found by finders before 404, redirects, etc - private page _umbracoPage; // legacy - - /// - /// Initializes a new instance of the class. - /// - /// The published router. - /// The Umbraco context. - /// The request Uri. - internal PublishedContentRequest(PublishedRouter publishedRouter, UmbracoContext umbracoContext, Uri uri = null) - { - UmbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext)); - _publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter)); - Uri = uri ?? umbracoContext.CleanedUmbracoUrl; - RenderingEngine = RenderingEngine.Unknown; - } - - /// - /// Gets the UmbracoContext. - /// - public UmbracoContext UmbracoContext { get; } - - /// - /// Gets or sets the cleaned up Uri used for routing. - /// - /// The cleaned up Uri has no virtual directory, no trailing slash, no .aspx extension, etc. - public Uri Uri - { - get => _uri; - set - { - if (_readonlyUri) - throw new InvalidOperationException("Cannot modify Uri after Preparing has triggered."); - _uri = value; - } - } - - // utility for ensuring it is ok to set some properties - private void EnsureWriteable() - { - if (_readonly) - throw new InvalidOperationException("Cannot modify a PublishedContentRequest once it is read-only."); - } - - /// - /// Prepares the request. - /// - public void Prepare() - { - _publishedRouter.PrepareRequest(this); - } - - #region Events - - /// - /// Triggers before the published content request is prepared. - /// - /// When the event triggers, no preparation has been done. It is still possible to - /// modify the request's Uri property, for example to restore its original, public-facing value - /// that might have been modified by an in-between equipement such as a load-balancer. - public static event EventHandler Preparing; - - /// - /// Triggers once the published content request has been prepared, but before it is processed. - /// - /// When the event triggers, preparation is done ie domain, culture, document, template, - /// rendering engine, etc. have been setup. It is then possible to change anything, before - /// the request is actually processed and rendered by Umbraco. - public static event EventHandler Prepared; - - /// - /// Triggers the Preparing event. - /// - internal void OnPreparing() - { - Preparing?.Invoke(this, EventArgs.Empty); - _readonlyUri = true; - } - - /// - /// Triggers the Prepared event. - /// - internal void OnPrepared() - { - Prepared?.Invoke(this, EventArgs.Empty); - - if (HasPublishedContent == false) - Is404 = true; // safety - - _readonly = true; - } - - #endregion - - #region PublishedContent - - /// - /// Gets or sets the requested content. - /// - /// Setting the requested content clears Template. - public IPublishedContent PublishedContent - { - get { return _publishedContent; } - set - { - EnsureWriteable(); - _publishedContent = value; - IsInternalRedirectPublishedContent = false; - TemplateModel = null; - } - } - - /// - /// Sets the requested content, following an internal redirect. - /// - /// The requested content. - /// Depending on UmbracoSettings.InternalRedirectPreservesTemplate, will - /// preserve or reset the template, if any. - public void SetInternalRedirectPublishedContent(IPublishedContent content) - { - if (content == null) throw new ArgumentNullException(nameof(content)); - EnsureWriteable(); - - // unless a template has been set already by the finder, - // template should be null at that point. - - // IsInternalRedirect if IsInitial, or already IsInternalRedirect - var isInternalRedirect = IsInitialPublishedContent || IsInternalRedirectPublishedContent; - - // redirecting to self - if (content.Id == PublishedContent.Id) // neither can be null - { - // no need to set PublishedContent, we're done - IsInternalRedirectPublishedContent = isInternalRedirect; - return; - } - - // else - - // save - var template = _template; - var renderingEngine = RenderingEngine; - - // set published content - this resets the template, and sets IsInternalRedirect to false - PublishedContent = content; - IsInternalRedirectPublishedContent = isInternalRedirect; - - // must restore the template if it's an internal redirect & the config option is set - if (isInternalRedirect && UmbracoConfig.For.UmbracoSettings().WebRouting.InternalRedirectPreservesTemplate) - { - // restore - _template = template; - RenderingEngine = renderingEngine; - } - } - - /// - /// Gets the initial requested content. - /// - /// The initial requested content is the content that was found by the finders, - /// before anything such as 404, redirect... took place. - public IPublishedContent InitialPublishedContent => _initialPublishedContent; - - /// - /// Gets value indicating whether the current published content is the initial one. - /// - public bool IsInitialPublishedContent => _initialPublishedContent != null && _initialPublishedContent == _publishedContent; - - /// - /// Indicates that the current PublishedContent is the initial one. - /// - public void SetIsInitialPublishedContent() - { - EnsureWriteable(); - - // note: it can very well be null if the initial content was not found - _initialPublishedContent = _publishedContent; - IsInternalRedirectPublishedContent = false; - } - - /// - /// Gets or sets a value indicating whether the current published content has been obtained - /// from the initial published content following internal redirections exclusively. - /// - /// Used by PublishedContentRequestEngine.FindTemplate() to figure out whether to - /// apply the internal redirect or not, when content is not the initial content. - public bool IsInternalRedirectPublishedContent { get; private set; } - - /// - /// Gets a value indicating whether the content request has a content. - /// - public bool HasPublishedContent => PublishedContent != null; - - #endregion - - #region Template - - /// - /// Gets or sets the template model to use to display the requested content. - /// - internal ITemplate TemplateModel - { - get - { - return _template; - } - - set - { - _template = value; - RenderingEngine = RenderingEngine.Unknown; // reset - if (_template != null) - RenderingEngine = _publishedRouter.FindTemplateRenderingEngine(_template.Alias); - } - } - - /// - /// Gets the alias of the template to use to display the requested content. - /// - public string TemplateAlias => _template?.Alias; - - /// - /// Tries to set the template to use to display the requested content. - /// - /// The alias of the template. - /// A value indicating whether a valid template with the specified alias was found. - /// - /// Successfully setting the template does refresh RenderingEngine. - /// If setting the template fails, then the previous template (if any) remains in place. - /// - public bool TrySetTemplate(string alias) - { - EnsureWriteable(); - - if (string.IsNullOrWhiteSpace(alias)) - { - TemplateModel = null; - return true; - } - - // NOTE - can we stil get it with whitespaces in it due to old legacy bugs? - alias = alias.Replace(" ", ""); - - var model = _publishedRouter.GetTemplate(alias); - if (model == null) - return false; - - TemplateModel = model; - return true; - } - - /// - /// Sets the template to use to display the requested content. - /// - /// The template. - /// Setting the template does refresh RenderingEngine. - public void SetTemplate(ITemplate template) - { - EnsureWriteable(); - TemplateModel = template; - } - - /// - /// Resets the template. - /// - /// The RenderingEngine becomes unknown. - public void ResetTemplate() - { - EnsureWriteable(); - TemplateModel = null; - } - - /// - /// Gets a value indicating whether the content request has a template. - /// - public bool HasTemplate => _template != null; - - internal void UpdateOnMissingTemplate() - { - var __readonly = _readonly; - _readonly = false; - _publishedRouter.UpdateRequestOnMissingTemplate(this); - _readonly = __readonly; - } - - #endregion - - #region Domain and Culture - - /// - /// Gets or sets the content request's domain. - /// - /// Is a DomainAndUri object ie a standard Domain plus the fully qualified uri. For example, - /// the Domain may contain "example.com" whereas the Uri will be fully qualified eg "http://example.com/". - public DomainAndUri Domain - { - get { return _domain; } - set - { - EnsureWriteable(); - _domain = value; - } - } - - /// - /// Gets a value indicating whether the content request has a domain. - /// - public bool HasDomain => Domain != null; - - /// - /// Gets or sets the content request's culture. - /// - public CultureInfo Culture - { - get { return _culture; } - set - { - EnsureWriteable(); - _culture = value; - } - } - - // note: do we want to have an ordered list of alternate cultures, - // to allow for fallbacks when doing dictionnary lookup and such? - - #endregion - - #region Rendering - - /// - /// Gets or sets whether the rendering engine is MVC or WebForms. - /// - public RenderingEngine RenderingEngine { get; internal set; } - - #endregion - - #region Status - - /// - /// Gets or sets a value indicating whether the requested content could not be found. - /// - /// This is set in the PublishedContentRequestBuilder and can also be used in - /// custom content finders or Prepared event handlers, where we want to allow developers - /// to indicate a request is 404 but not to cancel it. - public bool Is404 - { - get { return _is404; } - set - { - EnsureWriteable(); - _is404 = value; - } - } - - /// - /// Gets a value indicating whether the content request triggers a redirect (permanent or not). - /// - public bool IsRedirect => string.IsNullOrWhiteSpace(RedirectUrl) == false; - - /// - /// Gets or sets a value indicating whether the redirect is permanent. - /// - public bool IsRedirectPermanent { get; private set; } - - /// - /// Gets or sets the url to redirect to, when the content request triggers a redirect. - /// - public string RedirectUrl { get; private set; } - - /// - /// Indicates that the content request should trigger a redirect (302). - /// - /// The url to redirect to. - /// Does not actually perform a redirect, only registers that the response should - /// redirect. Redirect will or will not take place in due time. - public void SetRedirect(string url) - { - EnsureWriteable(); - RedirectUrl = url; - IsRedirectPermanent = false; - } - - /// - /// Indicates that the content request should trigger a permanent redirect (301). - /// - /// The url to redirect to. - /// Does not actually perform a redirect, only registers that the response should - /// redirect. Redirect will or will not take place in due time. - public void SetRedirectPermanent(string url) - { - EnsureWriteable(); - RedirectUrl = url; - IsRedirectPermanent = true; - } - - /// - /// Indicates that the content requet should trigger a redirect, with a specified status code. - /// - /// The url to redirect to. - /// The status code (300-308). - /// Does not actually perform a redirect, only registers that the response should - /// redirect. Redirect will or will not take place in due time. - public void SetRedirect(string url, int status) - { - EnsureWriteable(); - - if (status < 300 || status > 308) - throw new ArgumentOutOfRangeException(nameof(status), "Valid redirection status codes 300-308."); - - RedirectUrl = url; - IsRedirectPermanent = (status == 301 || status == 308); - if (status != 301 && status != 302) // default redirect statuses - ResponseStatusCode = status; - } - - /// - /// Gets or sets the content request http response status code. - /// - /// Does not actually set the http response status code, only registers that the response - /// should use the specified code. The code will or will not be used, in due time. - public int ResponseStatusCode { get; private set; } - - /// - /// Gets or sets the content request http response status description. - /// - /// Does not actually set the http response status description, only registers that the response - /// should use the specified description. The description will or will not be used, in due time. - public string ResponseStatusDescription { get; private set; } - - /// - /// Sets the http response status code, along with an optional associated description. - /// - /// The http status code. - /// The description. - /// Does not actually set the http response status code and description, only registers that - /// the response should use the specified code and description. The code and description will or will - /// not be used, in due time. - public void SetResponseStatus(int code, string description = null) - { - EnsureWriteable(); - - // .Status is deprecated - // .SubStatusCode is IIS 7+ internal, ignore - ResponseStatusCode = code; - ResponseStatusDescription = description; - } - - #endregion - - #region Response Cache - - /// - /// Gets or sets the System.Web.HttpCacheability - /// - // Note: we used to set a default value here but that would then be the default - // for ALL requests, we shouldn't overwrite it though if people are using [OutputCache] for example - // see: https://our.umbraco.org/forum/using-umbraco-and-getting-started/79715-output-cache-in-umbraco-752 - internal HttpCacheability Cacheability { get; set; } - - /// - /// Gets or sets a list of Extensions to append to the Response.Cache object. - /// - internal List CacheExtensions { get; set; } = new List(); - - /// - /// Gets or sets a dictionary of Headers to append to the Response object. - /// - internal Dictionary Headers { get; set; } = new Dictionary(); - - #endregion - - #region Legacy - - // for legacy/webforms code - todo - get rid of it eventually - internal page UmbracoPage - { - get - { - if (_umbracoPage == null) - throw new InvalidOperationException("The UmbracoPage object has not been initialized yet."); - - return _umbracoPage; - } - set { _umbracoPage = value; } - } - - #endregion - } -} +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Web; +using umbraco; +using Umbraco.Core.Configuration; +using Umbraco.Core.Models; +using Umbraco.Core.Models.PublishedContent; +using RenderingEngine = Umbraco.Core.RenderingEngine; + +namespace Umbraco.Web.Routing +{ + /// + /// Represents a request for one specified Umbraco IPublishedContent to be rendered + /// by one specified template, using one specified Culture and RenderingEngine. + /// + public class PublishedRequest + { + private readonly PublishedRouter _publishedRouter; + + private bool _readonly; // after prepared + private bool _readonlyUri; // after preparing + private Uri _uri; // clean uri, no virtual dir, no trailing slash nor .aspx, nothing + private ITemplate _template; // template model if any else null + private bool _is404; + private DomainAndUri _domain; + private CultureInfo _culture; + private IPublishedContent _publishedContent; + private IPublishedContent _initialPublishedContent; // found by finders before 404, redirects, etc + private page _umbracoPage; // legacy + + /// + /// Initializes a new instance of the class. + /// + /// The published router. + /// The Umbraco context. + /// The request Uri. + internal PublishedRequest(PublishedRouter publishedRouter, UmbracoContext umbracoContext, Uri uri = null) + { + UmbracoContext = umbracoContext ?? throw new ArgumentNullException(nameof(umbracoContext)); + _publishedRouter = publishedRouter ?? throw new ArgumentNullException(nameof(publishedRouter)); + Uri = uri ?? umbracoContext.CleanedUmbracoUrl; + RenderingEngine = RenderingEngine.Unknown; + } + + /// + /// Gets the UmbracoContext. + /// + public UmbracoContext UmbracoContext { get; } + + /// + /// Gets or sets the cleaned up Uri used for routing. + /// + /// The cleaned up Uri has no virtual directory, no trailing slash, no .aspx extension, etc. + public Uri Uri + { + get => _uri; + set + { + if (_readonlyUri) + throw new InvalidOperationException("Cannot modify Uri after Preparing has triggered."); + _uri = value; + } + } + + // utility for ensuring it is ok to set some properties + private void EnsureWriteable() + { + if (_readonly) + throw new InvalidOperationException("Cannot modify a PublishedContentRequest once it is read-only."); + } + + /// + /// Prepares the request. + /// + public void Prepare() + { + _publishedRouter.PrepareRequest(this); + } + + #region Events + + /// + /// Triggers before the published content request is prepared. + /// + /// When the event triggers, no preparation has been done. It is still possible to + /// modify the request's Uri property, for example to restore its original, public-facing value + /// that might have been modified by an in-between equipement such as a load-balancer. + public static event EventHandler Preparing; + + /// + /// Triggers once the published content request has been prepared, but before it is processed. + /// + /// When the event triggers, preparation is done ie domain, culture, document, template, + /// rendering engine, etc. have been setup. It is then possible to change anything, before + /// the request is actually processed and rendered by Umbraco. + public static event EventHandler Prepared; + + /// + /// Triggers the Preparing event. + /// + internal void OnPreparing() + { + Preparing?.Invoke(this, EventArgs.Empty); + _readonlyUri = true; + } + + /// + /// Triggers the Prepared event. + /// + internal void OnPrepared() + { + Prepared?.Invoke(this, EventArgs.Empty); + + if (HasPublishedContent == false) + Is404 = true; // safety + + _readonly = true; + } + + #endregion + + #region PublishedContent + + /// + /// Gets or sets the requested content. + /// + /// Setting the requested content clears Template. + public IPublishedContent PublishedContent + { + get { return _publishedContent; } + set + { + EnsureWriteable(); + _publishedContent = value; + IsInternalRedirectPublishedContent = false; + TemplateModel = null; + } + } + + /// + /// Sets the requested content, following an internal redirect. + /// + /// The requested content. + /// Depending on UmbracoSettings.InternalRedirectPreservesTemplate, will + /// preserve or reset the template, if any. + public void SetInternalRedirectPublishedContent(IPublishedContent content) + { + if (content == null) throw new ArgumentNullException(nameof(content)); + EnsureWriteable(); + + // unless a template has been set already by the finder, + // template should be null at that point. + + // IsInternalRedirect if IsInitial, or already IsInternalRedirect + var isInternalRedirect = IsInitialPublishedContent || IsInternalRedirectPublishedContent; + + // redirecting to self + if (content.Id == PublishedContent.Id) // neither can be null + { + // no need to set PublishedContent, we're done + IsInternalRedirectPublishedContent = isInternalRedirect; + return; + } + + // else + + // save + var template = _template; + var renderingEngine = RenderingEngine; + + // set published content - this resets the template, and sets IsInternalRedirect to false + PublishedContent = content; + IsInternalRedirectPublishedContent = isInternalRedirect; + + // must restore the template if it's an internal redirect & the config option is set + if (isInternalRedirect && UmbracoConfig.For.UmbracoSettings().WebRouting.InternalRedirectPreservesTemplate) + { + // restore + _template = template; + RenderingEngine = renderingEngine; + } + } + + /// + /// Gets the initial requested content. + /// + /// The initial requested content is the content that was found by the finders, + /// before anything such as 404, redirect... took place. + public IPublishedContent InitialPublishedContent => _initialPublishedContent; + + /// + /// Gets value indicating whether the current published content is the initial one. + /// + public bool IsInitialPublishedContent => _initialPublishedContent != null && _initialPublishedContent == _publishedContent; + + /// + /// Indicates that the current PublishedContent is the initial one. + /// + public void SetIsInitialPublishedContent() + { + EnsureWriteable(); + + // note: it can very well be null if the initial content was not found + _initialPublishedContent = _publishedContent; + IsInternalRedirectPublishedContent = false; + } + + /// + /// Gets or sets a value indicating whether the current published content has been obtained + /// from the initial published content following internal redirections exclusively. + /// + /// Used by PublishedContentRequestEngine.FindTemplate() to figure out whether to + /// apply the internal redirect or not, when content is not the initial content. + public bool IsInternalRedirectPublishedContent { get; private set; } + + /// + /// Gets a value indicating whether the content request has a content. + /// + public bool HasPublishedContent => PublishedContent != null; + + #endregion + + #region Template + + /// + /// Gets or sets the template model to use to display the requested content. + /// + internal ITemplate TemplateModel + { + get + { + return _template; + } + + set + { + _template = value; + RenderingEngine = RenderingEngine.Unknown; // reset + if (_template != null) + RenderingEngine = _publishedRouter.FindTemplateRenderingEngine(_template.Alias); + } + } + + /// + /// Gets the alias of the template to use to display the requested content. + /// + public string TemplateAlias => _template?.Alias; + + /// + /// Tries to set the template to use to display the requested content. + /// + /// The alias of the template. + /// A value indicating whether a valid template with the specified alias was found. + /// + /// Successfully setting the template does refresh RenderingEngine. + /// If setting the template fails, then the previous template (if any) remains in place. + /// + public bool TrySetTemplate(string alias) + { + EnsureWriteable(); + + if (string.IsNullOrWhiteSpace(alias)) + { + TemplateModel = null; + return true; + } + + // NOTE - can we stil get it with whitespaces in it due to old legacy bugs? + alias = alias.Replace(" ", ""); + + var model = _publishedRouter.GetTemplate(alias); + if (model == null) + return false; + + TemplateModel = model; + return true; + } + + /// + /// Sets the template to use to display the requested content. + /// + /// The template. + /// Setting the template does refresh RenderingEngine. + public void SetTemplate(ITemplate template) + { + EnsureWriteable(); + TemplateModel = template; + } + + /// + /// Resets the template. + /// + /// The RenderingEngine becomes unknown. + public void ResetTemplate() + { + EnsureWriteable(); + TemplateModel = null; + } + + /// + /// Gets a value indicating whether the content request has a template. + /// + public bool HasTemplate => _template != null; + + internal void UpdateOnMissingTemplate() + { + var __readonly = _readonly; + _readonly = false; + _publishedRouter.UpdateRequestOnMissingTemplate(this); + _readonly = __readonly; + } + + #endregion + + #region Domain and Culture + + /// + /// Gets or sets the content request's domain. + /// + /// Is a DomainAndUri object ie a standard Domain plus the fully qualified uri. For example, + /// the Domain may contain "example.com" whereas the Uri will be fully qualified eg "http://example.com/". + public DomainAndUri Domain + { + get { return _domain; } + set + { + EnsureWriteable(); + _domain = value; + } + } + + /// + /// Gets a value indicating whether the content request has a domain. + /// + public bool HasDomain => Domain != null; + + /// + /// Gets or sets the content request's culture. + /// + public CultureInfo Culture + { + get { return _culture; } + set + { + EnsureWriteable(); + _culture = value; + } + } + + // note: do we want to have an ordered list of alternate cultures, + // to allow for fallbacks when doing dictionnary lookup and such? + + #endregion + + #region Rendering + + /// + /// Gets or sets whether the rendering engine is MVC or WebForms. + /// + public RenderingEngine RenderingEngine { get; internal set; } + + #endregion + + #region Status + + /// + /// Gets or sets a value indicating whether the requested content could not be found. + /// + /// This is set in the PublishedContentRequestBuilder and can also be used in + /// custom content finders or Prepared event handlers, where we want to allow developers + /// to indicate a request is 404 but not to cancel it. + public bool Is404 + { + get { return _is404; } + set + { + EnsureWriteable(); + _is404 = value; + } + } + + /// + /// Gets a value indicating whether the content request triggers a redirect (permanent or not). + /// + public bool IsRedirect => string.IsNullOrWhiteSpace(RedirectUrl) == false; + + /// + /// Gets or sets a value indicating whether the redirect is permanent. + /// + public bool IsRedirectPermanent { get; private set; } + + /// + /// Gets or sets the url to redirect to, when the content request triggers a redirect. + /// + public string RedirectUrl { get; private set; } + + /// + /// Indicates that the content request should trigger a redirect (302). + /// + /// The url to redirect to. + /// Does not actually perform a redirect, only registers that the response should + /// redirect. Redirect will or will not take place in due time. + public void SetRedirect(string url) + { + EnsureWriteable(); + RedirectUrl = url; + IsRedirectPermanent = false; + } + + /// + /// Indicates that the content request should trigger a permanent redirect (301). + /// + /// The url to redirect to. + /// Does not actually perform a redirect, only registers that the response should + /// redirect. Redirect will or will not take place in due time. + public void SetRedirectPermanent(string url) + { + EnsureWriteable(); + RedirectUrl = url; + IsRedirectPermanent = true; + } + + /// + /// Indicates that the content requet should trigger a redirect, with a specified status code. + /// + /// The url to redirect to. + /// The status code (300-308). + /// Does not actually perform a redirect, only registers that the response should + /// redirect. Redirect will or will not take place in due time. + public void SetRedirect(string url, int status) + { + EnsureWriteable(); + + if (status < 300 || status > 308) + throw new ArgumentOutOfRangeException(nameof(status), "Valid redirection status codes 300-308."); + + RedirectUrl = url; + IsRedirectPermanent = (status == 301 || status == 308); + if (status != 301 && status != 302) // default redirect statuses + ResponseStatusCode = status; + } + + /// + /// Gets or sets the content request http response status code. + /// + /// Does not actually set the http response status code, only registers that the response + /// should use the specified code. The code will or will not be used, in due time. + public int ResponseStatusCode { get; private set; } + + /// + /// Gets or sets the content request http response status description. + /// + /// Does not actually set the http response status description, only registers that the response + /// should use the specified description. The description will or will not be used, in due time. + public string ResponseStatusDescription { get; private set; } + + /// + /// Sets the http response status code, along with an optional associated description. + /// + /// The http status code. + /// The description. + /// Does not actually set the http response status code and description, only registers that + /// the response should use the specified code and description. The code and description will or will + /// not be used, in due time. + public void SetResponseStatus(int code, string description = null) + { + EnsureWriteable(); + + // .Status is deprecated + // .SubStatusCode is IIS 7+ internal, ignore + ResponseStatusCode = code; + ResponseStatusDescription = description; + } + + #endregion + + #region Response Cache + + /// + /// Gets or sets the System.Web.HttpCacheability + /// + // Note: we used to set a default value here but that would then be the default + // for ALL requests, we shouldn't overwrite it though if people are using [OutputCache] for example + // see: https://our.umbraco.org/forum/using-umbraco-and-getting-started/79715-output-cache-in-umbraco-752 + internal HttpCacheability Cacheability { get; set; } + + /// + /// Gets or sets a list of Extensions to append to the Response.Cache object. + /// + internal List CacheExtensions { get; set; } = new List(); + + /// + /// Gets or sets a dictionary of Headers to append to the Response object. + /// + internal Dictionary Headers { get; set; } = new Dictionary(); + + #endregion + + #region Legacy + + // for legacy/webforms code - todo - get rid of it eventually + internal page UmbracoPage + { + get + { + if (_umbracoPage == null) + throw new InvalidOperationException("The UmbracoPage object has not been initialized yet."); + + return _umbracoPage; + } + set { _umbracoPage = value; } + } + + #endregion + } +} diff --git a/src/Umbraco.Web/Routing/PublishedRouter.cs b/src/Umbraco.Web/Routing/PublishedRouter.cs index 1b87ddc863..aef4c5e8a2 100644 --- a/src/Umbraco.Web/Routing/PublishedRouter.cs +++ b/src/Umbraco.Web/Routing/PublishedRouter.cs @@ -56,9 +56,9 @@ namespace Umbraco.Web.Routing // this is all soooo weird public Func> GetRolesForLogin { get; } - public PublishedContentRequest CreateRequest(UmbracoContext umbracoContext, Uri uri = null) + public PublishedRequest CreateRequest(UmbracoContext umbracoContext, Uri uri = null) { - return new PublishedContentRequest(this, umbracoContext, uri ?? umbracoContext.CleanedUmbracoUrl); + return new PublishedRequest(this, umbracoContext, uri ?? umbracoContext.CleanedUmbracoUrl); } #region Request @@ -66,7 +66,7 @@ namespace Umbraco.Web.Routing /// /// Tries to route the request. /// - internal bool TryRouteRequest(PublishedContentRequest request) + internal bool TryRouteRequest(PublishedRequest request) { // disabled - is it going to change the routing? //_pcr.OnPreparing(); @@ -95,7 +95,7 @@ namespace Umbraco.Web.Routing /// /// Returns false if the request was not successfully prepared /// - public bool PrepareRequest(PublishedContentRequest request) + public bool PrepareRequest(PublishedRequest request) { // note - at that point the original legacy module did something do handle IIS custom 404 errors // ie pages looking like /anything.aspx?404;/path/to/document - I guess the reason was to support @@ -164,7 +164,7 @@ namespace Umbraco.Web.Routing /// This method logic has been put into it's own method in case developers have created a custom PCR or are assigning their own values /// but need to finalize it themselves. /// - public bool ConfigureRequest(PublishedContentRequest frequest) + public bool ConfigureRequest(PublishedRequest frequest) { if (frequest.HasPublishedContent == false) { @@ -208,7 +208,7 @@ namespace Umbraco.Web.Routing /// Updates the request when there is no template to render the content. /// /// This is called from Mvc when there's a document to render but no template. - public void UpdateRequestOnMissingTemplate(PublishedContentRequest request) + public void UpdateRequestOnMissingTemplate(PublishedRequest request) { // clear content var content = request.PublishedContent; @@ -257,7 +257,7 @@ namespace Umbraco.Web.Routing /// Finds the site root (if any) matching the http request, and updates the PublishedContentRequest accordingly. /// /// A value indicating whether a domain was found. - internal bool FindDomain(PublishedContentRequest request) + internal bool FindDomain(PublishedRequest request) { const string tracePrefix = "FindDomain: "; @@ -266,7 +266,7 @@ namespace Umbraco.Web.Routing _logger.Debug("{0}Uri=\"{1}\"", () => tracePrefix, () => request.Uri); // try to find a domain matching the current request - var domainAndUri = DomainHelper.DomainForUri(request.UmbracoContext.PublishedShapshot.DomainCache.GetAll(false), request.Uri); + var domainAndUri = DomainHelper.DomainForUri(request.UmbracoContext.PublishedShapshot.Domains.GetAll(false), request.Uri); // handle domain - always has a contentId and a culture if (domainAndUri != null) @@ -305,7 +305,7 @@ namespace Umbraco.Web.Routing /// /// Looks for wildcard domains in the path and updates Culture accordingly. /// - internal void HandleWildcardDomains(PublishedContentRequest request) + internal void HandleWildcardDomains(PublishedRequest request) { const string tracePrefix = "HandleWildcardDomains: "; @@ -315,7 +315,7 @@ namespace Umbraco.Web.Routing var nodePath = request.PublishedContent.Path; _logger.Debug("{0}Path=\"{1}\"", () => tracePrefix, () => nodePath); var rootNodeId = request.HasDomain ? request.Domain.ContentId : (int?)null; - var domain = DomainHelper.FindWildcardDomainInPath(request.UmbracoContext.PublishedShapshot.DomainCache.GetAll(true), nodePath, rootNodeId); + var domain = DomainHelper.FindWildcardDomainInPath(request.UmbracoContext.PublishedShapshot.Domains.GetAll(true), nodePath, rootNodeId); // always has a contentId and a culture if (domain != null) @@ -397,7 +397,7 @@ namespace Umbraco.Web.Routing /// Finds the Umbraco document (if any) matching the request, and updates the PublishedContentRequest accordingly. /// /// A value indicating whether a document and template were found. - private void FindPublishedContentAndTemplate(PublishedContentRequest request) + private void FindPublishedContentAndTemplate(PublishedRequest request) { const string tracePrefix = "FindPublishedContentAndTemplate: "; _logger.Debug("{0}Path=\"{1}\"", () => tracePrefix, () => request.Uri.AbsolutePath); @@ -428,7 +428,7 @@ namespace Umbraco.Web.Routing /// Tries to find the document matching the request, by running the IPublishedContentFinder instances. /// /// There is no finder collection. - internal void FindPublishedContent(PublishedContentRequest request) + internal void FindPublishedContent(PublishedRequest request) { const string tracePrefix = "FindPublishedContent: "; @@ -460,7 +460,7 @@ namespace Umbraco.Web.Routing /// Handles "not found", internal redirects, access validation... /// things that must be handled in one place because they can create loops /// - private void HandlePublishedContent(PublishedContentRequest request) + private void HandlePublishedContent(PublishedRequest request) { const string tracePrefix = "HandlePublishedContent: "; @@ -521,7 +521,7 @@ namespace Umbraco.Web.Routing /// Redirecting to a different site root and/or culture will not pick the new site root nor the new culture. /// As per legacy, if the redirect does not work, we just ignore it. /// - private bool FollowInternalRedirects(PublishedContentRequest request) + private bool FollowInternalRedirects(PublishedRequest request) { const string tracePrefix = "FollowInternalRedirects: "; @@ -583,7 +583,7 @@ namespace Umbraco.Web.Routing /// Ensures that access to current node is permitted. /// /// Redirecting to a different site root and/or culture will not pick the new site root nor the new culture. - private void EnsurePublishedContentAccess(PublishedContentRequest request) + private void EnsurePublishedContentAccess(PublishedRequest request) { const string tracePrefix = "EnsurePublishedContentAccess: "; @@ -607,14 +607,14 @@ namespace Umbraco.Web.Routing var loginPageId = publicAccessAttempt.Result.LoginNodeId; if (loginPageId != request.PublishedContent.Id) - request.PublishedContent = request.UmbracoContext.PublishedShapshot.ContentCache.GetById(loginPageId); + request.PublishedContent = request.UmbracoContext.PublishedShapshot.Content.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); var errorPageId = publicAccessAttempt.Result.NoAccessNodeId; if (errorPageId != request.PublishedContent.Id) - request.PublishedContent = request.UmbracoContext.PublishedShapshot.ContentCache.GetById(errorPageId); + request.PublishedContent = request.UmbracoContext.PublishedShapshot.Content.GetById(errorPageId); } else { @@ -630,7 +630,7 @@ namespace Umbraco.Web.Routing /// /// Finds a template for the current node, if any. /// - private void FindTemplate(PublishedContentRequest request) + private void FindTemplate(PublishedRequest request) { // NOTE: at the moment there is only 1 way to find a template, and then ppl must // use the Prepared event to change the template if they wish. Should we also @@ -663,7 +663,7 @@ namespace Umbraco.Web.Routing if (request.HasTemplate) { - _logger.Debug("{0}Has a template already, and no alternate template.", () => tracePrefix); + _logger.Debug("{0}Has a template already, and no alternate template.", () => tracePrefix); return; } @@ -733,7 +733,7 @@ namespace Umbraco.Web.Routing /// Follows external redirection through umbracoRedirect document property. /// /// As per legacy, if the redirect does not work, we just ignore it. - private void FollowExternalRedirect(PublishedContentRequest request) + private void FollowExternalRedirect(PublishedRequest request) { if (request.HasPublishedContent == false) return; diff --git a/src/Umbraco.Web/Security/MembershipHelper.cs b/src/Umbraco.Web/Security/MembershipHelper.cs index 8dae7d15e5..c783119483 100644 --- a/src/Umbraco.Web/Security/MembershipHelper.cs +++ b/src/Umbraco.Web/Security/MembershipHelper.cs @@ -94,7 +94,7 @@ namespace Umbraco.Web.Security _umbracoContext = umbracoContext; _membershipProvider = membershipProvider; _roleProvider = roleProvider; - _memberCache = umbracoContext.PublishedShapshot.MemberCache; + _memberCache = umbracoContext.PublishedShapshot.Members; // helpers are *not* instanciated by the container so we have to // get our dependencies injected manually, through properties. @@ -156,7 +156,7 @@ namespace Umbraco.Web.Security /// private bool HasAccess(string path, RoleProvider roleProvider) { - return _umbracoContext.PublishedContentRequest == null + return _umbracoContext.PublishedRequest == null ? PublicAccessService.HasAccess(path, CurrentUserName, roleProvider.GetRolesForUser) : PublicAccessService.HasAccess(path, CurrentUserName, Router.GetRolesForLogin); } diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs index afccef92f4..0fc490d3c8 100644 --- a/src/Umbraco.Web/Templates/TemplateRenderer.cs +++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs @@ -29,7 +29,7 @@ namespace Umbraco.Web.Templates private readonly UmbracoContext _umbracoContext; private object _oldPageId; private object _oldPageElements; - private PublishedContentRequest _oldPublishedContentRequest; + private PublishedRequest _oldPublishedRequest; private object _oldAltTemplate; public TemplateRenderer(UmbracoContext umbracoContext, int pageId, int? altTemplateId) @@ -75,7 +75,7 @@ namespace Umbraco.Web.Templates //in some cases the UmbracoContext will not have a PublishedContentRequest assigned to it if we are not in the //execution of a front-end rendered page. In this case set the culture to the default. //set the culture to the same as is currently rendering - if (_umbracoContext.PublishedContentRequest == null) + if (_umbracoContext.PublishedRequest == null) { var defaultLanguage = Current.Services.LocalizationService.GetAllLanguages().FirstOrDefault(); contentRequest.Culture = defaultLanguage == null @@ -84,7 +84,7 @@ namespace Umbraco.Web.Templates } else { - contentRequest.Culture = _umbracoContext.PublishedContentRequest.Culture; + contentRequest.Culture = _umbracoContext.PublishedRequest.Culture; } //set the doc that was found by id @@ -128,7 +128,7 @@ namespace Umbraco.Web.Templates } - private void ExecuteTemplateRendering(TextWriter sw, PublishedContentRequest contentRequest) + private void ExecuteTemplateRendering(TextWriter sw, PublishedRequest request) { //NOTE: Before we used to build up the query strings here but this is not necessary because when we do a // Server.Execute in the TemplateRenderer, we pass in a 'true' to 'preserveForm' which automatically preserves all current @@ -138,7 +138,7 @@ namespace Umbraco.Web.Templates //var queryString = _umbracoContext.HttpContext.Request.QueryString.AllKeys // .ToDictionary(key => key, key => context.Request.QueryString[key]); - switch (contentRequest.RenderingEngine) + switch (request.RenderingEngine) { case RenderingEngine.Mvc: var requestContext = new RequestContext(_umbracoContext.HttpContext, new RouteData() @@ -146,13 +146,13 @@ namespace Umbraco.Web.Templates Route = RouteTable.Routes["Umbraco_default"] }); var routeHandler = new RenderRouteHandler(_umbracoContext, ControllerBuilder.Current.GetControllerFactory()); - var routeDef = routeHandler.GetUmbracoRouteDefinition(requestContext, contentRequest); - var renderModel = new ContentModel(contentRequest.PublishedContent); + var routeDef = routeHandler.GetUmbracoRouteDefinition(requestContext, request); + var renderModel = new ContentModel(request.PublishedContent); //manually add the action/controller, this is required by mvc requestContext.RouteData.Values.Add("action", routeDef.ActionName); requestContext.RouteData.Values.Add("controller", routeDef.ControllerName); //add the rest of the required route data - routeHandler.SetupRouteDataForRequest(renderModel, requestContext, contentRequest); + routeHandler.SetupRouteDataForRequest(renderModel, requestContext, request); var stringOutput = RenderUmbracoRequestToString(requestContext); @@ -197,15 +197,15 @@ namespace Umbraco.Web.Templates return newWriter.ToString(); } - private void SetNewItemsOnContextObjects(PublishedContentRequest contentRequest) + private void SetNewItemsOnContextObjects(PublishedRequest request) { // handlers like default.aspx will want it and most macros currently need it - contentRequest.UmbracoPage = new page(contentRequest); + request.UmbracoPage = new page(request); //now, set the new ones for this page execution - _umbracoContext.HttpContext.Items["pageID"] = contentRequest.PublishedContent.Id; - _umbracoContext.HttpContext.Items["pageElements"] = contentRequest.UmbracoPage.Elements; + _umbracoContext.HttpContext.Items["pageID"] = request.PublishedContent.Id; + _umbracoContext.HttpContext.Items["pageElements"] = request.UmbracoPage.Elements; _umbracoContext.HttpContext.Items[Core.Constants.Conventions.Url.AltTemplate] = null; - _umbracoContext.PublishedContentRequest = contentRequest; + _umbracoContext.PublishedRequest = request; } /// @@ -217,7 +217,7 @@ namespace Umbraco.Web.Templates //save the values in them so that we can re-set them after we render so the rest of the execution works as per normal. _oldPageId = _umbracoContext.HttpContext.Items["pageID"]; _oldPageElements = _umbracoContext.HttpContext.Items["pageElements"]; - _oldPublishedContentRequest = _umbracoContext.PublishedContentRequest; + _oldPublishedRequest = _umbracoContext.PublishedRequest; _oldAltTemplate = _umbracoContext.HttpContext.Items[Umbraco.Core.Constants.Conventions.Url.AltTemplate]; } @@ -226,7 +226,7 @@ namespace Umbraco.Web.Templates /// private void RestoreItems() { - _umbracoContext.PublishedContentRequest = _oldPublishedContentRequest; + _umbracoContext.PublishedRequest = _oldPublishedRequest; _umbracoContext.HttpContext.Items["pageID"] = _oldPageId; _umbracoContext.HttpContext.Items["pageElements"] = _oldPageElements; _umbracoContext.HttpContext.Items[Umbraco.Core.Constants.Conventions.Url.AltTemplate] = _oldAltTemplate; diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index a2b2ee3b2d..c4291b57d3 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1171,7 +1171,7 @@ - + Code diff --git a/src/Umbraco.Web/UmbracoComponentRenderer.cs b/src/Umbraco.Web/UmbracoComponentRenderer.cs index 28892cf551..59c0066926 100644 --- a/src/Umbraco.Web/UmbracoComponentRenderer.cs +++ b/src/Umbraco.Web/UmbracoComponentRenderer.cs @@ -86,12 +86,12 @@ namespace Umbraco.Web public IHtmlString RenderMacro(string alias, IDictionary parameters) { - if (_umbracoContext.PublishedContentRequest == null) + if (_umbracoContext.PublishedRequest == null) { throw new InvalidOperationException("Cannot render a macro when there is no current PublishedContentRequest."); } - return RenderMacro(alias, parameters, _umbracoContext.PublishedContentRequest.UmbracoPage); + return RenderMacro(alias, parameters, _umbracoContext.PublishedRequest.UmbracoPage); } /// @@ -280,8 +280,8 @@ namespace Umbraco.Web //currently assigned node. The PublishedContentRequest will be null if: // * we are rendering a partial view or child action // * we are rendering a view from a custom route - if ((_umbracoContext.PublishedContentRequest == null - || _umbracoContext.PublishedContentRequest.PublishedContent.Id != currentPage.Id) + if ((_umbracoContext.PublishedRequest == null + || _umbracoContext.PublishedRequest.PublishedContent.Id != currentPage.Id) && currentPage.Id > 0) // in case we're rendering a detached content (id == 0) { item.NodeId = currentPage.Id.ToString(CultureInfo.InvariantCulture); diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index c86fb60a6c..31d67cc118 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -175,17 +175,17 @@ namespace Umbraco.Web /// /// Gets the published content cache. /// - public IPublishedContentCache ContentCache => PublishedShapshot.ContentCache; + public IPublishedContentCache ContentCache => PublishedShapshot.Content; /// /// Gets the published media cache. /// - public IPublishedMediaCache MediaCache => PublishedShapshot.MediaCache; + public IPublishedMediaCache MediaCache => PublishedShapshot.Media; /// /// Boolean value indicating whether the current request is a front-end umbraco request /// - public bool IsFrontEndUmbracoRequest => PublishedContentRequest != null; + public bool IsFrontEndUmbracoRequest => PublishedRequest != null; /// /// Gets the url provider. @@ -195,7 +195,7 @@ namespace Umbraco.Web /// /// Gets/sets the PublishedContentRequest object /// - public PublishedContentRequest PublishedContentRequest { get; set; } + public PublishedRequest PublishedRequest { get; set; } /// /// Exposes the HttpContext for the current request diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index 48755a78be..9e950be64d 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -122,7 +122,7 @@ namespace Umbraco.Web _umbracoContext = umbracoContext; if (_umbracoContext.IsFrontEndUmbracoRequest) - _currentPage = _umbracoContext.PublishedContentRequest.PublishedContent; + _currentPage = _umbracoContext.PublishedRequest.PublishedContent; _services = services; _appCache = appCache; } diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index ed2553b446..7f42eafb9c 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -153,7 +153,7 @@ 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 = PublishedRouter.CreateRequest(umbracoContext); - umbracoContext.PublishedContentRequest = request; + umbracoContext.PublishedRequest = request; PublishedRouter.PrepareRequest(request); // HandleHttpResponseStatus returns a value indicating that the request should @@ -336,7 +336,7 @@ namespace Umbraco.Web // returns a value indicating whether redirection took place and the request has // been completed - because we don't want to Response.End() here to terminate // everything properly. - internal static bool HandleHttpResponseStatus(HttpContextBase context, PublishedContentRequest pcr, ILogger logger) + internal static bool HandleHttpResponseStatus(HttpContextBase context, PublishedRequest pcr, ILogger logger) { var end = false; var response = context.Response; @@ -422,7 +422,7 @@ namespace Umbraco.Web /// /// /// - private static void RewriteToUmbracoHandler(HttpContextBase context, PublishedContentRequest pcr) + private static void RewriteToUmbracoHandler(HttpContextBase context, PublishedRequest pcr) { // NOTE: we do not want to use TransferRequest even though many docs say it is better with IIS7, turns out this is // not what we need. The purpose of TransferRequest is to ensure that .net processes all of the rules for the newly diff --git a/src/Umbraco.Web/umbraco.presentation/default.aspx.cs b/src/Umbraco.Web/umbraco.presentation/default.aspx.cs index 588c82a2c3..0e825408e4 100644 --- a/src/Umbraco.Web/umbraco.presentation/default.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/default.aspx.cs @@ -32,7 +32,7 @@ namespace umbraco } private page _upage; - private PublishedContentRequest _frequest; + private PublishedRequest _frequest; /// /// To turn off request validation set this to false before the PageLoad event. This equivalent to the validateRequest page directive @@ -50,7 +50,7 @@ namespace umbraco Page.Trace.IsEnabled &= GlobalSettings.DebugMode && string.IsNullOrWhiteSpace(Request["umbDebugShowTrace"]) == false; // get the document request and the page - _frequest = UmbracoContext.Current.PublishedContentRequest; + _frequest = UmbracoContext.Current.PublishedRequest; _upage = _frequest.UmbracoPage; //we need to check this for backwards compatibility in case people still arent' using master pages diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs index 071c4cab10..3ddcc9a07f 100644 --- a/src/Umbraco.Web/umbraco.presentation/library.cs +++ b/src/Umbraco.Web/umbraco.presentation/library.cs @@ -1147,7 +1147,7 @@ namespace umbraco { var publishedSnapshot = Current.PublishedSnapshot ?? Current.PublishedSnapshotService.CreatePublishedSnapshot(null); - contentCache = publishedSnapshot.ContentCache as PublishedContentCache; + contentCache = publishedSnapshot.Content as PublishedContentCache; } if (contentCache == null) diff --git a/src/Umbraco.Web/umbraco.presentation/page.cs b/src/Umbraco.Web/umbraco.presentation/page.cs index 8bfcd810e6..d30c23e42f 100644 --- a/src/Umbraco.Web/umbraco.presentation/page.cs +++ b/src/Umbraco.Web/umbraco.presentation/page.cs @@ -52,13 +52,13 @@ namespace umbraco /// /// Initializes a new instance of the class for a published document request. /// - /// The pointing to the document. + /// The pointing to the document. /// /// The difference between creating the page with PublishedContentRequest vs an IPublishedContent item is /// that the PublishedContentRequest takes into account how a template is assigned during the routing process whereas /// with an IPublishedContent item, the template id is asssigned purely based on the default. /// - internal page(PublishedContentRequest frequest) + internal page(PublishedRequest frequest) { if (!frequest.HasPublishedContent)