1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.services.wcm.symlink;
18
19 import javax.jcr.Node;
20 import javax.jcr.Property;
21
22 import org.apache.commons.chain.Context;
23 import org.exoplatform.container.xml.PortalContainerInfo;
24 import org.exoplatform.services.cms.CmsService;
25 import org.exoplatform.services.cms.link.LinkManager;
26 import org.exoplatform.services.command.action.Action;
27 import org.exoplatform.services.listener.ListenerService;
28 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
29
30
31
32
33
34
35
36 public class CreateLinkAction implements Action{
37
38 public static final String UPDATE_EVENT = "WCMPublicationService.event.updateState";
39 public static final String EXO_SORTABLE = "exo:sortable";
40
41 public boolean execute(Context context) throws Exception {
42 Property property = (Property)context.get("currentItem");
43 if (!"exo:uuid".equals(property.getName())) return false;
44
45 Node linkNode = property.getParent();
46 if (!linkNode.isNodeType(EXO_SORTABLE) && !linkNode.canAddMixin(EXO_SORTABLE))
47 return false;
48
49 PortalContainerInfo containerInfo = WCMCoreUtils.getService(PortalContainerInfo.class);
50 String containerName = containerInfo.getContainerName();
51 LinkManager linkManager = WCMCoreUtils.getService(LinkManager.class, containerName);
52 Node targetNode = linkManager.getTarget(linkNode, true);
53
54 ListenerService listenerService = WCMCoreUtils.getService(ListenerService.class, containerName);
55 CmsService cmsService = WCMCoreUtils.getService(CmsService.class, containerName);
56
57 listenerService.broadcast(UPDATE_EVENT, cmsService, targetNode);
58
59 return true;
60 }
61
62 }