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)
82493: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 82483: An event is published when a file/folder is added using the FavouriteService git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@83290 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -45,5 +45,6 @@
|
|||||||
<property name="personService" ref="PersonService"/>
|
<property name="personService" ref="PersonService"/>
|
||||||
<property name="permissionService" ref="PermissionService"/>
|
<property name="permissionService" ref="PermissionService"/>
|
||||||
<property name="authenticationContext" ref="authenticationContext"/>
|
<property name="authenticationContext" ref="authenticationContext"/>
|
||||||
|
<property name="eventPublisher" ref="eventPublisher" />
|
||||||
</bean>
|
</bean>
|
||||||
</beans>
|
</beans>
|
@@ -15,10 +15,16 @@ import java.util.StringTokenizer;
|
|||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.events.types.ActivityEvent;
|
||||||
|
import org.alfresco.events.types.Event;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.query.PageDetails;
|
import org.alfresco.query.PageDetails;
|
||||||
import org.alfresco.query.PagingRequest;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
|
import org.alfresco.repo.Client;
|
||||||
|
import org.alfresco.repo.Client.ClientType;
|
||||||
|
import org.alfresco.repo.events.EventPreparator;
|
||||||
|
import org.alfresco.repo.events.EventPublisher;
|
||||||
import org.alfresco.repo.favourites.PersonFavourite.PersonFavouriteKey;
|
import org.alfresco.repo.favourites.PersonFavourite.PersonFavouriteKey;
|
||||||
import org.alfresco.repo.policy.ClassPolicy;
|
import org.alfresco.repo.policy.ClassPolicy;
|
||||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||||
@@ -65,6 +71,7 @@ public class FavouritesServiceImpl implements FavouritesService, InitializingBea
|
|||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
|
private EventPublisher eventPublisher;
|
||||||
|
|
||||||
/** Authentication Service */
|
/** Authentication Service */
|
||||||
private AuthenticationContext authenticationContext;
|
private AuthenticationContext authenticationContext;
|
||||||
@@ -645,12 +652,25 @@ public class FavouritesServiceImpl implements FavouritesService, InitializingBea
|
|||||||
if(personFavourite == null)
|
if(personFavourite == null)
|
||||||
{
|
{
|
||||||
Date createdAt = new Date();
|
Date createdAt = new Date();
|
||||||
String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
final String name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
personFavourite = new PersonFavourite(userName, nodeRef, type, name, createdAt);
|
personFavourite = new PersonFavourite(userName, nodeRef, type, name, createdAt);
|
||||||
personFavourites.put(personFavourite.getKey(), personFavourite);
|
personFavourites.put(personFavourite.getKey(), personFavourite);
|
||||||
updateFavouriteNodes(userName, type, personFavourites);
|
updateFavouriteNodes(userName, type, personFavourites);
|
||||||
|
|
||||||
QName nodeClass = nodeService.getType(nodeRef);
|
QName nodeClass = nodeService.getType(nodeRef);
|
||||||
|
final String finalRef = nodeRef.getId();
|
||||||
|
final QName nodeType = nodeClass;
|
||||||
|
|
||||||
|
eventPublisher.publishEvent(new EventPreparator(){
|
||||||
|
@Override
|
||||||
|
public Event prepareEvent(String user, String networkId, String transactionId)
|
||||||
|
{
|
||||||
|
return new ActivityEvent("favorite.added", transactionId, networkId, user, finalRef,
|
||||||
|
null, nodeType==null?null:nodeType.toString(), Client.asType(ClientType.script), null,
|
||||||
|
name, null, 0l, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
OnAddFavouritePolicy policy = onAddFavouriteDelegate.get(nodeRef, nodeClass);
|
OnAddFavouritePolicy policy = onAddFavouriteDelegate.get(nodeRef, nodeClass);
|
||||||
policy.onAddFavourite(userName, nodeRef);
|
policy.onAddFavourite(userName, nodeRef);
|
||||||
}
|
}
|
||||||
@@ -709,6 +729,19 @@ public class FavouritesServiceImpl implements FavouritesService, InitializingBea
|
|||||||
updateFavouriteNodes(userName, type, personFavourites);
|
updateFavouriteNodes(userName, type, personFavourites);
|
||||||
|
|
||||||
QName nodeClass = nodeService.getType(nodeRef);
|
QName nodeClass = nodeService.getType(nodeRef);
|
||||||
|
final String finalRef = nodeRef.getId();
|
||||||
|
final QName nodeType = nodeClass;
|
||||||
|
|
||||||
|
eventPublisher.publishEvent(new EventPreparator(){
|
||||||
|
@Override
|
||||||
|
public Event prepareEvent(String user, String networkId, String transactionId)
|
||||||
|
{
|
||||||
|
return new ActivityEvent("favorite.removed", transactionId, networkId, user, finalRef,
|
||||||
|
null, nodeType==null?null:nodeType.toString(), Client.asType(ClientType.script), null,
|
||||||
|
null, null, 0l, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
OnRemoveFavouritePolicy policy = onRemoveFavouriteDelegate.get(nodeRef, nodeClass);
|
OnRemoveFavouritePolicy policy = onRemoveFavouriteDelegate.get(nodeRef, nodeClass);
|
||||||
policy.onRemoveFavourite(userName, nodeRef);
|
policy.onRemoveFavourite(userName, nodeRef);
|
||||||
|
|
||||||
@@ -921,4 +954,9 @@ public class FavouritesServiceImpl implements FavouritesService, InitializingBea
|
|||||||
Type type = getType(nodeRef);
|
Type type = getType(nodeRef);
|
||||||
return getPersonFavourite(userName, type, nodeRef);
|
return getPersonFavourite(userName, type, nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEventPublisher(EventPublisher eventPublisher)
|
||||||
|
{
|
||||||
|
this.eventPublisher = eventPublisher;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user