diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs
index 0cc47263a6..bab1269932 100644
--- a/src/Umbraco.Core/CoreBootManager.cs
+++ b/src/Umbraco.Core/CoreBootManager.cs
@@ -14,6 +14,7 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Publishing;
using Umbraco.Core.Macros;
using Umbraco.Core.Services;
+using Umbraco.Core.Sync;
using MigrationsVersionFourNineZero = Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionFourNineZero;
namespace Umbraco.Core
@@ -165,6 +166,16 @@ namespace Umbraco.Core
///
protected virtual void InitializeResolvers()
{
+ //by default we'll use the standard configuration based sync
+ ServerRegistrarResolver.Current = new ServerRegistrarResolver(
+ new ConfigServerRegistrar());
+
+ //by default (outside of the web) we'll use the default server messenger without
+ //supplying a username/password, this will automatically disable distributed calls
+ // .. we'll override this in the WebBootManager
+ ServerMessengerResolver.Current = new ServerMessengerResolver(
+ new DefaultServerMessenger());
+
RepositoryResolver.Current = new RepositoryResolver(
new RepositoryFactory());
diff --git a/src/Umbraco.Core/Publishing/BasePublishingStrategy.cs b/src/Umbraco.Core/Publishing/BasePublishingStrategy.cs
index 90704648d1..63f32c41c5 100644
--- a/src/Umbraco.Core/Publishing/BasePublishingStrategy.cs
+++ b/src/Umbraco.Core/Publishing/BasePublishingStrategy.cs
@@ -9,25 +9,6 @@ namespace Umbraco.Core.Publishing
public abstract class BasePublishingStrategy : IPublishingStrategy
{
- internal abstract Attempt PublishInternal(IContent content, int userId);
-
- ///
- /// Publishes a list of content items
- ///
- ///
- ///
- ///
- /// By default this is set to true which means that it will publish any content item in the list that is completely unpublished and
- /// not visible on the front-end. If set to false, this will only publish content that is live on the front-end but has new versions
- /// that have yet to be published.
- ///
- /// If true this will validate each content item before trying to publish it, if validation fails it will not be published.
- ///
- internal abstract IEnumerable> PublishWithChildrenInternal(
- IEnumerable content, int userId, bool includeUnpublishedDocuments = true, bool validateContent = false);
-
- internal abstract IEnumerable> UnPublishInternal(IEnumerable content, int userId);
-
public abstract bool Publish(IContent content, int userId);
public abstract bool PublishWithChildren(IEnumerable content, int userId);
public abstract bool UnPublish(IContent content, int userId);
diff --git a/src/Umbraco.Core/Publishing/PublishingStrategy.cs b/src/Umbraco.Core/Publishing/PublishingStrategy.cs
index 4a8cc5a63d..5219604afa 100644
--- a/src/Umbraco.Core/Publishing/PublishingStrategy.cs
+++ b/src/Umbraco.Core/Publishing/PublishingStrategy.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Publishing
///
/// to publish
/// Id of the User issueing the publish operation
- internal override Attempt PublishInternal(IContent content, int userId)
+ internal Attempt PublishInternal(IContent content, int userId)
{
if (Publishing.IsRaisedEventCancelled(new PublishEventArgs(content), this))
{
@@ -85,8 +85,7 @@ namespace Umbraco.Core.Publishing
/// By default this is set to true which means that it will publish any content item in the list that is completely unpublished and
/// not visible on the front-end. If set to false, this will only publish content that is live on the front-end but has new versions
/// that have yet to be published.
- ///
- /// If true this will validate each content item before trying to publish it, if validation fails it will not be published.
+ ///
///
///
/// This method becomes complex once we start to be able to cancel events or stop publishing a content item in any way because if a
@@ -99,8 +98,8 @@ namespace Umbraco.Core.Publishing
/// level and so on. If we detect that the above rule applies when the document publishing is cancelled we'll add it to the list of
/// parentsIdsCancelled so that it's children don't get published.
///
- internal override IEnumerable> PublishWithChildrenInternal(
- IEnumerable content, int userId, bool includeUnpublishedDocuments = true, bool validateContent = false)
+ internal IEnumerable> PublishWithChildrenInternal(
+ IEnumerable content, int userId, bool includeUnpublishedDocuments = true)
{
var statuses = new List>();
@@ -163,7 +162,7 @@ namespace Umbraco.Core.Publishing
}
//Check if the content is valid if the flag is set to check
- if (validateContent && !item.IsValid())
+ if (!item.IsValid())
{
LogHelper.Info(
string.Format("Content '{0}' with Id '{1}' will not be published because some of it's content is not passing validation rules.",
@@ -322,7 +321,7 @@ namespace Umbraco.Core.Publishing
/// An enumerable list of
/// Id of the User issueing the unpublish operation
/// A list of publish statuses
- internal override IEnumerable> UnPublishInternal(IEnumerable content, int userId)
+ internal IEnumerable> UnPublishInternal(IEnumerable content, int userId)
{
var result = new List>();
diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index eec0346f4d..0fdb4b06c6 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -24,7 +24,7 @@ namespace Umbraco.Core.Services
public class ContentService : IContentService
{
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
- private readonly BasePublishingStrategy _publishingStrategy;
+ private readonly IPublishingStrategy _publishingStrategy;
private readonly RepositoryFactory _repositoryFactory;
public ContentService()
@@ -43,23 +43,16 @@ namespace Umbraco.Core.Services
: this(provider, repositoryFactory, new PublishingStrategy())
{ }
- [Obsolete("This contructor is no longer supported, use the other constructor accepting a BasePublishginStrategy object instead")]
public ContentService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IPublishingStrategy publishingStrategy)
{
- _uowProvider = provider;
- _publishingStrategy = publishingStrategy as BasePublishingStrategy;
- if (_publishingStrategy == null)
- throw new InvalidOperationException("publishingStrategy must be an instance of " + typeof(BasePublishingStrategy).Name);
+ if (provider == null) throw new ArgumentNullException("provider");
+ if (repositoryFactory == null) throw new ArgumentNullException("repositoryFactory");
+ if (publishingStrategy == null) throw new ArgumentNullException("publishingStrategy");
+ _uowProvider = provider;
+ _publishingStrategy = publishingStrategy;
_repositoryFactory = repositoryFactory;
}
- public ContentService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, BasePublishingStrategy publishingStrategy)
- {
- _uowProvider = provider;
- _publishingStrategy = publishingStrategy;
- _repositoryFactory = repositoryFactory;
- }
-
///
/// Creates an object using the alias of the
/// that this Content is based on.
@@ -477,7 +470,7 @@ namespace Umbraco.Core.Services
/// True if publishing succeeded, otherwise False
public bool RePublishAll(int userId = 0)
{
- return RePublishAllDo(false, userId);
+ return RePublishAllDo(userId);
}
///
@@ -488,7 +481,7 @@ namespace Umbraco.Core.Services
/// True if publishing succeeded, otherwise False
public bool Publish(IContent content, int userId = 0)
{
- var result = SaveAndPublishDo(content, false, userId);
+ var result = SaveAndPublishDo(content, userId);
return result.Success;
}
@@ -500,7 +493,7 @@ namespace Umbraco.Core.Services
/// True if publishing succeeded, otherwise False
public bool PublishWithChildren(IContent content, int userId = 0)
{
- var result = PublishWithChildrenDo(content, false, userId);
+ var result = PublishWithChildrenDo(content, userId);
//This used to just return false only when the parent content failed, otherwise would always return true so we'll
// do the same thing for the moment
@@ -527,7 +520,7 @@ namespace Umbraco.Core.Services
/// True if publishing succeeded, otherwise False
public bool SaveAndPublish(IContent content, int userId = 0, bool raiseEvents = true)
{
- var result = SaveAndPublishDo(content, false, userId, raiseEvents);
+ var result = SaveAndPublishDo(content, userId, raiseEvents);
return result.Success;
}
@@ -1063,67 +1056,41 @@ namespace Umbraco.Core.Services
}
#region Internal Methods
- ///
- /// Internal method to Re-Publishes all Content for legacy purposes.
- ///
- /// Optional Id of the User issueing the publishing
- /// Optional boolean to avoid having the cache refreshed when calling this RePublish method. By default this method will not update the cache.
- /// True if publishing succeeded, otherwise False
- internal bool RePublishAll(bool omitCacheRefresh = true, int userId = 0)
- {
- return RePublishAllDo(omitCacheRefresh, userId);
- }
-
+
///
/// Internal method that Publishes a single object for legacy purposes.
///
/// The to publish
- /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will not update the cache.
/// Optional Id of the User issueing the publishing
/// True if publishing succeeded, otherwise False
- internal Attempt Publish(IContent content, bool omitCacheRefresh = true, int userId = 0)
+ internal Attempt PublishInternal(IContent content, int userId = 0)
{
- return SaveAndPublishDo(content, omitCacheRefresh, userId);
+ return SaveAndPublishDo(content, userId);
}
///
/// Internal method that Publishes a object and all its children for legacy purposes.
///
/// The to publish along with its children
- /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will not update the cache.
/// Optional Id of the User issueing the publishing
/// If set to true, this will also publish descendants that are completely unpublished, normally this will only publish children that have previously been published
- /// If true this will validate the content before publishing
/// True if publishing succeeded, otherwise False
- internal IEnumerable> PublishWithChildren(
- IContent content, bool omitCacheRefresh = true, int userId = 0, bool includeUnpublished = false, bool validateContent = false)
+ internal IEnumerable> PublishWithChildrenInternal(
+ IContent content, int userId = 0, bool includeUnpublished = false)
{
- return PublishWithChildrenDo(content, omitCacheRefresh, userId, includeUnpublished, validateContent);
- }
-
- ///
- /// Internal method that UnPublishes a single object for legacy purposes.
- ///
- /// The to publish
- /// Optional boolean to avoid having the cache refreshed when calling this Unpublish method. By default this method will not update the cache.
- /// Optional Id of the User issueing the publishing
- /// True if unpublishing succeeded, otherwise False
- internal bool UnPublish(IContent content, bool omitCacheRefresh = true, int userId = 0)
- {
- return UnPublishDo(content, omitCacheRefresh, userId);
+ return PublishWithChildrenDo(content, userId, includeUnpublished);
}
///
/// Saves and Publishes a single object
///
/// The to save and publish
- /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will not update the cache.
/// Optional Id of the User issueing the publishing
/// Optional boolean indicating whether or not to raise save events.
/// True if publishing succeeded, otherwise False
- internal Attempt SaveAndPublish(IContent content, bool omitCacheRefresh = true, int userId = 0, bool raiseEvents = true)
+ internal Attempt SaveAndPublishInternal(IContent content, int userId = 0, bool raiseEvents = true)
{
- return SaveAndPublishDo(content, omitCacheRefresh, userId, raiseEvents);
+ return SaveAndPublishDo(content, userId, raiseEvents);
}
///
@@ -1150,9 +1117,8 @@ namespace Umbraco.Core.Services
/// Re-Publishes all Content
///
/// Optional Id of the User issueing the publishing
- /// Optional boolean to avoid having the cache refreshed when calling this RePublish method. By default this method will update the cache.
/// True if publishing succeeded, otherwise False
- private bool RePublishAllDo(bool omitCacheRefresh = false, int userId = 0)
+ private bool RePublishAllDo(int userId = 0)
{
var list = new List();
var updated = new List();
@@ -1198,9 +1164,8 @@ namespace Umbraco.Core.Services
: Convert.ToInt32(uow.Database.Insert(poco));
}
}
- //Updating content to published state is finished, so we fire event through PublishingStrategy to have cache updated
- if (omitCacheRefresh == false)
- _publishingStrategy.PublishingFinalized(updated, true);
+
+ _publishingStrategy.PublishingFinalized(updated, true);
}
Audit.Add(AuditTypes.Publish, "RePublish All performed by user", userId, -1);
@@ -1212,17 +1177,15 @@ namespace Umbraco.Core.Services
/// Publishes a object and all its children
///
/// The to publish along with its children
- /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache.
/// Optional Id of the User issueing the publishing
- /// If set to true, this will also publish descendants that are completely unpublished, normally this will only publish children that have previously been published
- /// If set to true will ensure the content is valid before publishing
+ /// If set to true, this will also publish descendants that are completely unpublished, normally this will only publish children that have previously been published
///
/// A list of publish statues. If the parent document is not valid or cannot be published because it's parent(s) is not published
/// then the list will only contain one status item, otherwise it will contain status items for it and all of it's descendants that
/// are to be published.
///
private IEnumerable> PublishWithChildrenDo(
- IContent content, bool omitCacheRefresh = false, int userId = 0, bool includeUnpublished = false, bool validateContent = false)
+ IContent content, int userId = 0, bool includeUnpublished = false)
{
if (content == null) throw new ArgumentNullException("content");
@@ -1257,8 +1220,10 @@ namespace Umbraco.Core.Services
list.Add(content); //include parent item
list.AddRange(GetDescendants(content));
+ var internalStrategy = (PublishingStrategy)_publishingStrategy;
+
//Publish and then update the database with new status
- var publishedOutcome = _publishingStrategy.PublishWithChildrenInternal(list, userId, includeUnpublished, validateContent).ToArray();
+ var publishedOutcome = internalStrategy.PublishWithChildrenInternal(list, userId, includeUnpublished).ToArray();
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateContentRepository(uow))
@@ -1288,8 +1253,7 @@ namespace Umbraco.Core.Services
}
}
//Save xml to db and call following method to fire event:
- if (omitCacheRefresh == false)
- _publishingStrategy.PublishingFinalized(updated, false);
+ _publishingStrategy.PublishingFinalized(updated, false);
Audit.Add(AuditTypes.Publish, "Publish with Children performed by user", userId, content.Id);
@@ -1334,11 +1298,10 @@ namespace Umbraco.Core.Services
/// Saves and Publishes a single object
///
/// The to save and publish
- /// Optional boolean to avoid having the cache refreshed when calling this Publish method. By default this method will update the cache.
/// Optional Id of the User issueing the publishing
/// Optional boolean indicating whether or not to raise save events.
/// True if publishing succeeded, otherwise False
- private Attempt SaveAndPublishDo(IContent content, bool omitCacheRefresh = false, int userId = 0, bool raiseEvents = true)
+ private Attempt SaveAndPublishDo(IContent content, int userId = 0, bool raiseEvents = true)
{
if(raiseEvents)
{
@@ -1372,8 +1335,9 @@ namespace Umbraco.Core.Services
publishStatus.StatusType = PublishStatusType.FailedContentInvalid;
}
+ var internalStrategy = (PublishingStrategy) _publishingStrategy;
//Publish and then update the database with new status
- var publishResult = _publishingStrategy.PublishInternal(content, userId);
+ var publishResult = internalStrategy.PublishInternal(content, userId);
//set our publish status to the publish result
publishStatus.StatusType = publishResult.Result.StatusType;
@@ -1430,13 +1394,13 @@ namespace Umbraco.Core.Services
Saved.RaiseEvent(new SaveEventArgs(content, false), this);
//Save xml to db and call following method to fire event through PublishingStrategy to update cache
- if (published && omitCacheRefresh == false)
+ if (published)
{
_publishingStrategy.PublishingFinalized(content);
}
//We need to check if children and their publish state to ensure that we 'republish' content that was previously published
- if (published && omitCacheRefresh == false && previouslyPublished == false && HasChildren(content.Id))
+ if (published && previouslyPublished == false && HasChildren(content.Id))
{
var descendants = GetPublishedDescendants(content);
diff --git a/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs b/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs
new file mode 100644
index 0000000000..8080ef05fa
--- /dev/null
+++ b/src/Umbraco.Core/Sync/ConfigServerRegistrar.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml;
+using Umbraco.Core.Configuration;
+
+namespace Umbraco.Core.Sync
+{
+ ///
+ /// A registrar that uses the legacy xml configuration in umbracoSettings to get a list of defined server nodes
+ ///
+ internal class ConfigServerRegistrar : IServerRegistrar
+ {
+ private readonly XmlNode _xmlServers;
+
+ public ConfigServerRegistrar()
+ : this(UmbracoSettings.DistributionServers)
+ {
+
+ }
+
+ internal ConfigServerRegistrar(XmlNode xmlServers)
+ {
+ _xmlServers = xmlServers;
+ }
+
+ private List _addresses;
+
+ public IEnumerable Registrations
+ {
+ get
+ {
+ if (_addresses == null)
+ {
+ _addresses = new List();
+ var nodes = _xmlServers.SelectNodes("./server");
+ foreach (XmlNode n in nodes)
+ {
+ _addresses.Add(new ConfigServerRegistration(n));
+ }
+ }
+ return _addresses;
+ }
+ }
+ }
+}
diff --git a/src/Umbraco.Core/Sync/ConfigServerRegistration.cs b/src/Umbraco.Core/Sync/ConfigServerRegistration.cs
new file mode 100644
index 0000000000..c8865bd4a2
--- /dev/null
+++ b/src/Umbraco.Core/Sync/ConfigServerRegistration.cs
@@ -0,0 +1,29 @@
+using System.Xml;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.IO;
+
+namespace Umbraco.Core.Sync
+{
+ ///
+ /// A server registration based on the legacy umbraco xml configuration in umbracoSettings
+ ///
+ internal class ConfigServerRegistration : IServerRegistration
+ {
+
+ public ConfigServerRegistration(XmlNode n)
+ {
+ var webServicesUrl = IOHelper.ResolveUrl(SystemDirectories.WebServices);
+
+ var protocol = GlobalSettings.UseSSL ? "https" : "http";
+ if (n.Attributes.GetNamedItem("forceProtocol") != null && !string.IsNullOrEmpty(n.Attributes.GetNamedItem("forceProtocol").Value))
+ protocol = n.Attributes.GetNamedItem("forceProtocol").Value;
+ var domain = XmlHelper.GetNodeValue(n);
+ if (n.Attributes.GetNamedItem("forcePortnumber") != null && !string.IsNullOrEmpty(n.Attributes.GetNamedItem("forcePortnumber").Value))
+ domain += string.Format(":{0}", n.Attributes.GetNamedItem("forcePortnumber").Value);
+ ServerAddress = string.Format("{0}://{1}{2}/cacheRefresher.asmx", protocol, domain, webServicesUrl);
+ }
+
+ public string ServerAddress { get; private set; }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Sync/DefaultServerMessenger.cs b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs
new file mode 100644
index 0000000000..2bc9e18467
--- /dev/null
+++ b/src/Umbraco.Core/Sync/DefaultServerMessenger.cs
@@ -0,0 +1,401 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Net;
+using System.Threading;
+using System.Web.Script.Serialization;
+using Umbraco.Core.Configuration;
+using Umbraco.Core.Logging;
+using umbraco.interfaces;
+
+namespace Umbraco.Core.Sync
+{
+ ///
+ /// The default server messenger that uses web services to keep servers in sync
+ ///
+ internal class DefaultServerMessenger : IServerMessenger
+ {
+ private readonly string _login;
+ private readonly string _password;
+ private readonly bool _useDistributedCalls;
+
+ ///
+ /// Without a username/password all distribuion will be disabled
+ ///
+ internal DefaultServerMessenger()
+ {
+ _useDistributedCalls = false;
+ }
+
+ ///
+ /// Distribution will be enabled based on the umbraco config setting.
+ ///
+ ///
+ ///
+ internal DefaultServerMessenger(string login, string password)
+ {
+ _useDistributedCalls = UmbracoSettings.UseDistributedCalls;
+ _login = login;
+ _password = password;
+ }
+
+ public void PerformRefresh(IEnumerable servers, ICacheRefresher refresher,Func getNumericId, params T[] instances)
+ {
+ if (servers == null) throw new ArgumentNullException("servers");
+ if (refresher == null) throw new ArgumentNullException("refresher");
+
+ //copy local
+ var idGetter = getNumericId;
+
+ MessageSeversForManyObjects(servers, refresher, MessageType.RefreshById,
+ x => idGetter(x),
+ instances);
+ }
+
+ 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");
+
+ //copy local
+ var idGetter = getGuidId;
+
+ MessageSeversForManyObjects(servers, refresher, MessageType.RefreshById,
+ x => idGetter(x),
+ instances);
+ }
+
+ 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");
+
+ //copy local
+ var idGetter = getNumericId;
+
+ MessageSeversForManyObjects(servers, refresher, MessageType.RemoveById,
+ x => idGetter(x),
+ instances);
+ }
+
+ public void PerformRemove(IEnumerable servers, ICacheRefresher refresher, params int[] numericIds)
+ {
+ if (servers == null) throw new ArgumentNullException("servers");
+ if (refresher == null) throw new ArgumentNullException("refresher");
+
+ MessageSeversForManyIds(servers, refresher, MessageType.RemoveById, numericIds.Cast
" + ui.Text("view") + " " + d.Text + "";
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs
index 987c5965f6..d870b59bec 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs
@@ -83,7 +83,7 @@ namespace umbraco.presentation.channels
if (publish)
{
- doc.Publish(new User(username));
+ doc.SaveAndPublish(new User(username));
}
return true;
}
@@ -401,7 +401,7 @@ namespace umbraco.presentation.channels
if (publish)
{
- doc.Publish(new User(username));
+ doc.SaveAndPublish(new User(username));
}
return doc.Id.ToString();
}
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/CacheRefresher.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/CacheRefresher.asmx.cs
index d2ecd05a33..23f43d7685 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/CacheRefresher.asmx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/CacheRefresher.asmx.cs
@@ -1,9 +1,11 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
+using System.Web.Script.Serialization;
using System.Web.Services;
using System.Xml;
using Umbraco.Core;
@@ -82,6 +84,29 @@ namespace umbraco.presentation.webservices
}
}
+ ///
+ /// Refreshes objects for all Ids matched in the json string
+ ///
+ ///
+ /// A JSON Serialized string of ids to match
+ ///
+ ///
+ [WebMethod]
+ public void RefreshByIds(Guid uniqueIdentifier, string jsonIds, string Login, string Password)
+ {
+ var serializer = new JavaScriptSerializer();
+ var ids = serializer.Deserialize(jsonIds);
+
+ if (BusinessLogic.User.validateCredentials(Login, Password))
+ {
+ var cr = CacheRefreshersResolver.Current.GetById(uniqueIdentifier);
+ foreach (var i in ids)
+ {
+ cr.Refresh(i);
+ }
+ }
+ }
+
[WebMethod]
public void RemoveById(Guid uniqueIdentifier, int Id, string Login, string Password) {
diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
index eda8ee7bee..e767cf5fd9 100644
--- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
+++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs
@@ -7,6 +7,7 @@ using System.Xml;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence.Caching;
using Umbraco.Web;
+using Umbraco.Web.Security;
using umbraco.BasePages;
using umbraco.BusinessLogic.Actions;
using umbraco.cms.businesslogic.web;
@@ -98,7 +99,7 @@ namespace umbraco.presentation.webservices
// refresh the xml for the sorting to work
if (published)
{
- document.Publish(BusinessLogic.User.GetCurrent());
+ document.SaveAndPublish(WebSecurity.CurrentUser);
document.refreshXmlSortOrder();
}
}
diff --git a/src/UmbracoExamine/BaseUmbracoIndexer.cs b/src/UmbracoExamine/BaseUmbracoIndexer.cs
index dc6c1c704f..fd9a1e8c16 100644
--- a/src/UmbracoExamine/BaseUmbracoIndexer.cs
+++ b/src/UmbracoExamine/BaseUmbracoIndexer.cs
@@ -95,7 +95,7 @@ namespace UmbracoExamine
{
//We need to check if we actually can initialize, if not then don't continue
- if (!CanInitialized())
+ if (!CanInitialize())
{
return;
}
@@ -173,7 +173,8 @@ namespace UmbracoExamine
/// Returns true if the Umbraco application is in a state that we can initialize the examine indexes
///
///
- protected bool CanInitialized()
+ [SecuritySafeCritical]
+ protected bool CanInitialize()
{
//We need to check if we actually can initialize, if not then don't continue
if (ApplicationContext.Current == null
diff --git a/src/UmbracoExamine/DataServices/UmbracoMediaService.cs b/src/UmbracoExamine/DataServices/UmbracoMediaService.cs
index a324903c41..c1bd2c71d3 100644
--- a/src/UmbracoExamine/DataServices/UmbracoMediaService.cs
+++ b/src/UmbracoExamine/DataServices/UmbracoMediaService.cs
@@ -19,12 +19,14 @@ namespace UmbracoExamine.DataServices
{
private readonly ServiceContext _services;
+ [SecuritySafeCritical]
public UmbracoMediaService()
: this(ApplicationContext.Current.Services)
{
}
+ [SecuritySafeCritical]
public UmbracoMediaService(ServiceContext services)
{
_services = services;
diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs
index 1fb1a19c69..7d3f22a187 100644
--- a/src/UmbracoExamine/UmbracoContentIndexer.cs
+++ b/src/UmbracoExamine/UmbracoContentIndexer.cs
@@ -121,7 +121,7 @@ namespace UmbracoExamine
{
//We need to check if we actually can initialize, if not then don't continue
- if (!CanInitialized())
+ if (!CanInitialize())
{
return;
}
diff --git a/src/UmbracoExamine/UmbracoExamineSearcher.cs b/src/UmbracoExamine/UmbracoExamineSearcher.cs
index b0fc1a54e9..a123bb4160 100644
--- a/src/UmbracoExamine/UmbracoExamineSearcher.cs
+++ b/src/UmbracoExamine/UmbracoExamineSearcher.cs
@@ -34,7 +34,7 @@ namespace UmbracoExamine
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
//We need to check if we actually can initialize, if not then don't continue
- if (!CanInitialized())
+ if (!CanInitialize())
{
return;
}
@@ -70,7 +70,8 @@ namespace UmbracoExamine
/// Returns true if the Umbraco application is in a state that we can initialize the examine indexes
///
///
- protected bool CanInitialized()
+ [SecuritySafeCritical]
+ protected bool CanInitialize()
{
//We need to check if we actually can initialize, if not then don't continue
if (ApplicationContext.Current == null
diff --git a/src/umbraco.businesslogic/User.cs b/src/umbraco.businesslogic/User.cs
index 3320e4fd9c..0f1e5d4946 100644
--- a/src/umbraco.businesslogic/User.cs
+++ b/src/umbraco.businesslogic/User.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using Umbraco.Core;
using Umbraco.Core.Logging;
using umbraco.DataLayer;
using System.Collections.Generic;
@@ -645,7 +646,7 @@ namespace umbraco.BusinessLogic
{
this.LoginName = DateTime.Now.ToString("yyyyMMdd") + "_" + this.LoginName;
}
-
+ this.Save();
}
///
@@ -890,12 +891,11 @@ namespace umbraco.BusinessLogic
///
/// Flushes the user from cache.
///
+ [Obsolete("This method should not be used, cache flushing is handled automatically by event handling in the web application and ensures that all servers are notified, this will not notify all servers in a load balanced environment")]
public void FlushFromCache()
{
OnFlushingFromCache(EventArgs.Empty);
-
- if (System.Web.HttpRuntime.Cache[string.Format("UmbracoUser{0}", Id.ToString())] != null)
- System.Web.HttpRuntime.Cache.Remove(string.Format("UmbracoUser{0}", Id.ToString()));
+ ApplicationContext.Current.ApplicationCache.ClearCacheItem(string.Format("UmbracoUser{0}", Id.ToString()));
}
///
@@ -905,22 +905,19 @@ namespace umbraco.BusinessLogic
///
public static User GetUser(int id)
{
- if (System.Web.HttpRuntime.Cache[string.Format("UmbracoUser{0}", id.ToString())] == null)
- {
-
- try
- {
- User u = new User(id);
- System.Web.HttpRuntime.Cache.Insert(string.Format("UmbracoUser{0}", id.ToString()), u);
- }
- catch (ArgumentException)
- {
- //no user was found
- return null;
- }
-
- }
- return (User)System.Web.HttpRuntime.Cache[string.Format("UmbracoUser{0}", id.ToString())];
+ return ApplicationContext.Current.ApplicationCache.GetCacheItem(
+ string.Format("UmbracoUser{0}", id.ToString()), () =>
+ {
+ try
+ {
+ return new User(id);
+ }
+ catch (ArgumentException)
+ {
+ //no user was found
+ return null;
+ }
+ });
}
diff --git a/src/umbraco.cms/businesslogic/skinning/tasks/ModifyPageProperty.cs b/src/umbraco.cms/businesslogic/skinning/tasks/ModifyPageProperty.cs
index 933715c4ad..cba9da77fb 100644
--- a/src/umbraco.cms/businesslogic/skinning/tasks/ModifyPageProperty.cs
+++ b/src/umbraco.cms/businesslogic/skinning/tasks/ModifyPageProperty.cs
@@ -34,7 +34,7 @@ namespace umbraco.cms.businesslogic.skinning.tasks
d.OriginalValue = doc.getProperty(PropertyAlias).Value.ToString();
doc.getProperty(PropertyAlias).Value = Value;
- doc.Publish(new BusinessLogic.User(0));
+ doc.SaveAndPublish(new BusinessLogic.User(0));
d.NewValue = Value;
d.TaskExecutionStatus = TaskExecutionStatus.Completed;
diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs
index 4d11f82e47..93b1dd95e3 100644
--- a/src/umbraco.cms/businesslogic/web/Document.cs
+++ b/src/umbraco.cms/businesslogic/web/Document.cs
@@ -801,7 +801,7 @@ namespace umbraco.cms.businesslogic.web
if (!e.Cancel)
{
- var result = ((ContentService)ApplicationContext.Current.Services.ContentService).Publish(Content, false, u.Id);
+ var result = ((ContentService)ApplicationContext.Current.Services.ContentService).PublishInternal(Content, u.Id);
_published = result.Success;
FireAfterPublish(e);
@@ -817,7 +817,8 @@ namespace umbraco.cms.businesslogic.web
[Obsolete("Obsolete, Use Umbraco.Core.Services.ContentService.PublishWithChildren()", false)]
public bool PublishWithChildrenWithResult(User u)
{
- var result = ((ContentService)ApplicationContext.Current.Services.ContentService).PublishWithChildren(Content, false, u.Id);
+ var result = ((ContentService)ApplicationContext.Current.Services.ContentService)
+ .PublishWithChildrenInternal(Content, u.Id);
//This used to just return false only when the parent content failed, otherwise would always return true so we'll
// do the same thing for the moment
return result.Single(x => x.Result.ContentItem.Id == Id).Success;
@@ -857,7 +858,8 @@ namespace umbraco.cms.businesslogic.web
if (!e.Cancel)
{
- var publishedResults = ((ContentService)ApplicationContext.Current.Services.ContentService).PublishWithChildren(Content, false, u.Id);
+ var publishedResults = ((ContentService)ApplicationContext.Current.Services.ContentService)
+ .PublishWithChildrenInternal(Content, u.Id);
FireAfterPublish(e);
}
@@ -872,7 +874,7 @@ namespace umbraco.cms.businesslogic.web
if (!e.Cancel)
{
- _published = ((ContentService)ApplicationContext.Current.Services.ContentService).UnPublish(Content, false, 0);
+ _published = ((ContentService)ApplicationContext.Current.Services.ContentService).UnPublish(Content);
FireAfterUnPublish(e);
}
@@ -931,7 +933,7 @@ namespace umbraco.cms.businesslogic.web
{
//NOTE: The 'false' parameter will cause the PublishingStrategy events to fire which will ensure that the cache is refreshed.
var result = ((ContentService)ApplicationContext.Current.Services.ContentService)
- .SaveAndPublish(Content, false, u.Id);
+ .SaveAndPublishInternal(Content, u.Id);
//NOTE: This is just going to call the CMSNode Save which will launch into the CMSNode.BeforeSave and CMSNode.AfterSave evenths
// which actually do dick all and there's no point in even having them there but just in case for some insane reason someone
diff --git a/src/umbraco.interfaces/ICacheRefresher.cs b/src/umbraco.interfaces/ICacheRefresher.cs
index a402682b33..21f454ca66 100644
--- a/src/umbraco.interfaces/ICacheRefresher.cs
+++ b/src/umbraco.interfaces/ICacheRefresher.cs
@@ -7,9 +7,10 @@ namespace umbraco.interfaces
/// The IcacheRefresher Interface is used for loadbalancing.
///
///
- public interface ICacheRefresher {
- Guid UniqueIdentifier { get;}
- string Name { get;}
+ public interface ICacheRefresher
+ {
+ Guid UniqueIdentifier { get; }
+ string Name { get; }
void RefreshAll();
void Refresh(int Id);
void Remove(int Id);
diff --git a/src/umbraco.providers/UsersMembershipProvider.cs b/src/umbraco.providers/UsersMembershipProvider.cs
index e0216d0ccb..e90d7b2495 100644
--- a/src/umbraco.providers/UsersMembershipProvider.cs
+++ b/src/umbraco.providers/UsersMembershipProvider.cs
@@ -248,6 +248,7 @@ namespace umbraco.providers
User user = new User(username);
string encodedPassword = EncodePassword(newPassword);
user.Password = encodedPassword;
+ user.Save();
return (user.ValidatePassword(encodedPassword)) ? true : false;
}
@@ -525,6 +526,7 @@ namespace umbraco.providers
{
User user = new User(userName);
user.Disabled = false;
+ user.Save();
}
catch (Exception)
{