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)
82385: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 79093: Added event generation for User update and create git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@83228 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,6 +22,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -31,6 +32,8 @@ import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.events.types.Event;
|
||||
import org.alfresco.events.types.UserManagementEvent;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryResults;
|
||||
@@ -40,6 +43,8 @@ import org.alfresco.repo.action.executer.MailActionExecuter;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.repo.cache.TransactionalCache;
|
||||
import org.alfresco.repo.domain.permissions.AclDAO;
|
||||
import org.alfresco.repo.events.EventPreparator;
|
||||
import org.alfresco.repo.events.EventPublisher;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.BeforeCreateNodePolicy;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
|
||||
@@ -148,6 +153,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
private String duplicateMode = LEAVE;
|
||||
private boolean lastIsBest = true;
|
||||
private boolean includeAutoCreated = false;
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
private NamedObjectRegistry<CannedQueryFactory<NodeRef>> cannedQueryRegistry;
|
||||
|
||||
@@ -972,7 +978,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
getPeopleContainer(),
|
||||
ContentModel.ASSOC_CHILDREN,
|
||||
getChildNameLower(userName), // Lowercase:
|
||||
ContentModel.TYPE_PERSON, properties).getChildRef();
|
||||
ContentModel.TYPE_PERSON, properties).getChildRef();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1752,6 +1758,8 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
{
|
||||
makeHomeFolderAsSystem(childAssocRef);
|
||||
}
|
||||
|
||||
reportEvent("user.create", this.nodeService.getProperties(personRef));
|
||||
}
|
||||
|
||||
private QName getChildNameLower(String userName)
|
||||
@@ -1982,6 +1990,28 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
throw new UnsupportedOperationException("The user name on a person can not be changed");
|
||||
}
|
||||
}
|
||||
|
||||
reportEvent("user.update", after);
|
||||
}
|
||||
|
||||
|
||||
private void reportEvent(String eventType, Map<QName, Serializable> properties)
|
||||
{
|
||||
if(properties == null) return;
|
||||
|
||||
final String managedUsername = (String)properties.get(ContentModel.PROP_USERNAME);
|
||||
final String managedFirstname = (String)properties.get(ContentModel.PROP_FIRSTNAME);
|
||||
final String managedLastname = (String)properties.get(ContentModel.PROP_LASTNAME);
|
||||
final String eventTType = eventType;
|
||||
|
||||
eventPublisher.publishEvent(new EventPreparator(){
|
||||
@Override
|
||||
public Event prepareEvent(String user, String networkId, String transactionId)
|
||||
{
|
||||
return new UserManagementEvent(eventTType , transactionId, networkId,new Date().getTime(),
|
||||
user, managedUsername,managedFirstname,managedLastname);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2141,4 +2171,11 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setEventPublisher(EventPublisher eventPublisher)
|
||||
{
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user