1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.services.cms.jcrext.activity;
18
19 import javax.jcr.Item;
20 import javax.jcr.Node;
21 import javax.jcr.Property;
22
23 import org.apache.commons.chain.Context;
24 import org.exoplatform.services.command.action.Action;
25 import org.exoplatform.services.listener.ListenerService;
26 import org.exoplatform.services.security.ConversationState;
27 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
28
29
30
31
32
33
34
35 public class EditPropertyActivityAction implements Action{
36 private ListenerService listenerService=null;
37 private ActivityCommonService activityService = null;
38 public EditPropertyActivityAction() {
39 listenerService = WCMCoreUtils.getService(ListenerService.class);
40 activityService = WCMCoreUtils.getService(ActivityCommonService.class);
41 }
42 @Override
43 public boolean execute(Context context) throws Exception {
44 Object item = context.get("currentItem");
45 Node node = (item instanceof Property) ?((Property)item).getParent():(Node)item;
46 Node nodeTemp = activityService.isSpecialContentNodeType((Item) item);
47 String propertyName = (item instanceof Property) ?((Property)item).getName():((Node)item).getName();
48 if (nodeTemp !=null) {
49 if (!activityService.isCreating(nodeTemp)) {
50
51 String itemPath = ((Item) item).getPath();
52 String nodePath = nodeTemp.getPath();
53 String referencePath = itemPath.substring(nodePath.length());
54 if (referencePath.startsWith("/")) {
55 referencePath = referencePath.substring(1);
56 }
57 listenerService.broadcast(ActivityCommonService.EDIT_ACTIVITY, nodeTemp, referencePath);
58 }
59 }
60 nodeTemp = node;
61
62 if (!activityService.isAcceptedProperties(propertyName)) return false;
63 if (ConversationState.getCurrent() == null) return false;
64
65 if(node.isNodeType("nt:resource")) node = node.getParent();
66
67 if (activityService.isAcceptedNode(node)) {
68
69 if (!activityService.isCreating(node)) {
70 listenerService.broadcast(ActivityCommonService.EDIT_ACTIVITY, node, propertyName);
71 }
72 }
73 return false;
74 }
75
76 }