diff --git a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs index cc6a428ee6..67e7dd3802 100644 --- a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs @@ -43,21 +43,24 @@ namespace Umbraco.Core.Sync { if (servers == null) throw new ArgumentNullException("servers"); if (refresher == null) throw new ArgumentNullException("refresher"); - throw new NotImplementedException(); + + instances.ForEach(x => InvokeDispatchMethod(servers, refresher, MessageType.RefreshById, getNumericId(x))); } public void PerformRefresh(IEnumerable servers, ICacheRefresher refresher, Func getGuidId, params T[] instances) { if (servers == null) throw new ArgumentNullException("servers"); if (refresher == null) throw new ArgumentNullException("refresher"); - throw new NotImplementedException(); + + instances.ForEach(x => InvokeDispatchMethod(servers, refresher, MessageType.RefreshById, getGuidId(x))); } public void PerformRemove(IEnumerable servers, ICacheRefresher refresher, Func getNumericId, params T[] instances) { if (servers == null) throw new ArgumentNullException("servers"); if (refresher == null) throw new ArgumentNullException("refresher"); - throw new NotImplementedException(); + + instances.ForEach(x => InvokeDispatchMethod(servers, refresher, MessageType.RemoveById, getNumericId(x))); } public void PerformRemove(IEnumerable servers, ICacheRefresher refresher, params int[] numericIds) @@ -129,7 +132,8 @@ namespace Umbraco.Core.Sync { if (servers == null) throw new ArgumentNullException("servers"); if (refresher == null) throw new ArgumentNullException("refresher"); - + if (!(id is int) && (!(id is Guid))) throw new ArgumentException("The id must be either an int or a Guid"); + //Now, check if we are using Distrubuted calls. If there are no servers in the list then we // can definitely not distribute. if (!_useDistributedCalls || !servers.Any()) diff --git a/src/Umbraco.Tests/Sync/DistributedCacheTests.cs b/src/Umbraco.Tests/Sync/DistributedCacheTests.cs index b2a6cca09e..e8fa316605 100644 --- a/src/Umbraco.Tests/Sync/DistributedCacheTests.cs +++ b/src/Umbraco.Tests/Sync/DistributedCacheTests.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.ObjectResolution; @@ -118,17 +119,17 @@ namespace Umbraco.Tests.Sync public void PerformRefresh(IEnumerable servers, ICacheRefresher refresher, Func getNumericId, params T[] instances) { - throw new NotImplementedException(); + IntIdsRefreshed.AddRange(instances.Select(getNumericId)); } public void PerformRefresh(IEnumerable servers, ICacheRefresher refresher, Func getGuidId, params T[] instances) { - throw new NotImplementedException(); + GuidIdsRefreshed.AddRange(instances.Select(getGuidId)); } public void PerformRemove(IEnumerable servers, ICacheRefresher refresher, Func getNumericId, params T[] instances) { - throw new NotImplementedException(); + IntIdsRemoved.AddRange(instances.Select(getNumericId)); } public void PerformRemove(IEnumerable servers, ICacheRefresher refresher, params int[] numericIds) diff --git a/src/Umbraco.Web.UI/umbraco/dialogs/Publish.aspx.cs b/src/Umbraco.Web.UI/umbraco/dialogs/Publish.aspx.cs index 4dd6feb26a..7e09d0b425 100644 --- a/src/Umbraco.Web.UI/umbraco/dialogs/Publish.aspx.cs +++ b/src/Umbraco.Web.UI/umbraco/dialogs/Publish.aspx.cs @@ -11,6 +11,7 @@ namespace Umbraco.Web.UI.Umbraco.Dialogs protected string PageName { get; private set; } protected int DocumentId { get; private set; } + protected string DocumentPath { get; private set; } protected override void OnInit(EventArgs e) { @@ -30,6 +31,7 @@ namespace Umbraco.Web.UI.Umbraco.Dialogs DocumentId = doc.Id; PageName = doc.Name; + DocumentPath = doc.Path; } } diff --git a/src/Umbraco.Web.UI/umbraco/dialogs/publish.aspx b/src/Umbraco.Web.UI/umbraco/dialogs/publish.aspx index 2a0a65ff51..e93221ba25 100644 --- a/src/Umbraco.Web.UI/umbraco/dialogs/publish.aspx +++ b/src/Umbraco.Web.UI/umbraco/dialogs/publish.aspx @@ -23,7 +23,8 @@ $(document).ready(function () { Umbraco.Dialogs.PublishDialog.getInstance().init({ restServiceLocation: "<%= Url.GetBulkPublishServicePath() %>", - documentId: <%= DocumentId %> + documentId: <%= DocumentId %>, + documentPath: '<%= DocumentPath %>' }); }); })(jQuery); diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/PublishDialog.js b/src/Umbraco.Web.UI/umbraco_client/Dialogs/PublishDialog.js index f361ec39a1..d034a07a4a 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Dialogs/PublishDialog.js +++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/PublishDialog.js @@ -56,7 +56,10 @@ else { self._koViewModel.resultMessage(msgs[0]); } - + + //sync the tree + UmbClientMgr.mainTree().setActiveTreeType('content'); + UmbClientMgr.mainTree().syncTree(self._opts.documentPath, true); }); } }; diff --git a/src/Umbraco.Web/Cache/DistributedCache.cs b/src/Umbraco.Web/Cache/DistributedCache.cs index 2d6989fcf3..8b8582f507 100644 --- a/src/Umbraco.Web/Cache/DistributedCache.cs +++ b/src/Umbraco.Web/Cache/DistributedCache.cs @@ -59,6 +59,26 @@ namespace Umbraco.Web.Cache } } + /// + /// Sends a request to all registered load-balanced servers to refresh node with the specified Id + /// using the specified ICacheRefresher with the guid factoryGuid. + /// + /// + /// + /// The callback method to retreive the ID from an instance + /// The instances containing Ids + /// + /// This method is much better for performance because it does not need to re-lookup an object instance + /// + public void Refresh(Guid factoryGuid, Func getNumericId, params T[] instances) + { + ServerMessengerResolver.Current.Messenger.PerformRefresh( + ServerRegistrarResolver.Current.Registrar.Registrations, + GetRefresherById(factoryGuid), + getNumericId, + instances); + } + /// /// Sends a request to all registered load-balanced servers to refresh node with the specified Id /// using the specified ICacheRefresher with the guid factoryGuid. diff --git a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs index 1e2d64c007..2ce60b42f8 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheExtensions.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.Linq; +using Umbraco.Core.Models; namespace Umbraco.Web.Cache { @@ -56,6 +59,16 @@ namespace Umbraco.Web.Cache dc.Refresh(new Guid(DistributedCache.PageCacheRefresherId), pageId); } + /// + /// Refreshes page cache for all instances passed in + /// + /// + /// + public static void RefreshPageCache(this DistributedCache dc, IEnumerable content) + { + dc.Refresh(new Guid(DistributedCache.PageCacheRefresherId), x => x.Id, content.ToArray()); + } + /// /// Removes the cache amongst servers for a page /// diff --git a/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs b/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs index 37b72a1e7b..99dacfb555 100644 --- a/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs +++ b/src/Umbraco.Web/Strategies/Publishing/UpdateCacheAfterPublish.cs @@ -66,10 +66,7 @@ namespace Umbraco.Web.Strategies.Publishing /// private void UpdateMultipleContentCache(IEnumerable content) { - foreach (var c in content) - { - DistributedCache.Instance.RefreshPageCache(c.Id); - } + DistributedCache.Instance.RefreshPageCache(content); } /// diff --git a/src/Umbraco.Web/umbraco.presentation/content.cs b/src/Umbraco.Web/umbraco.presentation/content.cs index 42d7b390b4..1d5eb594b7 100644 --- a/src/Umbraco.Web/umbraco.presentation/content.cs +++ b/src/Umbraco.Web/umbraco.presentation/content.cs @@ -489,7 +489,6 @@ namespace umbraco UpdateDocumentCache(d); } - /// /// Updates the document cache. /// diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs index d2f8d32404..64a78b903e 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/Trees/BaseContentTree.cs @@ -113,7 +113,7 @@ function openContent(id) { node.OpenIcon = dd.ContentTypeIcon; } - if (!dd.Published) + if (!dd.HasPublishedVersion()) node.Style.DimNode(); if (dd.HasPendingChanges())