Merge remote-tracking branch 'origin/6.2.0' into 6.2.0

This commit is contained in:
Stephan
2014-03-06 08:49:38 +01:00
12 changed files with 154 additions and 112 deletions

View File

@@ -15,7 +15,7 @@ namespace Umbraco.Core.Services
public interface IMembershipMemberService : IMembershipMemberService<IMember>, IMembershipRoleService<IMember>
{
IMember CreateMember(string username, string email, string password, string memberType);
IMember CreateMemberWithIdentity(string username, string email, string password, IMemberType memberType, bool raiseEvents = true);
IMember CreateMemberWithIdentity(string username, string email, string password, IMemberType memberType);
}
/// <summary>
@@ -47,9 +47,8 @@ namespace Umbraco.Core.Services
/// <param name="email"></param>
/// <param name="password"></param>
/// <param name="memberTypeAlias"></param>
/// <param name="raiseEvents"></param>
/// <returns></returns>
T CreateWithIdentity(string username, string email, string password, string memberTypeAlias, bool raiseEvents = true);
T CreateWithIdentity(string username, string email, string password, string memberTypeAlias);
/// <summary>
/// Gets the member by the provider key

View File

@@ -11,7 +11,7 @@ namespace Umbraco.Core.Services
public interface IMembershipUserService : IMembershipMemberService<IUser>
{
IUser CreateMemberWithIdentity(string username, string email, string password, IUserType userType, bool raiseEvents = true);
IUser CreateUserWithIdentity(string username, string email, string password, IUserType userType);
}
}

View File

@@ -587,19 +587,16 @@ namespace Umbraco.Core.Services
return member;
}
public IMember CreateMemberWithIdentity(string username, string email, string password, IMemberType memberType, bool raiseEvents = true)
public IMember CreateMemberWithIdentity(string username, string email, string password, IMemberType memberType)
{
if (memberType == null) throw new ArgumentNullException("memberType");
var member = new Member(username, email.ToLower().Trim(), username, password, -1, memberType);
if (raiseEvents)
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IMember>(member), this))
{
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IMember>(member), this))
{
member.WasCancelled = true;
return member;
}
member.WasCancelled = true;
return member;
}
var uow = _uowProvider.GetUnitOfWork();
@@ -613,12 +610,12 @@ namespace Umbraco.Core.Services
CreateAndSaveMemberXml(xml, member.Id, uow.Database);
}
if (raiseEvents)
Saved.RaiseEvent(new SaveEventArgs<IMember>(member, false), this);
Saved.RaiseEvent(new SaveEventArgs<IMember>(member, false), this);
Created.RaiseEvent(new NewEventArgs<IMember>(member, false, memberType.Alias, -1), this);
return member;
}
/// <summary>
/// Creates and persists a new Member
/// </summary>
@@ -626,9 +623,8 @@ namespace Umbraco.Core.Services
/// <param name="username"></param>
/// <param name="password"></param>
/// <param name="memberTypeAlias"></param>
/// <param name="raiseEvents"></param>
/// <returns></returns>
public IMember CreateWithIdentity(string username, string email, string password, string memberTypeAlias, bool raiseEvents = true)
IMember IMembershipMemberService<IMember>.CreateWithIdentity(string username, string email, string password, string memberTypeAlias)
{
var uow = _uowProvider.GetUnitOfWork();
IMemberType memberType;
@@ -644,7 +640,7 @@ namespace Umbraco.Core.Services
throw new ArgumentException(string.Format("No MemberType matching the passed in Alias: '{0}' was found", memberTypeAlias));
}
return CreateMemberWithIdentity(username, email, password, memberType, raiseEvents);
return CreateMemberWithIdentity(username, email, password, memberType);
}
/// <summary>

View File

@@ -75,7 +75,7 @@ namespace Umbraco.Core.Services
}
}
public IUser CreateMemberWithIdentity(string username, string email, string password, IUserType userType, bool raiseEvents = true)
public IUser CreateUserWithIdentity(string username, string email, string password, IUserType userType)
{
if (userType == null) throw new ArgumentNullException("userType");
@@ -103,23 +103,19 @@ namespace Umbraco.Core.Services
IsApproved = true
};
if (raiseEvents)
{
if (SavingUser.IsRaisedEventCancelled(new SaveEventArgs<IUser>(user), this))
return user;
}
if (SavingUser.IsRaisedEventCancelled(new SaveEventArgs<IUser>(user), this))
return user;
repository.AddOrUpdate(user);
uow.Commit();
if (raiseEvents)
SavedUser.RaiseEvent(new SaveEventArgs<IUser>(user, false), this);
SavedUser.RaiseEvent(new SaveEventArgs<IUser>(user, false), this);
return user;
}
}
public IUser CreateWithIdentity(string username, string email, string password, string memberTypeAlias, bool raiseEvents = true)
IUser IMembershipMemberService<IUser>.CreateWithIdentity(string username, string email, string password, string memberTypeAlias)
{
var userType = GetUserTypeByAlias(memberTypeAlias);
if (userType == null)
@@ -127,7 +123,7 @@ namespace Umbraco.Core.Services
throw new ArgumentException("The user type " + memberTypeAlias + " could not be resolved");
}
return CreateMemberWithIdentity(username, email, password, userType);
return CreateUserWithIdentity(username, email, password, userType);
}
public IUser GetById(int id)

View File

@@ -94,7 +94,7 @@ namespace Umbraco.Tests.Membership
mServiceMock.Setup(service => service.GetByEmail("test@test.com")).Returns(() => null);
mServiceMock.Setup(service => service.GetDefaultMemberType()).Returns("Member");
mServiceMock.Setup(
service => service.CreateWithIdentity(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>()))
service => service.CreateWithIdentity(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
.Callback((string u, string e, string p, string m, bool b) =>
{
createdMember = new Member("test", e, u, p, memberType);
@@ -125,7 +125,7 @@ namespace Umbraco.Tests.Membership
mServiceMock.Setup(service => service.GetByEmail("test@test.com")).Returns(() => null);
mServiceMock.Setup(service => service.GetDefaultMemberType()).Returns("Member");
mServiceMock.Setup(
service => service.CreateWithIdentity(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>()))
service => service.CreateWithIdentity(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
.Callback((string u, string e, string p, string m, bool b) =>
{
createdMember = new Member("test", e, u, p, memberType);
@@ -158,7 +158,7 @@ namespace Umbraco.Tests.Membership
mServiceMock.Setup(service => service.GetByEmail("test@test.com")).Returns(() => null);
mServiceMock.Setup(service => service.GetDefaultMemberType()).Returns("Member");
mServiceMock.Setup(
service => service.CreateWithIdentity(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>()))
service => service.CreateWithIdentity(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
.Callback((string u, string e, string p, string m, bool b) =>
{
createdMember = new Member("test", e, u, p, memberType);

View File

@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Services
// Arrange
var userService = ServiceContext.UserService;
var userType = userService.GetUserTypeByAlias("admin");
var user = ServiceContext.UserService.CreateMemberWithIdentity("test1", "test1@test.com", "123456", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("test1", "test1@test.com", "123456", userType);
var contentType = MockedContentTypes.CreateSimpleContentType();
ServiceContext.ContentTypeService.Save(contentType);
var content = new[]
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.Services
// Arrange
var userService = ServiceContext.UserService;
var userType = userService.GetUserTypeByAlias("admin");
var user = ServiceContext.UserService.CreateMemberWithIdentity("test1", "test1@test.com", "123456", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("test1", "test1@test.com", "123456", userType);
var contentType = MockedContentTypes.CreateSimpleContentType();
ServiceContext.ContentTypeService.Save(contentType);
var content = new[]
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
ServiceContext.UserService.Delete(user, true);
var deleted = ServiceContext.UserService.GetUserById(user.Id);
@@ -111,7 +111,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
ServiceContext.UserService.Delete(user);
var deleted = ServiceContext.UserService.GetUserById(user.Id);
@@ -125,7 +125,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
Assert.IsTrue(ServiceContext.UserService.Exists("JohnDoe"));
Assert.IsFalse(ServiceContext.UserService.Exists("notFound"));
@@ -136,7 +136,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
Assert.IsNotNull(ServiceContext.UserService.GetByEmail(user.Email));
Assert.IsNull(ServiceContext.UserService.GetByEmail("do@not.find"));
@@ -147,7 +147,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
Assert.IsNotNull(ServiceContext.UserService.GetByUsername(user.Username));
Assert.IsNull(ServiceContext.UserService.GetByUsername("notFound"));
@@ -158,7 +158,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("mydomain\\JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("mydomain\\JohnDoe", "john@umbraco.io", "12345", userType);
Assert.IsNotNull(ServiceContext.UserService.GetByUsername(user.Username));
Assert.IsNull(ServiceContext.UserService.GetByUsername("notFound"));
@@ -169,7 +169,7 @@ namespace Umbraco.Tests.Services
{
var userType = MockedUserType.CreateUserType();
ServiceContext.UserService.SaveUserType(userType);
var user = ServiceContext.UserService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
Assert.IsNotNull(ServiceContext.UserService.GetUserById(user.Id));
Assert.IsNull(ServiceContext.UserService.GetUserById(9876));
@@ -351,7 +351,7 @@ namespace Umbraco.Tests.Services
var userType = userService.GetUserTypeByAlias("admin");
// Act
var membershipUser = userService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
var membershipUser = userService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", "12345", userType);
// Assert
Assert.That(membershipUser.HasIdentity, Is.True);
@@ -374,7 +374,7 @@ namespace Umbraco.Tests.Services
var hash = new HMACSHA1();
hash.Key = Encoding.Unicode.GetBytes(password);
var encodedPassword = Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password)));
var membershipUser = userService.CreateMemberWithIdentity("JohnDoe", "john@umbraco.io", encodedPassword, userType);
var membershipUser = userService.CreateUserWithIdentity("JohnDoe", "john@umbraco.io", encodedPassword, userType);
// Assert
Assert.That(membershipUser.HasIdentity, Is.True);
@@ -390,8 +390,8 @@ namespace Umbraco.Tests.Services
{
var userType = ServiceContext.UserService.GetUserTypeByAlias("admin");
var user1 = ServiceContext.UserService.CreateMemberWithIdentity("test1", "test1@test.com", "test1", userType);
var user2 = ServiceContext.UserService.CreateMemberWithIdentity("test2", "test2@test.com", "test2", userType);
var user1 = ServiceContext.UserService.CreateUserWithIdentity("test1", "test1@test.com", "test1", userType);
var user2 = ServiceContext.UserService.CreateUserWithIdentity("test2", "test2@test.com", "test2", userType);
//adds some allowed sections
user1.AddAllowedSection("test");
@@ -415,7 +415,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var userType = ServiceContext.UserService.GetUserTypeByAlias("admin");
var user = ServiceContext.UserService.CreateMemberWithIdentity("test1", "test1@test.com", "test1", userType);
var user = ServiceContext.UserService.CreateUserWithIdentity("test1", "test1@test.com", "test1", userType);
// Act
@@ -432,7 +432,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var userType = ServiceContext.UserService.GetUserTypeByAlias("admin");
var user = (IUser)ServiceContext.UserService.CreateMemberWithIdentity("test1", "test1@test.com", "test1", userType);
var user = (IUser)ServiceContext.UserService.CreateUserWithIdentity("test1", "test1@test.com", "test1", userType);
// Act
@@ -449,7 +449,7 @@ namespace Umbraco.Tests.Services
{
// Arrange
var userType = ServiceContext.UserService.GetUserTypeByAlias("admin");
var originalUser = (User)ServiceContext.UserService.CreateMemberWithIdentity("test1", "test1@test.com", "test1", userType);
var originalUser = (User)ServiceContext.UserService.CreateUserWithIdentity("test1", "test1@test.com", "test1", userType);
// Act

View File

@@ -1,25 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<trees>
<!--Content-->
<add application="content" alias="content" title="Content" type="umbraco.loadContent, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" silent="true" sortOrder="0" />
<add application="content" alias="contentRecycleBin" title="RecycleBin" type="umbraco.cms.presentation.Trees.ContentRecycleBin, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" initialize="false" sortOrder="0" />
<!--Media-->
<add application="media" alias="media" title="Media" type="umbraco.loadMedia, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="0" />
<add application="media" alias="mediaRecycleBin" title="RecycleBin" type="umbraco.cms.presentation.Trees.MediaRecycleBin, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" initialize="false" sortOrder="0" />
<!--Settings-->
<add application="settings" alias="stylesheets" title="Stylesheets" type="umbraco.loadStylesheets, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="0" />
<add application="settings" alias="stylesheetProperty" title="Stylesheet Property" type="umbraco.loadStylesheetProperty, umbraco" iconClosed="" iconOpen="" initialize="false" sortOrder="0" />
<add application="settings" alias="templates" title="Templates" type="umbraco.loadTemplates, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="1" />
<add application="settings" alias="partialViews" title="Partial Views" silent="false" initialize="true" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" type="Umbraco.Web.Trees.PartialViewsTree, umbraco" sortOrder="2" />
<add application="settings" alias="scripts" title="Scripts" type="umbraco.loadScripts, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="3" />
<add application="settings" alias="partialViews" title="Partial Views" silent="false" initialize="true" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" type="Umbraco.Web.Trees.PartialViewsTree, umbraco" sortOrder="2" />
<add application="settings" alias="scripts" title="Scripts" type="umbraco.loadScripts, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="3" />
<add application="settings" alias="dictionary" title="Dictionary" type="umbraco.loadDictionary, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" action="openDictionary()" sortOrder="4" />
<add application="settings" alias="languages" title="Languages" type="umbraco.loadLanguages, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="5" />
<add application="settings" alias="mediaTypes" title="Media Types" type="umbraco.loadMediaTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="6" />
<add application="settings" alias="nodeTypes" title="Document Types" type="umbraco.loadNodeTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="7" />
<!--Developer-->
<add application="developer" alias="datatype" title="Data Types" type="umbraco.loadDataTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="1" />
<add application="developer" alias="macros" title="Macros" type="umbraco.loadMacros, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="2" />
@@ -28,24 +24,19 @@
<add application="developer" alias="relationTypes" title="Relation Types" type="umbraco.loadRelationTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="4" />
<add application="developer" alias="python" title="Scripting Files" type="umbraco.loadPython, umbraco" iconClosed="folder.gif" iconOpen="folder_o.gif" sortOrder="4" />
<add application="developer" alias="xslt" title="XSLT Files" type="umbraco.loadXslt, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="5" />
<add application="developer" alias="partialViewMacros" type="Umbraco.Web.Trees.PartialViewMacrosTree, umbraco" silent="false" initialize="true" sortOrder="6" title="Partial View Macro Files" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" />
<add application="developer" alias="partialViewMacros" type="Umbraco.Web.Trees.PartialViewMacrosTree, umbraco" silent="false" initialize="true" sortOrder="6" title="Partial View Macro Files" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" />
<!--Users-->
<add application="users" alias="users" title="Users" type="umbraco.loadUsers, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="0" />
<add application="users" alias="userTypes" title="User Types" type="umbraco.cms.presentation.Trees.UserTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="1" />
<add application="users" alias="userPermissions" title="User Permissions" type="umbraco.cms.presentation.Trees.UserPermissions, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="2" />
<!--Members-->
<add application="member" alias="member" title="Members" type="umbraco.loadMembers, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="0" />
<add application="member" alias="memberGroup" title="Member Groups" type="umbraco.loadMemberGroups, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="1" />
<add application="member" alias="memberType" title="Member Types" type="umbraco.loadMemberTypes, umbraco" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="2" />
<!--Translation-->
<add silent="false" initialize="true" sortOrder="1" alias="openTasks" application="translation" title="Tasks assigned to you" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" type="umbraco.loadOpenTasks, umbraco" action="" />
<add silent="false" initialize="true" sortOrder="2" alias="yourTasks" application="translation" title="Tasks created by you" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" type="umbraco.loadYourTasks, umbraco" action="" />
<!-- Custom -->
<!--<add application="myApplication" alias="myTree" title="Me Tree" type="MyNamespace.myTree, MyAssembly"
iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" sortOrder="10" />-->
</trees>

View File

@@ -224,7 +224,7 @@
</scheduledTasks>
<!-- distributed calls make umbraco use webservices to handle cache refreshing -->
<distributedCall enable="false">
<distributedCall enable="true">
<!-- the id of the user who's making the calls -->
<!-- needed for security, umbraco will automatically look up correct login and passwords -->
<user>0</user>
@@ -233,7 +233,7 @@
<!-- you can also add optional attributes to force a protocol or port number (see #2) -->
<!-- <server>127.0.0.1</server>-->
<!-- <server forceProtocol="http|https" forcePortnumber="80|443">127.0.0.1</server>-->
<server>umb1.dev</server>
<!--<server>umb1.dev</server>-->
<server forcePortnumber="6200">localhost</server>
</servers>
</distributedCall>

View File

@@ -596,22 +596,22 @@ namespace Umbraco.Web.Cache
#endregion
#region Media event handlers
static void MediaServiceTrashing(IMediaService sender, Core.Events.MoveEventArgs<IMedia> e)
static void MediaServiceTrashing(IMediaService sender, MoveEventArgs<IMedia> e)
{
DistributedCache.Instance.RemoveMediaCache(false, e.Entity);
}
static void MediaServiceMoving(IMediaService sender, Core.Events.MoveEventArgs<IMedia> e)
static void MediaServiceMoving(IMediaService sender, MoveEventArgs<IMedia> e)
{
DistributedCache.Instance.RefreshMediaCache(e.Entity);
}
static void MediaServiceDeleting(IMediaService sender, Core.Events.DeleteEventArgs<IMedia> e)
static void MediaServiceDeleting(IMediaService sender, DeleteEventArgs<IMedia> e)
{
DistributedCache.Instance.RemoveMediaCache(true, e.DeletedEntities.ToArray());
}
static void MediaServiceSaved(IMediaService sender, Core.Events.SaveEventArgs<IMedia> e)
static void MediaServiceSaved(IMediaService sender, SaveEventArgs<IMedia> e)
{
DistributedCache.Instance.RefreshMediaCache(e.SavedEntities.ToArray());
}
@@ -619,27 +619,21 @@ namespace Umbraco.Web.Cache
#region Member event handlers
static void MemberServiceDeleted(IMemberService sender, Core.Events.DeleteEventArgs<IMember> e)
static void MemberServiceDeleted(IMemberService sender, DeleteEventArgs<IMember> e)
{
foreach (var m in e.DeletedEntities.ToArray())
{
DistributedCache.Instance.RemoveMemberCache(m.Id);
}
DistributedCache.Instance.RemoveMemberCache(e.DeletedEntities.ToArray());
}
static void MemberServiceSaved(IMemberService sender, Core.Events.SaveEventArgs<IMember> e)
static void MemberServiceSaved(IMemberService sender, SaveEventArgs<IMember> e)
{
foreach (var m in e.SavedEntities.ToArray())
{
DistributedCache.Instance.RefreshMemberCache(m.Id);
}
DistributedCache.Instance.RefreshMemberCache(e.SavedEntities.ToArray());
}
#endregion
#region Member group event handlers
static void MemberGroupService_Deleted(IMemberGroupService sender, Core.Events.DeleteEventArgs<IMemberGroup> e)
static void MemberGroupService_Deleted(IMemberGroupService sender, DeleteEventArgs<IMemberGroup> e)
{
foreach (var m in e.DeletedEntities.ToArray())
{
@@ -647,7 +641,7 @@ namespace Umbraco.Web.Cache
}
}
static void MemberGroupService_Saved(IMemberGroupService sender, Core.Events.SaveEventArgs<IMemberGroup> e)
static void MemberGroupService_Saved(IMemberGroupService sender, SaveEventArgs<IMemberGroup> e)
{
foreach (var m in e.SavedEntities.ToArray())
{

View File

@@ -256,11 +256,33 @@ namespace Umbraco.Web.Cache
#endregion
#region Member cache
/// <summary>
/// Refreshes the cache among servers for a member
/// </summary>
/// <param name="dc"></param>
/// <param name="members"></param>
public static void RefreshMemberCache(this DistributedCache dc, params IMember[] members)
{
dc.Refresh(new Guid(DistributedCache.MemberCacheRefresherId), x => x.Id, members);
}
/// <summary>
/// Removes the cache among servers for a member
/// </summary>
/// <param name="dc"></param>
/// <param name="members"></param>
public static void RemoveMemberCache(this DistributedCache dc, params IMember[] members)
{
dc.Remove(new Guid(DistributedCache.MemberCacheRefresherId), x => x.Id, members);
}
/// <summary>
/// Refreshes the cache among servers for a member
/// </summary>
/// <param name="dc"></param>
/// <param name="memberId"></param>
[Obsolete("Use the RefreshMemberCache with strongly typed IMember objects instead")]
public static void RefreshMemberCache(this DistributedCache dc, int memberId)
{
dc.Refresh(new Guid(DistributedCache.MemberCacheRefresherId), memberId);
@@ -271,6 +293,7 @@ namespace Umbraco.Web.Cache
/// </summary>
/// <param name="dc"></param>
/// <param name="memberId"></param>
[Obsolete("Use the RemoveMemberCache with strongly typed IMember objects instead")]
public static void RemoveMemberCache(this DistributedCache dc, int memberId)
{
dc.Remove(new Guid(DistributedCache.MemberCacheRefresherId), memberId);

View File

@@ -14,7 +14,7 @@ namespace Umbraco.Web.Cache
/// <remarks>
/// This is not intended to be used directly in your code and it should be sealed but due to legacy code we cannot seal it.
/// </remarks>
public class MemberCacheRefresher : CacheRefresherBase<MemberCacheRefresher>
public class MemberCacheRefresher : TypedCacheRefresherBase<MemberCacheRefresher, IMember>
{
protected override MemberCacheRefresher Instance
@@ -44,6 +44,18 @@ namespace Umbraco.Web.Cache
base.Remove(id);
}
public override void Refresh(IMember instance)
{
ClearCache(instance.Id);
base.Remove(instance);
}
public override void Remove(IMember instance)
{
ClearCache(instance.Id);
base.Remove(instance);
}
private void ClearCache(int id)
{
ApplicationContext.Current.ApplicationCache.ClearPartialViewCache();

View File

@@ -60,10 +60,8 @@ namespace Umbraco.Web.Search
CacheRefresherBase<UnpublishedPageCacheRefresher>.CacheUpdated += UnpublishedPageCacheRefresherCacheUpdated;
CacheRefresherBase<PageCacheRefresher>.CacheUpdated += PublishedPageCacheRefresherCacheUpdated;
CacheRefresherBase<MediaCacheRefresher>.CacheUpdated += MediaCacheRefresherCacheUpdated;
CacheRefresherBase<MemberCacheRefresher>.CacheUpdated += MemberCacheRefresherCacheUpdated;
Member.AfterSave += MemberAfterSave;
Member.AfterDelete += MemberAfterDelete;
var contentIndexer = ExamineManager.Instance.IndexProviderCollection["InternalIndexer"] as UmbracoContentIndexer;
if (contentIndexer != null)
{
@@ -76,11 +74,55 @@ namespace Umbraco.Web.Search
}
}
/// <summary>
[SecuritySafeCritical]
static void MemberCacheRefresherCacheUpdated(MemberCacheRefresher sender, CacheRefresherEventArgs e)
{
switch (e.MessageType)
{
case MessageType.RefreshById:
var c1 = ApplicationContext.Current.Services.MemberService.GetById((int)e.MessageObject);
if (c1 != null)
{
ReIndexForMember(c1);
}
break;
case MessageType.RemoveById:
// This is triggered when the item is permanently deleted
DeleteIndexForEntity((int)e.MessageObject, false);
break;
case MessageType.RefreshByInstance:
var c3 = e.MessageObject as IMember;
if (c3 != null)
{
ReIndexForMember(c3);
}
break;
case MessageType.RemoveByInstance:
// This is triggered when the item is permanently deleted
var c4 = e.MessageObject as IMember;
if (c4 != null)
{
DeleteIndexForEntity(c4.Id, false);
}
break;
case MessageType.RefreshAll:
case MessageType.RefreshByJson:
default:
//We don't support these, these message types will not fire for unpublished content
break;
}
}
/// <summary>
/// Handles index management for all media events - basically handling saving/copying/trashing/deleting
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[SecuritySafeCritical]
static void MediaCacheRefresherCacheUpdated(MediaCacheRefresher sender, CacheRefresherEventArgs e)
{
switch (e.MessageType)
@@ -265,24 +307,13 @@ namespace Umbraco.Web.Search
}
[SecuritySafeCritical]
private static void MemberAfterSave(Member sender, SaveEventArgs e)
private static void ReIndexForMember(IMember member)
{
//ensure that only the providers are flagged to listen execute
var xml = ExamineXmlExtensions.ToXElement(sender.ToXml(new System.Xml.XmlDocument(), false));
var providers = ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
.Where(x => x.EnableDefaultEventHandler);
ExamineManager.Instance.ReIndexNode(xml, IndexTypes.Member, providers);
}
[SecuritySafeCritical]
private static void MemberAfterDelete(Member sender, DeleteEventArgs e)
{
var nodeId = sender.Id.ToString();
//ensure that only the providers are flagged to listen execute
ExamineManager.Instance.DeleteFromIndex(nodeId,
ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
.Where(x => x.EnableDefaultEventHandler));
ExamineManager.Instance.ReIndexNode(
member.ToXml(), IndexTypes.Member,
ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
//ensure that only the providers are flagged to listen execute
.Where(x => x.EnableDefaultEventHandler));
}
/// <summary>
@@ -310,14 +341,14 @@ namespace Umbraco.Web.Search
private static void ReIndexForMedia(IMedia sender, bool isMediaPublished)
{
ExamineManager.Instance.ReIndexNode(
sender.ToXml(), "media",
sender.ToXml(), IndexTypes.Media,
ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
//Index this item for all indexers if the media is not trashed, otherwise if the item is trashed
// then only index this for indexers supporting unpublished media
//Index this item for all indexers if the media is not trashed, otherwise if the item is trashed
// then only index this for indexers supporting unpublished media
.Where(x => isMediaPublished || (x.SupportUnpublishedContent))
.Where(x => x.EnableDefaultEventHandler));
.Where(x => isMediaPublished || (x.SupportUnpublishedContent))
.Where(x => x.EnableDefaultEventHandler));
}
/// <summary>
@@ -351,17 +382,17 @@ namespace Umbraco.Web.Search
/// </param>
[SecuritySafeCritical]
private static void ReIndexForContent(IContent sender, bool isContentPublished)
{
ExamineManager.Instance.ReIndexNode(
sender.ToXml(), "content",
ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
{
ExamineManager.Instance.ReIndexNode(
sender.ToXml(), IndexTypes.Content,
ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
//Index this item for all indexers if the content is published, otherwise if the item is not published
// then only index this for indexers supporting unpublished content
//Index this item for all indexers if the content is published, otherwise if the item is not published
// then only index this for indexers supporting unpublished content
.Where(x => isContentPublished || (x.SupportUnpublishedContent))
.Where(x => x.EnableDefaultEventHandler));
}
.Where(x => isContentPublished || (x.SupportUnpublishedContent))
.Where(x => x.EnableDefaultEventHandler));
}
/// <summary>
/// Converts a content node to XDocument