mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
82394: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 80104: Bug fixed user Create / Update event generation, mistakenly creating multiple events. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@83237 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -997,6 +997,8 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
|
||||
removeFromCache(userName, false);
|
||||
|
||||
publishEvent("user.create", this.nodeService.getProperties(personRef));
|
||||
|
||||
return personRef;
|
||||
}
|
||||
|
||||
@@ -1758,8 +1760,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
{
|
||||
makeHomeFolderAsSystem(childAssocRef);
|
||||
}
|
||||
|
||||
reportEvent("user.create", this.nodeService.getProperties(personRef));
|
||||
|
||||
}
|
||||
|
||||
private QName getChildNameLower(String userName)
|
||||
@@ -1991,11 +1992,42 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
}
|
||||
}
|
||||
|
||||
reportEvent("user.update", after);
|
||||
|
||||
if(validUserUpdateEvent(before, after))
|
||||
{
|
||||
publishEvent("user.update", after);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the updated properties constitute a valid user update.
|
||||
* Currently we only check for updates to the user firstname, lastname
|
||||
*
|
||||
* @param before
|
||||
* @param after
|
||||
* @return
|
||||
*/
|
||||
private boolean validUserUpdateEvent(Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
final String firstnameBefore = (String)before.get(ContentModel.PROP_FIRSTNAME);
|
||||
final String lastnameBefore = (String)before.get(ContentModel.PROP_LASTNAME);
|
||||
final String firstnameAfter = (String)after.get(ContentModel.PROP_FIRSTNAME);
|
||||
final String lastnameAfter = (String)after.get(ContentModel.PROP_LASTNAME);
|
||||
|
||||
boolean updatedFirstName = !EqualsHelper.nullSafeEquals(firstnameBefore, firstnameAfter);
|
||||
boolean updatedLastName = !EqualsHelper.nullSafeEquals(lastnameBefore, lastnameAfter);
|
||||
|
||||
return updatedFirstName || updatedLastName;
|
||||
}
|
||||
|
||||
private void reportEvent(String eventType, Map<QName, Serializable> properties)
|
||||
/**
|
||||
* Publish new user event
|
||||
*
|
||||
* @param eventType
|
||||
* @param properties
|
||||
*/
|
||||
private void publishEvent(String eventType, Map<QName, Serializable> properties)
|
||||
{
|
||||
if(properties == null) return;
|
||||
|
||||
|
Reference in New Issue
Block a user