diff --git a/src/Umbraco.Tests/LibraryTests.cs b/src/Umbraco.Tests/LibraryTests.cs index 7174094e5a..ed47e27b7c 100644 --- a/src/Umbraco.Tests/LibraryTests.cs +++ b/src/Umbraco.Tests/LibraryTests.cs @@ -6,6 +6,8 @@ using System.Text; using NUnit.Framework; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using umbraco; namespace Umbraco.Tests @@ -38,9 +40,9 @@ namespace Umbraco.Tests protected override void FreezeResolution() { - //set the current umbraco context and a published content store - PublishedContentStoreResolver.Current = new PublishedContentStoreResolver( - new DefaultPublishedContentStore()); + //set the current umbraco context and a published content cache + PublishedContentCacheResolver.Current = new PublishedContentCacheResolver( + new PublishedContentCache()); base.FreezeResolution(); } diff --git a/src/Umbraco.Tests/ContentStores/PublishContentStoreTests.cs b/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs similarity index 92% rename from src/Umbraco.Tests/ContentStores/PublishContentStoreTests.cs rename to src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs index 7494c4ed30..117ed926dc 100644 --- a/src/Umbraco.Tests/ContentStores/PublishContentStoreTests.cs +++ b/src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs @@ -5,17 +5,18 @@ using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using Umbraco.Web.Routing; using umbraco.BusinessLogic; -namespace Umbraco.Tests.ContentStores +namespace Umbraco.Tests.PublishedCache { [TestFixture] public class PublishContentStoreTests { private FakeHttpContextFactory _httpContextFactory; private UmbracoContext _umbracoContext; - private DefaultPublishedContentStore _publishedContentStore; + private PublishedContentCache _cache; private string GetLegacyXml() { @@ -85,7 +86,7 @@ namespace Umbraco.Tests.ContentStores return xDoc; }; - _publishedContentStore = new DefaultPublishedContentStore(); + _cache = new PublishedContentCache(); } private void SetupForLegacy() @@ -118,7 +119,7 @@ namespace Umbraco.Tests.ContentStores [Test] public void Has_Content() { - Assert.IsTrue(_publishedContentStore.HasContent(_umbracoContext)); + Assert.IsTrue(_cache.HasContent(_umbracoContext)); } [Test] @@ -131,7 +132,7 @@ namespace Umbraco.Tests.ContentStores [Test] public void Get_Root_Docs() { - var result = _publishedContentStore.GetRootDocuments(_umbracoContext); + var result = _cache.GetAtRoot(_umbracoContext); Assert.AreEqual(2, result.Count()); Assert.AreEqual(1046, result.ElementAt(0).Id); Assert.AreEqual(1172, result.ElementAt(1).Id); @@ -158,7 +159,7 @@ namespace Umbraco.Tests.ContentStores [TestCase("/home/Sub'Apostrophe", 1177)] public void Get_Node_By_Route(string route, int nodeId) { - var result = _publishedContentStore.GetDocumentByRoute(_umbracoContext, route, false); + var result = _cache.GetByRoute(_umbracoContext, route, false); Assert.IsNotNull(result); Assert.AreEqual(nodeId, result.Id); } @@ -177,7 +178,7 @@ namespace Umbraco.Tests.ContentStores [TestCase("/Sub1", 1173)] public void Get_Node_By_Route_Hiding_Top_Level_Nodes(string route, int nodeId) { - var result = _publishedContentStore.GetDocumentByRoute(_umbracoContext, route, true); + var result = _cache.GetByRoute(_umbracoContext, route, true); Assert.IsNotNull(result); Assert.AreEqual(nodeId, result.Id); } diff --git a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs b/src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs similarity index 92% rename from src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs rename to src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs index e3ac64869a..f99747a02b 100644 --- a/src/Umbraco.Tests/ContentStores/PublishMediaStoreTests.cs +++ b/src/Umbraco.Tests/PublishedCache/PublishedMediaCacheTests.cs @@ -9,9 +9,10 @@ using Umbraco.Core.Models; using Umbraco.Tests.PublishedContent; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using umbraco.BusinessLogic; -namespace Umbraco.Tests.ContentStores +namespace Umbraco.Tests.PublishedCache { [TestFixture] public class PublishMediaStoreTests : PublishedContentTestBase @@ -40,8 +41,8 @@ namespace Umbraco.Tests.ContentStores var mChild2 = global::umbraco.cms.businesslogic.media.Media.MakeNew("Child2", mType, user, mRoot2.Id); var ctx = GetUmbracoContext("/test", 1234); - var mediaStore = new DefaultPublishedMediaStore(); - var roots = mediaStore.GetRootDocuments(ctx); + var mediaStore = new PublishedMediaCache(); + var roots = mediaStore.GetAtRoot(ctx); Assert.AreEqual(2, roots.Count()); Assert.IsTrue(roots.Select(x => x.Id).ContainsAll(new[] {mRoot1.Id, mRoot2.Id})); @@ -147,7 +148,7 @@ namespace Umbraco.Tests.ContentStores result.Fields.Add("updateDate", "2012-07-16T10:34:09"); result.Fields.Add("writerName", "Shannon"); - var store = new DefaultPublishedMediaStore(); + var store = new PublishedMediaCache(); var doc = store.ConvertFromSearchResult(result); DoAssert(doc, 1234, 0, 0, "", "Image", 0, "Shannon", "", 0, 0, "-1,1234", default(DateTime), DateTime.Parse("2012-07-16T10:34:09"), 2); @@ -159,8 +160,8 @@ namespace Umbraco.Tests.ContentStores { var xmlDoc = GetMediaXml(); var navigator = xmlDoc.SelectSingleNode("/root/Image").CreateNavigator(); - var store = new DefaultPublishedMediaStore(); - var doc = store.ConvertFromXPathNavigator(navigator); + var cache = new PublishedMediaCache(); + var doc = cache.ConvertFromXPathNavigator(navigator); DoAssert(doc, 2000, 0, 2, "image1", "Image", 2044, "Shannon", "Shannon2", 22, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1); Assert.AreEqual(null, doc.Parent); @@ -225,7 +226,7 @@ namespace Umbraco.Tests.ContentStores }; } - private DefaultPublishedMediaStore.DictionaryPublishedContent GetDictionaryDocument( + private PublishedMediaCache.DictionaryPublishedContent GetDictionaryDocument( string idKey = "id", string templateKey = "template", string nodeNameKey = "nodeName", @@ -237,11 +238,11 @@ namespace Umbraco.Tests.ContentStores { if (children == null) children = new List(); - var dicDoc = new DefaultPublishedMediaStore.DictionaryPublishedContent( + var dicDoc = new PublishedMediaCache.DictionaryPublishedContent( //the dictionary GetDictionary(idVal, parentIdVal, idKey, templateKey, nodeNameKey, nodeTypeAliasKey, pathKey), //callback to get the parent - d => new DefaultPublishedMediaStore.DictionaryPublishedContent( + d => new PublishedMediaCache.DictionaryPublishedContent( GetDictionary(parentIdVal, -1, idKey, templateKey, nodeNameKey, nodeTypeAliasKey, pathKey), //there is no parent a => null, @@ -257,7 +258,7 @@ namespace Umbraco.Tests.ContentStores } private void DoAssert( - DefaultPublishedMediaStore.DictionaryPublishedContent dicDoc, + PublishedMediaCache.DictionaryPublishedContent dicDoc, int idVal = 1234, int templateIdVal = 333, int sortOrderVal = 44, diff --git a/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs b/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs index 2540c4bf53..02a0e1a9aa 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicNodeTests.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using umbraco.MacroEngines; using umbraco.NodeFactory; using System.Linq; @@ -82,7 +83,7 @@ namespace Umbraco.Tests.PublishedContent //var template = Template.MakeNew("test", new User(0)); //var ctx = GetUmbracoContext("/test", template.Id); var ctx = GetUmbracoContext("/test", 1234); - var contentStore = new DefaultPublishedContentStore(); + var cache = new PublishedContentCache(); var node = new DynamicNode( new DynamicBackingItem( new Node(ctx.GetXml().SelectSingleNode("//*[@id='" + id + "' and @isDoc]")))); diff --git a/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs index 06570e8fee..fb39ed947b 100644 --- a/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/DynamicPublishedContentTests.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Web; using Umbraco.Web.Models; +using Umbraco.Web.PublishedCache.LegacyXmlCache; namespace Umbraco.Tests.PublishedContent { @@ -26,8 +27,8 @@ namespace Umbraco.Tests.PublishedContent //var template = Template.MakeNew("test", new User(0)); //var ctx = GetUmbracoContext("/test", template.Id); var ctx = GetUmbracoContext("/test", 1234); - var contentStore = new DefaultPublishedContentStore(); - var doc = contentStore.GetDocumentById(ctx, id); + var contentStore = new PublishedContentCache(); + var doc = contentStore.GetById(ctx, id); Assert.IsNotNull(doc); var dynamicNode = new DynamicPublishedContent(doc); Assert.IsNotNull(dynamicNode); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index 8a8532275c..6939cbb5a0 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -5,6 +5,8 @@ using Umbraco.Core.Configuration; using Umbraco.Core.PropertyEditors; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.PublishedCache.LegacyXmlCache; namespace Umbraco.Tests.PublishedContent { @@ -45,8 +47,8 @@ namespace Umbraco.Tests.PublishedContent typeof(YesNoPropertyEditorValueConverter) }); - PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore()); - PublishedMediaStoreResolver.Current = new PublishedMediaStoreResolver(new DefaultPublishedMediaStore()); + PublishedContentCacheResolver.Current = new PublishedContentCacheResolver(new PublishedContentCache()); + PublishedMediaCacheResolver.Current = new PublishedMediaCacheResolver(new PublishedMediaCache()); base.FreezeResolution(); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index d449e5f04c..7153a5225f 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -8,6 +8,7 @@ using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; namespace Umbraco.Tests.PublishedContent { @@ -81,8 +82,8 @@ namespace Umbraco.Tests.PublishedContent internal IPublishedContent GetNode(int id) { var ctx = GetUmbracoContext("/test", 1234); - var contentStore = new DefaultPublishedContentStore(); - var doc = contentStore.GetDocumentById(ctx, id); + var cache = new PublishedContentCache(); + var doc = cache.GetById(ctx, id); Assert.IsNotNull(doc); return doc; } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index 4f36d9dad8..461eb77b20 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -18,6 +18,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.UmbracoExamine; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using UmbracoExamine; using UmbracoExamine.DataServices; using umbraco.BusinessLogic; @@ -58,8 +59,8 @@ namespace Umbraco.Tests.PublishedContent internal static IPublishedContent GetNode(int id, UmbracoContext umbracoContext) { var ctx = umbracoContext; - var mediaStore = new DefaultPublishedMediaStore(); - var doc = mediaStore.GetDocumentById(ctx, id); + var mediaStore = new PublishedMediaCache(); + var doc = mediaStore.GetById(ctx, id); Assert.IsNotNull(doc); return doc; } @@ -77,12 +78,12 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); - var store = new DefaultPublishedMediaStore( + var cache = new PublishedMediaCache( searcher, indexer); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace - var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111); + var publishedMedia = cache.GetById(GetUmbracoContext("/test", 1234), 1111); var rootChildren = publishedMedia.Children().ToArray(); var currSort = 0; for (var i = 0; i < rootChildren.Count(); i++) @@ -107,11 +108,11 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); - var store = new DefaultPublishedMediaStore(searcher, indexer); + var cache = new PublishedMediaCache(searcher, indexer); var ctx = GetUmbracoContext("/test", 1234); //ensure it is found - var publishedMedia = store.GetDocumentById(ctx, 3113); + var publishedMedia = cache.GetById(ctx, 3113); Assert.IsNotNull(publishedMedia); //move item to recycle bin @@ -132,7 +133,7 @@ namespace Umbraco.Tests.PublishedContent Assert.AreEqual(1, found.TotalItemCount); //ensure it does not show up in the published media store - var recycledMedia = store.GetDocumentById(ctx, 3113); + var recycledMedia = cache.GetById(ctx, 3113); Assert.IsNull(recycledMedia); } @@ -147,16 +148,16 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); - var store = new DefaultPublishedMediaStore( + var cache = new PublishedMediaCache( searcher, indexer); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace - var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111); + var publishedMedia = cache.GetById(GetUmbracoContext("/test", 1234), 1111); var rootChildren = publishedMedia.Children(); Assert.IsTrue(rootChildren.Select(x => x.Id).ContainsAll(new[] { 2222, 1113, 1114, 1115, 1116 })); - var publishedChild1 = store.GetDocumentById(GetUmbracoContext("/test", 1234), 2222); + var publishedChild1 = cache.GetById(GetUmbracoContext("/test", 1234), 2222); var subChildren = publishedChild1.Children(); Assert.IsTrue(subChildren.Select(x => x.Id).ContainsAll(new[] { 2112 })); } @@ -170,16 +171,16 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); - var store = new DefaultPublishedMediaStore( + var cache = new PublishedMediaCache( searcher, indexer); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace - var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111); + var publishedMedia = cache.GetById(GetUmbracoContext("/test", 1234), 1111); var rootDescendants = publishedMedia.Descendants(); Assert.IsTrue(rootDescendants.Select(x => x.Id).ContainsAll(new[] { 2112, 2222, 1113, 1114, 1115, 1116 })); - var publishedChild1 = store.GetDocumentById(GetUmbracoContext("/test", 1234), 2222); + var publishedChild1 = cache.GetById(GetUmbracoContext("/test", 1234), 2222); var subDescendants = publishedChild1.Descendants(); Assert.IsTrue(subDescendants.Select(x => x.Id).ContainsAll(new[] { 2112, 3113 })); } @@ -193,16 +194,16 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); - var store = new DefaultPublishedMediaStore( + var cache = new PublishedMediaCache( searcher, indexer); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace - var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 1111); + var publishedMedia = cache.GetById(GetUmbracoContext("/test", 1234), 1111); var rootDescendants = publishedMedia.DescendantsOrSelf(); Assert.IsTrue(rootDescendants.Select(x => x.Id).ContainsAll(new[] { 1111, 2112, 2222, 1113, 1114, 1115, 1116 })); - var publishedChild1 = store.GetDocumentById(GetUmbracoContext("/test", 1234), 2222); + var publishedChild1 = cache.GetById(GetUmbracoContext("/test", 1234), 2222); var subDescendants = publishedChild1.DescendantsOrSelf(); Assert.IsTrue(subDescendants.Select(x => x.Id).ContainsAll(new[] { 2222, 2112, 3113 })); } @@ -216,12 +217,12 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); - var store = new DefaultPublishedMediaStore( + var cache = new PublishedMediaCache( IndexInitializer.GetUmbracoSearcher(luceneDir), indexer); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace - var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 3113); + var publishedMedia = cache.GetById(GetUmbracoContext("/test", 1234), 3113); var ancestors = publishedMedia.Ancestors(); Assert.IsTrue(ancestors.Select(x => x.Id).ContainsAll(new[] { 2112, 2222, 1111 })); } @@ -236,12 +237,12 @@ namespace Umbraco.Tests.PublishedContent var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); - var store = new DefaultPublishedMediaStore( + var cache = new PublishedMediaCache( IndexInitializer.GetUmbracoSearcher(luceneDir), indexer); //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace - var publishedMedia = store.GetDocumentById(GetUmbracoContext("/test", 1234), 3113); + var publishedMedia = cache.GetById(GetUmbracoContext("/test", 1234), 3113); var ancestors = publishedMedia.AncestorsOrSelf(); Assert.IsTrue(ancestors.Select(x => x.Id).ContainsAll(new[] { 3113, 2112, 2222, 1111 })); } diff --git a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs index a5ae0874fc..096c31d450 100644 --- a/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs +++ b/src/Umbraco.Tests/PublishedContent/StronglyTypedQueryTests.cs @@ -8,6 +8,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Tests.TestHelpers; using Umbraco.Web; using Umbraco.Web.Models; +using Umbraco.Web.PublishedCache.LegacyXmlCache; namespace Umbraco.Tests.PublishedContent { @@ -74,8 +75,8 @@ namespace Umbraco.Tests.PublishedContent internal IPublishedContent GetNode(int id) { var ctx = UmbracoContext.Current; - var contentStore = new DefaultPublishedContentStore(); - var doc = contentStore.GetDocumentById(ctx, id); + var contentStore = new PublishedContentCache(); + var doc = contentStore.GetById(ctx, id); Assert.IsNotNull(doc); return doc; } diff --git a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs index 8bc4f58786..b13ecf488c 100644 --- a/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs +++ b/src/Umbraco.Tests/Routing/RenderRouteHandlerTests.cs @@ -76,7 +76,7 @@ namespace Umbraco.Tests.Routing var routingContext = GetRoutingContext("~/dummy-page", template.Id, routeData); var docRequest = new PublishedContentRequest(routingContext.UmbracoContext.CleanedUmbracoUrl, routingContext) { - PublishedContent = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1174), + PublishedContent = routingContext.PublishedContentCache.GetById(routingContext.UmbracoContext, 1174), TemplateModel = template }; @@ -112,7 +112,7 @@ namespace Umbraco.Tests.Routing var routingContext = GetRoutingContext("~/dummy-page", template.Id, routeData, true); var docRequest = new PublishedContentRequest(routingContext.UmbracoContext.CleanedUmbracoUrl, routingContext) { - PublishedContent = routingContext.PublishedContentStore.GetDocumentById(routingContext.UmbracoContext, 1172), + PublishedContent = routingContext.PublishedContentCache.GetById(routingContext.UmbracoContext, 1172), TemplateModel = template }; diff --git a/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs b/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs index 52ef0a944b..46d7699bdb 100644 --- a/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs +++ b/src/Umbraco.Tests/Routing/uQueryGetNodeIdByUrlTests.cs @@ -7,6 +7,7 @@ using Umbraco.Tests.Stubs; using Umbraco.Tests.TestHelpers; using System.Configuration; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using Umbraco.Web.Routing; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.template; @@ -33,13 +34,13 @@ namespace Umbraco.Tests.Routing var t = Template.MakeNew("test", new User(0)); var umbracoContext = GetUmbracoContext(url, t.Id); - var contentStore = new DefaultPublishedContentStore(); - var urlProvider = new UrlProvider(umbracoContext, contentStore, new IUrlProvider[] { new DefaultUrlProvider() }); + var cache = new PublishedContentCache(); + var urlProvider = new UrlProvider(umbracoContext, cache, new IUrlProvider[] { new DefaultUrlProvider() }); var routingContext = new RoutingContext( umbracoContext, lookups, new FakeLastChanceFinder(), - contentStore, + cache, urlProvider, GetRoutesCache()); diff --git a/src/Umbraco.Tests/TestHelpers/BaseRoutingTest.cs b/src/Umbraco.Tests/TestHelpers/BaseRoutingTest.cs index 4968daed26..36cc8c6bf9 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseRoutingTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseRoutingTest.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Tests.Stubs; using Umbraco.Web; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using Umbraco.Web.Routing; namespace Umbraco.Tests.TestHelpers @@ -27,13 +28,13 @@ namespace Umbraco.Tests.TestHelpers protected RoutingContext GetRoutingContext(string url, int templateId, RouteData routeData = null, bool setUmbracoContextCurrent = false) { var umbracoContext = GetUmbracoContext(url, templateId, routeData); - var contentStore = new DefaultPublishedContentStore(); - var urlProvider = new UrlProvider(umbracoContext, contentStore, new IUrlProvider[] { new DefaultUrlProvider() }); + var cache = new PublishedContentCache(); + var urlProvider = new UrlProvider(umbracoContext, cache, new IUrlProvider[] { new DefaultUrlProvider() }); var routingContext = new RoutingContext( umbracoContext, Enumerable.Empty(), new FakeLastChanceFinder(), - contentStore, + cache, urlProvider, GetRoutesCache()); diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index eab3db317e..f42fc7b225 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -175,7 +175,7 @@ - + @@ -277,7 +277,7 @@ - + diff --git a/src/Umbraco.Web/ExamineExtensions.cs b/src/Umbraco.Web/ExamineExtensions.cs index 2dce84adb0..5bc305e3b4 100644 --- a/src/Umbraco.Web/ExamineExtensions.cs +++ b/src/Umbraco.Web/ExamineExtensions.cs @@ -6,6 +6,7 @@ using Examine; using Umbraco.Core.Dynamics; using Umbraco.Core.Models; using Umbraco.Web.Models; +using Umbraco.Web.PublishedCache; namespace Umbraco.Web { @@ -16,7 +17,7 @@ namespace Umbraco.Web { internal static IEnumerable ConvertSearchResultToPublishedContent( this IEnumerable results, - IPublishedStore store) + IPublishedCache contentCache) { //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, // however thsi is currently not the case: @@ -26,7 +27,7 @@ namespace Umbraco.Web foreach (var result in results.OrderByDescending(x => x.Score)) { - var doc = store.GetDocumentById( + var doc = contentCache.GetById( UmbracoContext.Current, result.Id); if (doc == null) continue; //skip if this doesn't exist in the cache diff --git a/src/Umbraco.Web/IPublishedContentStore.cs b/src/Umbraco.Web/IPublishedContentStore.cs deleted file mode 100644 index 411657e8b3..0000000000 --- a/src/Umbraco.Web/IPublishedContentStore.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Umbraco.Core.CodeAnnotations; -using Umbraco.Core.Models; - -namespace Umbraco.Web -{ - /// - /// Defines the methods to access published content - /// - [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1153", "We need to create something like the IPublishListener interface to have proper published content storage. We'll also need to publicize the resolvers so people can set a resolver at app startup.")] - internal interface IPublishedContentStore : IPublishedStore - { - IPublishedContent GetDocumentByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null); - IPublishedContent GetDocumentByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias); - bool HasContent(UmbracoContext umbracoContext); - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/IPublishedMediaStore.cs b/src/Umbraco.Web/IPublishedMediaStore.cs deleted file mode 100644 index 2e58ebc2ce..0000000000 --- a/src/Umbraco.Web/IPublishedMediaStore.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Umbraco.Core.CodeAnnotations; - -namespace Umbraco.Web -{ - /// - /// Defines the methods to access published media - /// - [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1153", "We need to create something like the IPublishListener interface to have proper published content storage. We'll also need to publicize the resolvers so people can set a resolver at app startup.")] - internal interface IPublishedMediaStore : IPublishedStore - { - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/IPublishedStore.cs b/src/Umbraco.Web/IPublishedStore.cs deleted file mode 100644 index c67dac680c..0000000000 --- a/src/Umbraco.Web/IPublishedStore.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; -using Umbraco.Core.CodeAnnotations; -using Umbraco.Core.Models; - -namespace Umbraco.Web -{ - /// - /// Defines the methods for published documents - /// - [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1153", "We need to create something like the IPublishListener interface to have proper published content storage. We'll also need to publicize the resolvers so people can set a resolver at app startup.")] - internal interface IPublishedStore - { - IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId); - IEnumerable GetRootDocuments(UmbracoContext umbracoContext); - - //TODO: SD: We should make this happen! This will allow us to natively do a GetByDocumentType query - // on the UmbracoHelper (or an internal DataContext that it uses, etc...) - // One issue is that we need to make media work as fast as we can and need to create a ConvertFromMediaObject - // method in the DefaultPublishedMediaStore, there's already a TODO noting this but in order to do that we'll - // have to also use Examine as much as we can so we don't have to make db calls for looking up things like the - // node type alias, etc... in order to populate the created IPublishedContent object. - //IEnumerable GetDocumentsByType(string docTypeAlias); - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs b/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs index 427a24f6e6..d41dd8d85f 100644 --- a/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs +++ b/src/Umbraco.Web/Mvc/RedirectToUmbracoPageResult.cs @@ -2,6 +2,7 @@ using System; using System.Web.Mvc; using Umbraco.Core; using Umbraco.Core.Models; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; namespace Umbraco.Web.Mvc @@ -45,7 +46,7 @@ namespace Umbraco.Web.Mvc if (_publishedContent != null) return _publishedContent; //need to get the URL for the page - _publishedContent = PublishedContentStoreResolver.Current.PublishedContentStore.GetDocumentById(_umbracoContext, _pageId); + _publishedContent = PublishedContentCacheResolver.Current.PublishedContentCache.GetById(_umbracoContext, _pageId); return _publishedContent; } diff --git a/src/Umbraco.Web/PublishedCache/IPublishedCache.cs b/src/Umbraco.Web/PublishedCache/IPublishedCache.cs new file mode 100644 index 0000000000..9efd785ec1 --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/IPublishedCache.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Umbraco.Core.CodeAnnotations; +using Umbraco.Core.Models; +using Umbraco.Core.Xml; + +namespace Umbraco.Web.PublishedCache +{ + /// + /// Defines the methods for published documents + /// + [UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1153", + "We need to create something like the IPublishListener interface to have proper published content storage.")] + internal interface IPublishedCache + { + // FIXME do we need the context here?! + // FIXME write documentation + + IPublishedContent GetById(UmbracoContext umbracoContext, int nodeId); + IEnumerable GetAtRoot(UmbracoContext umbracoContext); + + IPublishedContent GetSingleByXPath(UmbracoContext umbracoContext, string xpath, XPathVariable[] vars); + IEnumerable GetByXPath(UmbracoContext umbracoContext, string xpath, XPathVariable[] vars); + + // ... GetXPath single or multi + // ... pass the helper and NOT the store, so we're consistent?! + + //TODO: SD: We should make this happen! This will allow us to natively do a GetByDocumentType query + // on the UmbracoHelper (or an internal DataContext that it uses, etc...) + // One issue is that we need to make media work as fast as we can and need to create a ConvertFromMediaObject + // method in the DefaultPublishedMediaStore, there's already a TODO noting this but in order to do that we'll + // have to also use Examine as much as we can so we don't have to make db calls for looking up things like the + // node type alias, etc... in order to populate the created IPublishedContent object. + //IEnumerable GetDocumentsByType(string docTypeAlias); + } +} diff --git a/src/Umbraco.Web/PublishedCache/IPublishedContentCache.cs b/src/Umbraco.Web/PublishedCache/IPublishedContentCache.cs new file mode 100644 index 0000000000..9e00068b3b --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/IPublishedContentCache.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Umbraco.Core.Models; + +namespace Umbraco.Web.PublishedCache +{ + internal interface IPublishedContentCache : IPublishedCache + { + // do we want that one? + IPublishedContent GetByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null); + // do we want that one? + IPublishedContent GetByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias); + + // vs. having a GetDocumentByXPath ?! + + // do we want to get-by-xpath? + + bool HasContent(UmbracoContext umbracoContext); + } +} diff --git a/src/Umbraco.Web/PublishedCache/IPublishedMediaCache.cs b/src/Umbraco.Web/PublishedCache/IPublishedMediaCache.cs new file mode 100644 index 0000000000..fccc661b22 --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/IPublishedMediaCache.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Umbraco.Web.PublishedCache +{ + internal interface IPublishedMediaCache : IPublishedCache + { + } +} diff --git a/src/Umbraco.Web/DefaultPublishedContentStore.cs b/src/Umbraco.Web/PublishedCache/LegacyXmlCache/PublishedContentCache.cs similarity index 67% rename from src/Umbraco.Web/DefaultPublishedContentStore.cs rename to src/Umbraco.Web/PublishedCache/LegacyXmlCache/PublishedContentCache.cs index 5a86d3c6c6..f6d44bf544 100644 --- a/src/Umbraco.Web/DefaultPublishedContentStore.cs +++ b/src/Umbraco.Web/PublishedCache/LegacyXmlCache/PublishedContentCache.cs @@ -2,21 +2,14 @@ using System; using System.Collections.Generic; using System.Text; using System.Xml; -using System.Xml.Linq; using Umbraco.Core.Models; using Umbraco.Core.Xml; -using Umbraco.Web.Routing; using umbraco; -using umbraco.NodeFactory; -using umbraco.interfaces; using System.Linq; -namespace Umbraco.Web +namespace Umbraco.Web.PublishedCache.LegacyXmlCache { - /// - /// An IPublishedContentStore which uses the Xml cache system to return data - /// - internal class DefaultPublishedContentStore : IPublishedContentStore + internal class PublishedContentCache : IPublishedContentCache { #region XPath Strings @@ -24,7 +17,7 @@ namespace Umbraco.Web { public int Version { get; private set; } - public string Root { get { return "/root"; } } + public static string Root { get { return "/root"; } } public string RootDocuments { get; private set; } public string DescendantDocumentById { get; private set; } public string DescendantDocumentByAlias { get; private set; } @@ -70,7 +63,7 @@ namespace Umbraco.Web } } - static XPathStringsDefinition XPathStringsValue = null; + static XPathStringsDefinition _xPathStringsValue; static XPathStringsDefinition XPathStrings { get @@ -80,36 +73,65 @@ namespace Umbraco.Web // that switch schemas fail - so cache and refresh when needed, // ie never when running the actual site - int version = UmbracoSettings.UseLegacyXmlSchema ? 0 : 1; - if (XPathStringsValue == null || XPathStringsValue.Version != version) - XPathStringsValue = new XPathStringsDefinition(version); - return XPathStringsValue; + var version = UmbracoSettings.UseLegacyXmlSchema ? 0 : 1; + if (_xPathStringsValue == null || _xPathStringsValue.Version != version) + _xPathStringsValue = new XPathStringsDefinition(version); + return _xPathStringsValue; } } #endregion - private IPublishedContent ConvertToDocument(XmlNode xmlNode) + private static IPublishedContent ConvertToDocument(XmlNode xmlNode) { - if (xmlNode == null) - return null; + return xmlNode == null ? null : new Models.XmlPublishedContent(xmlNode); + } - return new Models.XmlPublishedContent(xmlNode); - } + private static IEnumerable ConvertToDocuments(XmlNodeList xmlNodes) + { + return xmlNodes.Cast().Select(xmlNode => new Models.XmlPublishedContent(xmlNode)); + } - public virtual IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId) + public virtual IPublishedContent GetById(UmbracoContext umbracoContext, int nodeId) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); return ConvertToDocument(GetXml(umbracoContext).GetElementById(nodeId.ToString())); } - public IEnumerable GetRootDocuments(UmbracoContext umbracoContext) + public IEnumerable GetAtRoot(UmbracoContext umbracoContext) { return (from XmlNode x in GetXml(umbracoContext).SelectNodes(XPathStrings.RootDocuments) select ConvertToDocument(x)).ToList(); } - public IPublishedContent GetDocumentByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null) + public IPublishedContent GetSingleByXPath(UmbracoContext umbracoContext, string xpath, params XPathVariable[] vars) + { + if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); + if (xpath == null) throw new ArgumentNullException("xpath"); + if (string.IsNullOrWhiteSpace(xpath)) return null; + + var xml = GetXml(umbracoContext); + var node = vars == null + ? xml.SelectSingleNode(xpath) + : xml.SelectSingleNode(xpath, vars); + return ConvertToDocument(node); + } + + public IEnumerable GetByXPath(UmbracoContext umbracoContext, string xpath, params XPathVariable[] vars) + { + if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); + if (xpath == null) throw new ArgumentNullException("xpath"); + if (string.IsNullOrWhiteSpace(xpath)) return Enumerable.Empty(); + + var xml = GetXml(umbracoContext); + var nodes = vars == null + ? xml.SelectNodes(xpath) + : xml.SelectNodes(xpath, vars); + return ConvertToDocuments(nodes); + } + + //FIXME keep here or remove? + public IPublishedContent GetByRoute(UmbracoContext umbracoContext, string route, bool? hideTopLevelNode = null) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); if (route == null) throw new ArgumentNullException("route"); @@ -120,29 +142,30 @@ namespace Umbraco.Web //the route always needs to be lower case because we only store the urlName attribute in lower case route = route.ToLowerInvariant(); - int pos = route.IndexOf('/'); - string path = pos == 0 ? route : route.Substring(pos); - int startNodeId = pos == 0 ? 0 : int.Parse(route.Substring(0, pos)); + var pos = route.IndexOf('/'); + var path = pos == 0 ? route : route.Substring(pos); + var startNodeId = pos == 0 ? 0 : int.Parse(route.Substring(0, pos)); IEnumerable vars; var xpath = CreateXpathQuery(startNodeId, path, hideTopLevelNode.Value, out vars); //check if we can find the node in our xml cache - var found = GetXml(umbracoContext).SelectSingleNode(xpath, vars); + var content = GetSingleByXPath(umbracoContext, xpath, vars == null ? null : vars.ToArray()); // if hideTopLevelNodePath is true then for url /foo we looked for /*/foo // but maybe that was the url of a non-default top-level node, so we also // have to look for /foo (see note in NiceUrlProvider). - if (found == null && hideTopLevelNode.Value && path.Length > 1 && path.IndexOf('/', 1) < 0) + if (content == null && hideTopLevelNode.Value && path.Length > 1 && path.IndexOf('/', 1) < 0) { xpath = CreateXpathQuery(startNodeId, path, false, out vars); - found = GetXml(umbracoContext).SelectSingleNode(xpath, vars); + content = GetSingleByXPath(umbracoContext, xpath, vars == null ? null : vars.ToArray()); } - return ConvertToDocument(found); + return content; } - public IPublishedContent GetDocumentByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias) + // FIXME MOVE THAT ONE OUT OF HERE? + public IPublishedContent GetByUrlAlias(UmbracoContext umbracoContext, int rootNodeId, string alias) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); if (alias == null) throw new ArgumentNullException("alias"); @@ -153,7 +176,7 @@ namespace Umbraco.Web alias = alias.TrimStart('/'); var xpathBuilder = new StringBuilder(); - xpathBuilder.Append(XPathStrings.Root); + xpathBuilder.Append(XPathStringsDefinition.Root); if (rootNodeId > 0) xpathBuilder.AppendFormat(XPathStrings.DescendantDocumentById, rootNodeId); @@ -169,7 +192,7 @@ namespace Umbraco.Web var xpath = xpathBuilder.ToString(); - return ConvertToDocument(GetXml(umbracoContext).SelectSingleNode(xpath, var)); + return GetSingleByXPath(umbracoContext, xpath, var); } public bool HasContent(UmbracoContext umbracoContext) @@ -181,14 +204,14 @@ namespace Umbraco.Web return node != null; } - XmlDocument GetXml(UmbracoContext umbracoContext) + static XmlDocument GetXml(UmbracoContext umbracoContext) { if (umbracoContext == null) throw new ArgumentNullException("umbracoContext"); return umbracoContext.GetXml(); } - static readonly char[] SlashChar = new char[] { '/' }; + static readonly char[] SlashChar = new[] { '/' }; protected string CreateXpathQuery(int startNodeId, string path, bool hideTopLevelNodeFromPath, out IEnumerable vars) { @@ -201,7 +224,7 @@ namespace Umbraco.Web if (startNodeId > 0) { // if in a domain then use the root node of the domain - xpath = string.Format(XPathStrings.Root + XPathStrings.DescendantDocumentById, startNodeId); + xpath = string.Format(XPathStringsDefinition.Root + XPathStrings.DescendantDocumentById, startNodeId); } else { @@ -234,11 +257,11 @@ namespace Umbraco.Web if (hideTopLevelNodeFromPath) xpathBuilder.Append(XPathStrings.RootDocuments); // first node is not in the url else - xpathBuilder.Append(XPathStrings.Root); + xpathBuilder.Append(XPathStringsDefinition.Root); } else { - xpathBuilder.AppendFormat(XPathStrings.Root + XPathStrings.DescendantDocumentById, startNodeId); + xpathBuilder.AppendFormat(XPathStringsDefinition.Root + XPathStrings.DescendantDocumentById, startNodeId); // always "hide top level" when there's a domain } diff --git a/src/Umbraco.Web/DefaultPublishedMediaStore.cs b/src/Umbraco.Web/PublishedCache/LegacyXmlCache/PublishedMediaCache.cs similarity index 92% rename from src/Umbraco.Web/DefaultPublishedMediaStore.cs rename to src/Umbraco.Web/PublishedCache/LegacyXmlCache/PublishedMediaCache.cs index 5ed98f9591..cb4bed448c 100644 --- a/src/Umbraco.Web/DefaultPublishedMediaStore.cs +++ b/src/Umbraco.Web/PublishedCache/LegacyXmlCache/PublishedMediaCache.cs @@ -12,13 +12,14 @@ using Umbraco.Core; using Umbraco.Core.Dynamics; using Umbraco.Core.Logging; using Umbraco.Core.Models; +using Umbraco.Core.Xml; using Umbraco.Web.Models; using UmbracoExamine; using umbraco; using umbraco.cms.businesslogic; using ContentType = umbraco.cms.businesslogic.ContentType; -namespace Umbraco.Web +namespace Umbraco.Web.PublishedCache.LegacyXmlCache { /// /// An IPublishedMediaStore that first checks for the media in Examine, and then reverts to the database @@ -26,10 +27,10 @@ namespace Umbraco.Web /// /// NOTE: In the future if we want to properly cache all media this class can be extended or replaced when these classes/interfaces are exposed publicly. /// - internal class DefaultPublishedMediaStore : IPublishedMediaStore + internal class PublishedMediaCache : IPublishedMediaCache { - public DefaultPublishedMediaStore() + public PublishedMediaCache() { } @@ -38,7 +39,7 @@ namespace Umbraco.Web /// /// /// - internal DefaultPublishedMediaStore(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider) + internal PublishedMediaCache(BaseSearchProvider searchProvider, BaseIndexProvider indexProvider) { _searchProvider = searchProvider; _indexProvider = indexProvider; @@ -47,12 +48,12 @@ namespace Umbraco.Web private readonly BaseSearchProvider _searchProvider; private readonly BaseIndexProvider _indexProvider; - public virtual IPublishedContent GetDocumentById(UmbracoContext umbracoContext, int nodeId) + public virtual IPublishedContent GetById(UmbracoContext umbracoContext, int nodeId) { return GetUmbracoMedia(nodeId); } - public IEnumerable GetRootDocuments(UmbracoContext umbracoContext) + public IEnumerable GetAtRoot(UmbracoContext umbracoContext) { var rootMedia = global::umbraco.cms.businesslogic.media.Media.GetRootMedias(); var result = new List(); @@ -67,7 +68,17 @@ namespace Umbraco.Web return result; } - private ExamineManager GetExamineManagerSafe() + public IPublishedContent GetSingleByXPath(UmbracoContext umbracoContext, string xpath, XPathVariable[] vars) + { + throw new NotImplementedException("PublishedMediaCache does not support XPath queries."); + } + + public IEnumerable GetByXPath(UmbracoContext umbracoContext, string xpath, XPathVariable[] vars) + { + throw new NotImplementedException("PublishedMediaCache does not support XPath queries."); + } + + private ExamineManager GetExamineManagerSafe() { try { @@ -94,7 +105,7 @@ namespace Umbraco.Web } catch (Exception ex) { - LogHelper.Error("Could not retreive the InternalIndexer", ex); + LogHelper.Error("Could not retreive the InternalIndexer", ex); //something didn't work, continue returning null. } } diff --git a/src/Umbraco.Web/PublishedCache/PublishedContentCacheResolver.cs b/src/Umbraco.Web/PublishedCache/PublishedContentCacheResolver.cs new file mode 100644 index 0000000000..5c02f75216 --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/PublishedContentCacheResolver.cs @@ -0,0 +1,37 @@ +using Umbraco.Core.ObjectResolution; + +namespace Umbraco.Web.PublishedCache +{ + /// + /// Resolves the IPublishedContentCache object. + /// + internal sealed class PublishedContentCacheResolver : SingleObjectResolverBase + { + /// + /// Initializes a new instance of the class with a content cache. + /// + /// The content cache. + /// The resolver is created by the WebBootManager and thus the constructor remains internal. + internal PublishedContentCacheResolver(IPublishedContentCache publishedContentCache) + : base(publishedContentCache) + { } + + /// + /// Sets the content cache. + /// + /// The content cache. + /// For developers, at application startup. + public void SetContentStore(IPublishedContentCache publishedContentCache) + { + Value = publishedContentCache; + } + + /// + /// Gets the content cache. + /// + public IPublishedContentCache PublishedContentCache + { + get { return Value; } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/PublishedCache/PublishedMediaCacheResolver.cs b/src/Umbraco.Web/PublishedCache/PublishedMediaCacheResolver.cs new file mode 100644 index 0000000000..a3a0d47fb6 --- /dev/null +++ b/src/Umbraco.Web/PublishedCache/PublishedMediaCacheResolver.cs @@ -0,0 +1,37 @@ +using Umbraco.Core.ObjectResolution; + +namespace Umbraco.Web.PublishedCache +{ + /// + /// Resolves the IPublicMediaCache object. + /// + internal sealed class PublishedMediaCacheResolver : SingleObjectResolverBase + { + /// + /// Initializes a new instance of the class with a media cache. + /// + /// The media cache. + /// The resolver is created by the WebBootManager and thus the constructor remains internal. + internal PublishedMediaCacheResolver(IPublishedMediaCache publishedMediaCache) + : base(publishedMediaCache) + { } + + /// + /// Sets the media cache. + /// + /// The media cache. + /// For developers, at application startup. + public void SetContentCache(IPublishedMediaCache publishedMediaCache) + { + Value = publishedMediaCache; + } + + /// + /// Gets the media cache. + /// + public IPublishedMediaCache PublishedMediaCache + { + get { return Value; } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 5815e7817a..fa89ab3bd7 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -9,6 +9,7 @@ using Examine.LuceneEngine.SearchCriteria; using Umbraco.Core.Dynamics; using Umbraco.Core.Models; using Umbraco.Web.Models; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.Templates; using umbraco; @@ -269,7 +270,7 @@ namespace Umbraco.Web s = searchProvider; var results = s.Search(criteria); - return results.ConvertSearchResultToPublishedContent(PublishedContentStoreResolver.Current.PublishedContentStore); + return results.ConvertSearchResultToPublishedContent(PublishedContentCacheResolver.Current.PublishedContentCache); } #endregion @@ -1127,7 +1128,7 @@ namespace Umbraco.Web { //get the root docs if parent is null return content.Parent == null - ? PublishedContentStoreResolver.Current.PublishedContentStore.GetRootDocuments(UmbracoContext.Current) + ? PublishedContentCacheResolver.Current.PublishedContentCache.GetAtRoot(UmbracoContext.Current) : content.Parent.Children; } diff --git a/src/Umbraco.Web/PublishedContentStoreResolver.cs b/src/Umbraco.Web/PublishedContentStoreResolver.cs deleted file mode 100644 index 2ba6eb0ef1..0000000000 --- a/src/Umbraco.Web/PublishedContentStoreResolver.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Umbraco.Core.ObjectResolution; - -namespace Umbraco.Web -{ - /// - /// An object resolver to return the IPublishedContentStore - /// - internal sealed class PublishedContentStoreResolver : SingleObjectResolverBase - { - internal PublishedContentStoreResolver(IPublishedContentStore publishedContentStore) - : base(publishedContentStore) - { - } - - /// - /// Can be used by developers at runtime to set their IContentStore at app startup - /// - /// - public void SetContentStore(IPublishedContentStore publishedContentStore) - { - Value = publishedContentStore; - } - - /// - /// Returns the IContentStore - /// - public IPublishedContentStore PublishedContentStore - { - get { return Value; } - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/PublishedMediaStoreResolver.cs b/src/Umbraco.Web/PublishedMediaStoreResolver.cs deleted file mode 100644 index 6f741b3796..0000000000 --- a/src/Umbraco.Web/PublishedMediaStoreResolver.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Umbraco.Core.ObjectResolution; - -namespace Umbraco.Web -{ - /// - /// An object resolver to return the IPublishedMediaStore - /// - internal sealed class PublishedMediaStoreResolver : SingleObjectResolverBase - { - internal PublishedMediaStoreResolver(IPublishedMediaStore publishedMediaStore) - : base(publishedMediaStore) - { - } - - /// - /// Can be used by developers at runtime to set their IContentStore at app startup - /// - /// - public void SetContentStore(IPublishedMediaStore publishedMediaStore) - { - Value = publishedMediaStore; - } - - /// - /// Returns the IContentStore - /// - public IPublishedMediaStore PublishedMediaStore - { - get { return Value; } - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/Routing/AliasUrlProvider.cs b/src/Umbraco.Web/Routing/AliasUrlProvider.cs index 43aa4d1060..16df5293ee 100644 --- a/src/Umbraco.Web/Routing/AliasUrlProvider.cs +++ b/src/Umbraco.Web/Routing/AliasUrlProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Umbraco.Core; +using Umbraco.Web.PublishedCache; namespace Umbraco.Web.Routing { @@ -30,7 +31,7 @@ namespace Umbraco.Web.Routing /// absolute is true, in which case the url is always absolute. /// If the provider is unable to provide a url, it should return null. /// - public string GetUrl(UmbracoContext umbracoContext, IPublishedContentStore contentCache, int id, Uri current, UrlProviderMode mode) + public string GetUrl(UmbracoContext umbracoContext, IPublishedContentCache contentCache, int id, Uri current, UrlProviderMode mode) { return null; // we have nothing to say } @@ -51,12 +52,12 @@ namespace Umbraco.Web.Routing /// Other urls are those that GetUrl would not return in the current context, but would be valid /// urls for the node in other contexts (different domain for current request, umbracoUrlAlias...). /// - public IEnumerable GetOtherUrls(UmbracoContext umbracoContext, IPublishedContentStore contentCache, int id, Uri current) + public IEnumerable GetOtherUrls(UmbracoContext umbracoContext, IPublishedContentCache contentCache, int id, Uri current) { if (!FindByUrlAliasEnabled) return Enumerable.Empty(); // we have nothing to say - var node = contentCache.GetDocumentById(umbracoContext, id); + var node = contentCache.GetById(umbracoContext, id); string umbracoUrlName = null; if (node.HasProperty(Constants.Conventions.Content.UrlAlias)) umbracoUrlName = node.GetPropertyValue(Constants.Conventions.Content.UrlAlias); diff --git a/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs b/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs index 8a7e5f4b31..57f0dd9d89 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByIdPath.cs @@ -34,7 +34,7 @@ namespace Umbraco.Web.Routing if (nodeId > 0) { LogHelper.Debug("Id={0}", () => nodeId); - node = docRequest.RoutingContext.PublishedContentStore.GetDocumentById( + node = docRequest.RoutingContext.PublishedContentCache.GetById( docRequest.RoutingContext.UmbracoContext, nodeId); diff --git a/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs b/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs index 8dc538ee15..653cfa702b 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByLegacy404.cs @@ -27,7 +27,7 @@ namespace Umbraco.Web.Routing { LogHelper.Debug("Got id={0}.", () => id); - content = pcr.RoutingContext.PublishedContentStore.GetDocumentById( + content = pcr.RoutingContext.PublishedContentCache.GetById( pcr.RoutingContext.UmbracoContext, id); diff --git a/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs b/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs index 0dbca210e5..427bb4500b 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByNiceUrl.cs @@ -66,7 +66,7 @@ namespace Umbraco.Web.Routing IPublishedContent node = null; if (nodeId > 0) { - node = docreq.RoutingContext.PublishedContentStore.GetDocumentById( + node = docreq.RoutingContext.PublishedContentCache.GetById( docreq.RoutingContext.UmbracoContext, nodeId); @@ -85,7 +85,7 @@ namespace Umbraco.Web.Routing if (node == null) { LogHelper.Debug("Cache miss, query"); - node = docreq.RoutingContext.PublishedContentStore.GetDocumentByRoute( + node = docreq.RoutingContext.PublishedContentCache.GetByRoute( docreq.RoutingContext.UmbracoContext, route); diff --git a/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandler.cs b/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandler.cs index 2d120dfd9c..3b824825e7 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandler.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandler.cs @@ -30,7 +30,7 @@ namespace Umbraco.Web.Routing { LogHelper.Debug>("Handler '{0}' returned id={1}.", () => type.FullName, () => handler.redirectID); - var content = pcr.RoutingContext.PublishedContentStore.GetDocumentById( + var content = pcr.RoutingContext.PublishedContentCache.GetById( pcr.RoutingContext.UmbracoContext, handler.redirectID); diff --git a/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandlers.cs b/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandlers.cs index 5826b6676b..ee64578e5e 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandlers.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByNotFoundHandlers.cs @@ -76,7 +76,7 @@ namespace Umbraco.Web.Routing if (handler.Execute(url) && handler.redirectID > 0) { var redirectId = handler.redirectID; - docRequest.PublishedContent = docRequest.RoutingContext.PublishedContentStore.GetDocumentById( + docRequest.PublishedContent = docRequest.RoutingContext.PublishedContentCache.GetById( docRequest.RoutingContext.UmbracoContext, redirectId); diff --git a/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs b/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs index 51f9b16a31..a6cb2da50c 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByPageIdQuery.cs @@ -14,7 +14,7 @@ namespace Umbraco.Web.Routing int pageId; if (int.TryParse(docRequest.RoutingContext.UmbracoContext.HttpContext.Request["umbPageID"], out pageId)) { - var doc = docRequest.RoutingContext.PublishedContentStore.GetDocumentById( + var doc = docRequest.RoutingContext.PublishedContentCache.GetById( docRequest.RoutingContext.UmbracoContext, pageId); diff --git a/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs b/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs index 5a2d470e52..67422da605 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs @@ -24,7 +24,7 @@ namespace Umbraco.Web.Routing if (docRequest.Uri.AbsolutePath != "/") // no alias if "/" { - node = docRequest.RoutingContext.PublishedContentStore.GetDocumentByUrlAlias( + node = docRequest.RoutingContext.PublishedContentCache.GetByUrlAlias( docRequest.RoutingContext.UmbracoContext, docRequest.HasDomain ? docRequest.Domain.RootNodeId : 0, docRequest.Uri.GetAbsolutePathDecoded()); diff --git a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs index 9b762e328c..0d853413f3 100644 --- a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs +++ b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs @@ -5,6 +5,7 @@ using System.Threading; using Umbraco.Core; using Umbraco.Core.Logging; +using Umbraco.Web.PublishedCache; using umbraco.cms.businesslogic.web; namespace Umbraco.Web.Routing @@ -29,7 +30,7 @@ namespace Umbraco.Web.Routing /// The url is absolute or relative depending on mode and on current. /// If the provider is unable to provide a url, it should return null. /// - public virtual string GetUrl(UmbracoContext umbracoContext, IPublishedContentStore contentCache, int id, Uri current, UrlProviderMode mode) + public virtual string GetUrl(UmbracoContext umbracoContext, IPublishedContentCache contentCache, int id, Uri current, UrlProviderMode mode) { DomainAndUri domainUri; string path; @@ -55,7 +56,7 @@ namespace Umbraco.Web.Routing else { // there was no route in the cache - create a route - var node = contentCache.GetDocumentById(umbracoContext, id); + var node = contentCache.GetById(umbracoContext, id); if (node == null) { LogHelper.Warn( @@ -115,7 +116,7 @@ namespace Umbraco.Web.Routing /// Other urls are those that GetUrl would not return in the current context, but would be valid /// urls for the node in other contexts (different domain for current request, umbracoUrlAlias...). /// - public virtual IEnumerable GetOtherUrls(UmbracoContext umbracoContext, IPublishedContentStore contentCache, int id, Uri current) + public virtual IEnumerable GetOtherUrls(UmbracoContext umbracoContext, IPublishedContentCache contentCache, int id, Uri current) { string path; IEnumerable domainUris; @@ -136,7 +137,7 @@ namespace Umbraco.Web.Routing else { // there was no route in the cache - create a route - var node = contentCache.GetDocumentById(umbracoContext, id); + var node = contentCache.GetById(umbracoContext, id); if (node == null) { LogHelper.Warn( @@ -272,7 +273,7 @@ namespace Umbraco.Web.Routing return uris.Select(UriUtility.UriFromUmbraco); } - static void ApplyHideTopLevelNodeFromPath(UmbracoContext umbracoContext, IPublishedContentStore contentCache, Core.Models.IPublishedContent node, IList pathParts) + static void ApplyHideTopLevelNodeFromPath(UmbracoContext umbracoContext, IPublishedContentCache contentCache, Core.Models.IPublishedContent node, IList pathParts) { // in theory if hideTopLevelNodeFromPath is true, then there should be only once // top-level node, or else domains should be assigned. but for backward compatibility @@ -284,7 +285,7 @@ namespace Umbraco.Web.Routing // that's the way it works pre-4.10 and we try to be backward compat for the time being if (node.Parent == null) { - var rootNode = contentCache.GetDocumentByRoute(umbracoContext, "/", true); + var rootNode = contentCache.GetByRoute(umbracoContext, "/", true); if (rootNode.Id == node.Id) // remove only if we're the default node pathParts.RemoveAt(pathParts.Count - 1); } diff --git a/src/Umbraco.Web/Routing/IUrlProvider.cs b/src/Umbraco.Web/Routing/IUrlProvider.cs index 7cd0924654..bbde44363d 100644 --- a/src/Umbraco.Web/Routing/IUrlProvider.cs +++ b/src/Umbraco.Web/Routing/IUrlProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Umbraco.Web.PublishedCache; namespace Umbraco.Web.Routing { @@ -21,7 +22,7 @@ namespace Umbraco.Web.Routing /// The url is absolute or relative depending on mode and on current. /// If the provider is unable to provide a url, it should return null. /// - string GetUrl(UmbracoContext umbracoContext, IPublishedContentStore contentCache, int id, Uri current, UrlProviderMode mode); + string GetUrl(UmbracoContext umbracoContext, IPublishedContentCache contentCache, int id, Uri current, UrlProviderMode mode); /// /// Gets the other urls of a published content. @@ -35,6 +36,6 @@ namespace Umbraco.Web.Routing /// Other urls are those that GetUrl would not return in the current context, but would be valid /// urls for the node in other contexts (different domain for current request, umbracoUrlAlias...). /// - IEnumerable GetOtherUrls(UmbracoContext umbracoContext, IPublishedContentStore contentCache, int id, Uri current); + IEnumerable GetOtherUrls(UmbracoContext umbracoContext, IPublishedContentCache contentCache, int id, Uri current); } } diff --git a/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs b/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs index 2d937e3206..ca6ef63818 100644 --- a/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs +++ b/src/Umbraco.Web/Routing/PublishedContentRequestEngine.cs @@ -444,7 +444,7 @@ namespace Umbraco.Web.Routing else { // redirect to another page - var node = _routingContext.PublishedContentStore.GetDocumentById(_routingContext.UmbracoContext, internalRedirectId); + var node = _routingContext.PublishedContentCache.GetById(_routingContext.UmbracoContext, internalRedirectId); _pcr.SetInternalRedirectPublishedContent(node); // don't use .PublishedContent here if (node != null) @@ -494,14 +494,14 @@ namespace Umbraco.Web.Routing LogHelper.Debug("{0}Not logged in, redirect to login page", () => tracePrefix); var loginPageId = Access.GetLoginPage(path); if (loginPageId != _pcr.PublishedContent.Id) - _pcr.PublishedContent = _routingContext.PublishedContentStore.GetDocumentById(_routingContext.UmbracoContext, loginPageId); + _pcr.PublishedContent = _routingContext.PublishedContentCache.GetById(_routingContext.UmbracoContext, loginPageId); } else if (!Access.HasAccces(_pcr.PublishedContent.Id, user.ProviderUserKey)) { LogHelper.Debug("{0}Current member has not access, redirect to error page", () => tracePrefix); var errorPageId = Access.GetErrorPage(path); if (errorPageId != _pcr.PublishedContent.Id) - _pcr.PublishedContent = _routingContext.PublishedContentStore.GetDocumentById(_routingContext.UmbracoContext, errorPageId); + _pcr.PublishedContent = _routingContext.PublishedContentCache.GetById(_routingContext.UmbracoContext, errorPageId); } else { diff --git a/src/Umbraco.Web/Routing/RoutingContext.cs b/src/Umbraco.Web/Routing/RoutingContext.cs index af6eff62b5..25d776d21b 100644 --- a/src/Umbraco.Web/Routing/RoutingContext.cs +++ b/src/Umbraco.Web/Routing/RoutingContext.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Web.PublishedCache; namespace Umbraco.Web.Routing { @@ -14,21 +15,21 @@ namespace Umbraco.Web.Routing /// /// The document lookups resolver. /// - /// The content store. + /// The content store. /// The nice urls provider. /// The routes cache. internal RoutingContext( UmbracoContext umbracoContext, IEnumerable contentFinders, IContentFinder contentLastChanceFinder, - IPublishedContentStore publishedContentStore, + IPublishedContentCache contentCache, UrlProvider urlProvider, IRoutesCache routesCache) { UmbracoContext = umbracoContext; PublishedContentFinders = contentFinders; PublishedContentLastChanceFinder = contentLastChanceFinder; - PublishedContentStore = publishedContentStore; + PublishedContentCache = contentCache; UrlProvider = urlProvider; RoutesCache = routesCache; } @@ -49,9 +50,9 @@ namespace Umbraco.Web.Routing internal IContentFinder PublishedContentLastChanceFinder { get; private set; } /// - /// Gets the content store. + /// Gets the published content cache. /// - internal IPublishedContentStore PublishedContentStore { get; private set; } + internal IPublishedContentCache PublishedContentCache { get; private set; } /// /// Gets the urls provider. diff --git a/src/Umbraco.Web/Routing/UrlProvider.cs b/src/Umbraco.Web/Routing/UrlProvider.cs index ba71e4f31c..11a871e4b0 100644 --- a/src/Umbraco.Web/Routing/UrlProvider.cs +++ b/src/Umbraco.Web/Routing/UrlProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Umbraco.Core.Configuration; +using Umbraco.Web.PublishedCache; namespace Umbraco.Web.Routing { @@ -18,7 +19,7 @@ namespace Umbraco.Web.Routing /// The Umbraco context. /// The content cache. /// The list of url providers. - public UrlProvider(UmbracoContext umbracoContext, IPublishedContentStore contentCache, + public UrlProvider(UmbracoContext umbracoContext, IPublishedContentCache contentCache, IEnumerable urlProviders) { _umbracoContext = umbracoContext; @@ -28,7 +29,7 @@ namespace Umbraco.Web.Routing } private readonly UmbracoContext _umbracoContext; - private readonly IPublishedContentStore _contentCache; + private readonly IPublishedContentCache _contentCache; private readonly IEnumerable _urlProviders; /// diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs index 92704c8c50..cc7dc97164 100644 --- a/src/Umbraco.Web/Templates/TemplateRenderer.cs +++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs @@ -53,8 +53,8 @@ namespace Umbraco.Web.Templates // important to use CleanedUmbracoUrl - lowercase path-only version of the current url, though this isn't going to matter // terribly much for this implementation since we are just creating a doc content request to modify it's properties manually. var contentRequest = new PublishedContentRequest(_umbracoContext.CleanedUmbracoUrl, _umbracoContext.RoutingContext); - - var doc = contentRequest.RoutingContext.PublishedContentStore.GetDocumentById( + + var doc = contentRequest.RoutingContext.PublishedContentCache.GetById( contentRequest.RoutingContext.UmbracoContext, PageId); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 6a42c15783..d26d3a4f49 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -320,7 +320,7 @@ - + @@ -348,14 +348,17 @@ + + + + + ASPXCodeBehind - - @@ -386,7 +389,6 @@ - @@ -542,10 +544,8 @@ - - + - diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index ea6ea718bf..e9dc7f1b31 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -3,6 +3,7 @@ using System.Web; using Umbraco.Core; using Umbraco.Core.Services; using Umbraco.Core.CodeAnnotations; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using umbraco; using umbraco.IO; @@ -87,7 +88,7 @@ namespace Umbraco.Web // there's one per request because there are some behavior parameters that can be changed var urlProvider = new UrlProvider( umbracoContext, - PublishedContentStoreResolver.Current.PublishedContentStore, + PublishedContentCacheResolver.Current.PublishedContentCache, UrlProviderResolver.Current.Providers); // create the RoutingContext, and assign @@ -95,7 +96,7 @@ namespace Umbraco.Web umbracoContext, ContentFinderResolver.Current.Finders, ContentLastChanceFinderResolver.Current.Finder, - PublishedContentStoreResolver.Current.PublishedContentStore, + PublishedContentCacheResolver.Current.PublishedContentCache, urlProvider, RoutesCacheResolver.Current.RoutesCache); diff --git a/src/Umbraco.Web/UmbracoHelper.cs b/src/Umbraco.Web/UmbracoHelper.cs index da51f57184..7c98071d0e 100644 --- a/src/Umbraco.Web/UmbracoHelper.cs +++ b/src/Umbraco.Web/UmbracoHelper.cs @@ -14,6 +14,7 @@ using Umbraco.Core.Dictionary; using Umbraco.Core.Dynamics; using Umbraco.Core.Models; using Umbraco.Web.Models; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Templates; using umbraco; using System.Collections.Generic; @@ -437,32 +438,32 @@ namespace Umbraco.Web public IPublishedContent TypedContent(object id) { - return TypedDocumentById(id, PublishedContentStoreResolver.Current.PublishedContentStore); + return TypedDocumentById(id, PublishedContentCacheResolver.Current.PublishedContentCache); } public IPublishedContent TypedContent(int id) { - return TypedDocumentById(id, PublishedContentStoreResolver.Current.PublishedContentStore); + return TypedDocumentById(id, PublishedContentCacheResolver.Current.PublishedContentCache); } public IPublishedContent TypedContent(string id) { - return TypedDocumentById(id, PublishedContentStoreResolver.Current.PublishedContentStore); + return TypedDocumentById(id, PublishedContentCacheResolver.Current.PublishedContentCache); } public IEnumerable TypedContent(params object[] ids) { - return TypedDocumentsbyIds(PublishedContentStoreResolver.Current.PublishedContentStore, ids); + return TypedDocumentsbyIds(PublishedContentCacheResolver.Current.PublishedContentCache, ids); } public IEnumerable TypedContent(params int[] ids) { - return TypedDocumentsbyIds(PublishedContentStoreResolver.Current.PublishedContentStore, ids); + return TypedDocumentsbyIds(PublishedContentCacheResolver.Current.PublishedContentCache, ids); } public IEnumerable TypedContent(params string[] ids) { - return TypedDocumentsbyIds(PublishedContentStoreResolver.Current.PublishedContentStore, ids); + return TypedDocumentsbyIds(PublishedContentCacheResolver.Current.PublishedContentCache, ids); } public IEnumerable TypedContent(IEnumerable ids) @@ -482,37 +483,37 @@ namespace Umbraco.Web public IEnumerable TypedContentAtRoot() { - return TypedDocumentsAtRoot(PublishedContentStoreResolver.Current.PublishedContentStore); + return TypedDocumentsAtRoot(PublishedContentCacheResolver.Current.PublishedContentCache); } public dynamic Content(object id) { - return DocumentById(id, PublishedContentStoreResolver.Current.PublishedContentStore, new DynamicNull()); + return DocumentById(id, PublishedContentCacheResolver.Current.PublishedContentCache, new DynamicNull()); } public dynamic Content(int id) { - return DocumentById(id, PublishedContentStoreResolver.Current.PublishedContentStore, new DynamicNull()); + return DocumentById(id, PublishedContentCacheResolver.Current.PublishedContentCache, new DynamicNull()); } public dynamic Content(string id) { - return DocumentById(id, PublishedContentStoreResolver.Current.PublishedContentStore, new DynamicNull()); + return DocumentById(id, PublishedContentCacheResolver.Current.PublishedContentCache, new DynamicNull()); } public dynamic Content(params object[] ids) { - return DocumentByIds(PublishedContentStoreResolver.Current.PublishedContentStore, ids); + return DocumentByIds(PublishedContentCacheResolver.Current.PublishedContentCache, ids); } public dynamic Content(params int[] ids) { - return DocumentByIds(PublishedContentStoreResolver.Current.PublishedContentStore, ids); + return DocumentByIds(PublishedContentCacheResolver.Current.PublishedContentCache, ids); } public dynamic Content(params string[] ids) { - return DocumentByIds(PublishedContentStoreResolver.Current.PublishedContentStore, ids); + return DocumentByIds(PublishedContentCacheResolver.Current.PublishedContentCache, ids); } public dynamic Content(IEnumerable ids) @@ -532,7 +533,7 @@ namespace Umbraco.Web public dynamic ContentAtRoot() { - return DocumentsAtRoot(PublishedContentStoreResolver.Current.PublishedContentStore); + return DocumentsAtRoot(PublishedContentCacheResolver.Current.PublishedContentCache); } #endregion @@ -551,32 +552,32 @@ namespace Umbraco.Web /// public IPublishedContent TypedMedia(object id) { - return TypedDocumentById(id, PublishedMediaStoreResolver.Current.PublishedMediaStore); + return TypedDocumentById(id, PublishedMediaCacheResolver.Current.PublishedMediaCache); } public IPublishedContent TypedMedia(int id) { - return TypedDocumentById(id, PublishedMediaStoreResolver.Current.PublishedMediaStore); + return TypedDocumentById(id, PublishedMediaCacheResolver.Current.PublishedMediaCache); } public IPublishedContent TypedMedia(string id) { - return TypedDocumentById(id, PublishedMediaStoreResolver.Current.PublishedMediaStore); + return TypedDocumentById(id, PublishedMediaCacheResolver.Current.PublishedMediaCache); } public IEnumerable TypedMedia(params object[] ids) { - return TypedDocumentsbyIds(PublishedMediaStoreResolver.Current.PublishedMediaStore, ids); + return TypedDocumentsbyIds(PublishedMediaCacheResolver.Current.PublishedMediaCache, ids); } public IEnumerable TypedMedia(params int[] ids) { - return TypedDocumentsbyIds(PublishedMediaStoreResolver.Current.PublishedMediaStore, ids); + return TypedDocumentsbyIds(PublishedMediaCacheResolver.Current.PublishedMediaCache, ids); } public IEnumerable TypedMedia(params string[] ids) { - return TypedDocumentsbyIds(PublishedMediaStoreResolver.Current.PublishedMediaStore, ids); + return TypedDocumentsbyIds(PublishedMediaCacheResolver.Current.PublishedMediaCache, ids); } public IEnumerable TypedMedia(IEnumerable ids) @@ -596,37 +597,37 @@ namespace Umbraco.Web public IEnumerable TypedMediaAtRoot() { - return TypedDocumentsAtRoot(PublishedMediaStoreResolver.Current.PublishedMediaStore); + return TypedDocumentsAtRoot(PublishedMediaCacheResolver.Current.PublishedMediaCache); } public dynamic Media(object id) { - return DocumentById(id, PublishedMediaStoreResolver.Current.PublishedMediaStore, new DynamicNull()); + return DocumentById(id, PublishedMediaCacheResolver.Current.PublishedMediaCache, new DynamicNull()); } public dynamic Media(int id) { - return DocumentById(id, PublishedMediaStoreResolver.Current.PublishedMediaStore, new DynamicNull()); + return DocumentById(id, PublishedMediaCacheResolver.Current.PublishedMediaCache, new DynamicNull()); } public dynamic Media(string id) { - return DocumentById(id, PublishedMediaStoreResolver.Current.PublishedMediaStore, new DynamicNull()); + return DocumentById(id, PublishedMediaCacheResolver.Current.PublishedMediaCache, new DynamicNull()); } public dynamic Media(params object[] ids) { - return DocumentByIds(PublishedMediaStoreResolver.Current.PublishedMediaStore, ids); + return DocumentByIds(PublishedMediaCacheResolver.Current.PublishedMediaCache, ids); } public dynamic Media(params int[] ids) { - return DocumentByIds(PublishedMediaStoreResolver.Current.PublishedMediaStore, ids); + return DocumentByIds(PublishedMediaCacheResolver.Current.PublishedMediaCache, ids); } public dynamic Media(params string[] ids) { - return DocumentByIds(PublishedMediaStoreResolver.Current.PublishedMediaStore, ids); + return DocumentByIds(PublishedMediaCacheResolver.Current.PublishedMediaCache, ids); } public dynamic Media(IEnumerable ids) @@ -646,7 +647,7 @@ namespace Umbraco.Web public dynamic MediaAtRoot() { - return DocumentsAtRoot(PublishedMediaStoreResolver.Current.PublishedMediaStore); + return DocumentsAtRoot(PublishedMediaCacheResolver.Current.PublishedMediaCache); } #endregion @@ -657,33 +658,33 @@ namespace Umbraco.Web /// Overloaded method accepting an 'object' type /// /// - /// + /// /// /// /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass /// this result in to this method. /// This method will throw an exception if the value is not of type int or string. /// - private IPublishedContent TypedDocumentById(object id, IPublishedStore store) + private IPublishedContent TypedDocumentById(object id, IPublishedCache cache) { if (id is string) - return TypedDocumentById((string)id, store); + return TypedDocumentById((string)id, cache); if (id is int) - return TypedDocumentById((int)id, store); + return TypedDocumentById((int)id, cache); throw new InvalidOperationException("The value of parameter 'id' must be either a string or an integer"); } - private IPublishedContent TypedDocumentById(int id, IPublishedStore store) + private IPublishedContent TypedDocumentById(int id, IPublishedCache cache) { - var doc = store.GetDocumentById(UmbracoContext.Current, id); + var doc = cache.GetById(UmbracoContext.Current, id); return doc; } - private IPublishedContent TypedDocumentById(string id, IPublishedStore store) + private IPublishedContent TypedDocumentById(string id, IPublishedCache cache) { int docId; return int.TryParse(id, out docId) - ? DocumentById(docId, store, null) + ? DocumentById(docId, cache, null) : null; } @@ -691,38 +692,38 @@ namespace Umbraco.Web /// Overloaded method accepting an 'object' type /// /// - /// + /// /// /// /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass /// this result in to this method. /// This method will throw an exception if the value is not of type int or string. /// - private IEnumerable TypedDocumentsbyIds(IPublishedStore store, params object[] ids) + private IEnumerable TypedDocumentsbyIds(IPublishedCache cache, params object[] ids) { - return ids.Select(eachId => TypedDocumentById(eachId, store)); + return ids.Select(eachId => TypedDocumentById(eachId, cache)); } - private IEnumerable TypedDocumentsbyIds(IPublishedStore store, params int[] ids) + private IEnumerable TypedDocumentsbyIds(IPublishedCache cache, params int[] ids) { - return ids.Select(eachId => TypedDocumentById(eachId, store)); + return ids.Select(eachId => TypedDocumentById(eachId, cache)); } - private IEnumerable TypedDocumentsbyIds(IPublishedStore store, params string[] ids) + private IEnumerable TypedDocumentsbyIds(IPublishedCache cache, params string[] ids) { - return ids.Select(eachId => TypedDocumentById(eachId, store)); + return ids.Select(eachId => TypedDocumentById(eachId, cache)); } - private IEnumerable TypedDocumentsAtRoot(IPublishedStore store) + private IEnumerable TypedDocumentsAtRoot(IPublishedCache cache) { - return store.GetRootDocuments(_umbracoContext); + return cache.GetAtRoot(_umbracoContext); } /// /// Overloaded method accepting an 'object' type /// /// - /// + /// /// /// /// @@ -730,35 +731,35 @@ namespace Umbraco.Web /// this result in to this method. /// This method will throw an exception if the value is not of type int or string. /// - private dynamic DocumentById(object id, IPublishedStore store, object ifNotFound) + private dynamic DocumentById(object id, IPublishedCache cache, object ifNotFound) { if (id is string) - return DocumentById((string)id, store, ifNotFound); + return DocumentById((string)id, cache, ifNotFound); if (id is int) - return DocumentById((int)id, store, ifNotFound); + return DocumentById((int)id, cache, ifNotFound); throw new InvalidOperationException("The value of parameter 'id' must be either a string or an integer"); } - private dynamic DocumentById(int id, IPublishedStore store, object ifNotFound) + private dynamic DocumentById(int id, IPublishedCache cache, object ifNotFound) { - var doc = store.GetDocumentById(UmbracoContext.Current, id); + var doc = cache.GetById(UmbracoContext.Current, id); return doc == null ? ifNotFound : new DynamicPublishedContent(doc).AsDynamic(); } - private dynamic DocumentById(string id, IPublishedStore store, object ifNotFound) + private dynamic DocumentById(string id, IPublishedCache cache, object ifNotFound) { int docId; return int.TryParse(id, out docId) - ? DocumentById(docId, store, ifNotFound) + ? DocumentById(docId, cache, ifNotFound) : ifNotFound; } - private dynamic DocumentsAtRoot(IPublishedStore store) + private dynamic DocumentsAtRoot(IPublishedCache cache) { return new DynamicPublishedContentList( - store.GetRootDocuments(_umbracoContext) + cache.GetAtRoot(_umbracoContext) .Select(publishedContent => new DynamicPublishedContent(publishedContent)) ); } @@ -767,35 +768,35 @@ namespace Umbraco.Web /// Overloaded method accepting an 'object' type /// /// - /// + /// /// /// /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass /// this result in to this method. /// This method will throw an exception if the value is not of type int or string. /// - private dynamic DocumentByIds(IPublishedStore store, params object[] ids) + private dynamic DocumentByIds(IPublishedCache cache, params object[] ids) { var dNull = new DynamicNull(); - var nodes = ids.Select(eachId => DocumentById(eachId, store, dNull)) + var nodes = ids.Select(eachId => DocumentById(eachId, cache, dNull)) .Where(x => !TypeHelper.IsTypeAssignableFrom(x)) .Cast(); return new DynamicPublishedContentList(nodes); } - private dynamic DocumentByIds(IPublishedStore store, params int[] ids) + private dynamic DocumentByIds(IPublishedCache cache, params int[] ids) { var dNull = new DynamicNull(); - var nodes = ids.Select(eachId => DocumentById(eachId, store, dNull)) + var nodes = ids.Select(eachId => DocumentById(eachId, cache, dNull)) .Where(x => !TypeHelper.IsTypeAssignableFrom(x)) .Cast(); return new DynamicPublishedContentList(nodes); } - private dynamic DocumentByIds(IPublishedStore store, params string[] ids) + private dynamic DocumentByIds(IPublishedCache cache, params string[] ids) { var dNull = new DynamicNull(); - var nodes = ids.Select(eachId => DocumentById(eachId, store, dNull)) + var nodes = ids.Select(eachId => DocumentById(eachId, cache, dNull)) .Where(x => !TypeHelper.IsTypeAssignableFrom(x)) .Cast(); return new DynamicPublishedContentList(nodes); @@ -844,7 +845,7 @@ namespace Umbraco.Web searcher = Examine.ExamineManager.Instance.SearchProviderCollection[searchProvider]; var results = searcher.Search(term, useWildCards); - return results.ConvertSearchResultToPublishedContent(PublishedContentStoreResolver.Current.PublishedContentStore); + return results.ConvertSearchResultToPublishedContent(PublishedContentCacheResolver.Current.PublishedContentCache); } /// @@ -860,7 +861,7 @@ namespace Umbraco.Web s = searchProvider; var results = s.Search(criteria); - return results.ConvertSearchResultToPublishedContent(PublishedContentStoreResolver.Current.PublishedContentStore); + return results.ConvertSearchResultToPublishedContent(PublishedContentCacheResolver.Current.PublishedContentCache); } #endregion diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index ddc1c3fad2..f8a05e57e7 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -317,7 +317,7 @@ namespace Umbraco.Web // if yes, return true private static bool EnsureHasContent(UmbracoContext context, HttpContextBase httpContext) { - var store = context.RoutingContext.PublishedContentStore; + var store = context.RoutingContext.PublishedContentCache; if (store.HasContent(context)) return true; diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 9f46825b41..088e9c5b40 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -19,6 +19,8 @@ using Umbraco.Web.Media.ThumbnailProviders; using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.PropertyEditors; +using Umbraco.Web.PublishedCache; +using Umbraco.Web.PublishedCache.LegacyXmlCache; using Umbraco.Web.Routing; using Umbraco.Web.WebApi; using umbraco.BusinessLogic; @@ -275,8 +277,8 @@ namespace Umbraco.Web PropertyEditorValueConvertersResolver.Current.RemoveType(); PropertyEditorValueConvertersResolver.Current.AddType(); - PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore()); - PublishedMediaStoreResolver.Current = new PublishedMediaStoreResolver(new DefaultPublishedMediaStore()); + PublishedContentCacheResolver.Current = new PublishedContentCacheResolver(new PublishedContentCache()); + PublishedMediaCacheResolver.Current = new PublishedMediaCacheResolver(new PublishedMediaCache()); FilteredControllerFactoriesResolver.Current = new FilteredControllerFactoriesResolver( // add all known factories, devs can then modify this list on application diff --git a/src/Umbraco.Web/umbraco.presentation/library.cs b/src/Umbraco.Web/umbraco.presentation/library.cs index 98482ee785..a5b45db945 100644 --- a/src/Umbraco.Web/umbraco.presentation/library.cs +++ b/src/Umbraco.Web/umbraco.presentation/library.cs @@ -14,6 +14,7 @@ using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Web; using Umbraco.Web.Cache; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.Templates; using umbraco.BusinessLogic; @@ -326,7 +327,7 @@ namespace umbraco /// Returns a string with the data from the given element of a node public static string GetItem(int nodeID, String alias) { - var doc = PublishedContentStoreResolver.Current.PublishedContentStore.GetDocumentById( + var doc = PublishedContentCacheResolver.Current.PublishedContentCache.GetById( Umbraco.Web.UmbracoContext.Current, nodeID); diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs index a1d423bfa3..cbf15fa7f2 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/templateControls/ItemRenderer.cs @@ -9,6 +9,7 @@ using System.Web.UI; using System.Xml; using Umbraco.Core.Macros; using Umbraco.Web; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; using Umbraco.Web.Templates; using umbraco.cms.businesslogic; @@ -102,7 +103,7 @@ namespace umbraco.presentation.templateControls //moved the following from the catch block up as this will allow fallback options alt text etc to work //get the publishedcontent item - var publishedContent = PublishedContentStoreResolver.Current.PublishedContentStore.GetDocumentById( + var publishedContent = PublishedContentCacheResolver.Current.PublishedContentCache.GetById( Umbraco.Web.UmbracoContext.Current, tempNodeId.Value);