Search in sources :

Example 6 with PersonFavouriteKey

use of org.alfresco.repo.favourites.PersonFavourite.PersonFavouriteKey in project alfresco-repository by Alfresco.

the class FavouritesServiceImpl method removeFavouriteNode.

private boolean removeFavouriteNode(String userName, Type type, NodeRef nodeRef) {
    boolean exists = false;
    Map<PersonFavouriteKey, PersonFavourite> personFavourites = getFavouriteNodes(userName, type);
    PersonFavouriteKey personFavouriteKey = new PersonFavouriteKey(userName, null, type, nodeRef);
    PersonFavourite personFavourite = personFavourites.remove(personFavouriteKey);
    exists = personFavourite != null;
    updateFavouriteNodes(userName, type, personFavourites);
    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);
    policy.onRemoveFavourite(userName, nodeRef);
    return exists;
}
Also used : EventPreparator(org.alfresco.sync.repo.events.EventPreparator) ActivityEvent(org.alfresco.sync.events.types.ActivityEvent) QName(org.alfresco.service.namespace.QName) Event(org.alfresco.sync.events.types.Event) ActivityEvent(org.alfresco.sync.events.types.ActivityEvent) PersonFavouriteKey(org.alfresco.repo.favourites.PersonFavourite.PersonFavouriteKey)

Aggregations

PersonFavouriteKey (org.alfresco.repo.favourites.PersonFavourite.PersonFavouriteKey)6 Serializable (java.io.Serializable)2 Date (java.util.Date)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 QName (org.alfresco.service.namespace.QName)2 ActivityEvent (org.alfresco.sync.events.types.ActivityEvent)2 Event (org.alfresco.sync.events.types.Event)2 EventPreparator (org.alfresco.sync.repo.events.EventPreparator)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 StringTokenizer (java.util.StringTokenizer)1 TreeMap (java.util.TreeMap)1 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 PageDetails (org.alfresco.query.PageDetails)1 PagingResults (org.alfresco.query.PagingResults)1 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)1 Pair (org.alfresco.util.Pair)1