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.Node;
20
21 import org.apache.commons.chain.Context;
22 import org.exoplatform.services.command.action.Action;
23 import org.exoplatform.services.listener.ListenerService;
24 import org.exoplatform.services.wcm.core.NodetypeConstant;
25 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
26
27
28
29
30
31
32
33 public class AddNodeActivityAction implements Action{
34
35 private ListenerService listenerService=null;
36 private ActivityCommonService activityService = null;
37 public AddNodeActivityAction() {
38 listenerService = WCMCoreUtils.getService(ListenerService.class);
39 activityService = WCMCoreUtils.getService(ActivityCommonService.class);
40 }
41 public boolean execute(Context context) throws Exception {
42 if (listenerService ==null) return false;
43 Object item = context.get("currentItem");
44 if (item instanceof Node) {
45 Node node = (Node)item;
46 if (node.getPrimaryNodeType().getName().equals((NodetypeConstant.NT_FILE))) {
47 Node parent = node.getParent();
48 if (activityService.isAcceptedNode(parent) && !activityService.isCreating(parent)) {
49 listenerService.broadcast(ActivityCommonService.ATTACH_ADDED_ACTIVITY, parent, node);
50 }
51 }
52 }
53 return false;
54 }
55 }