1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.services.cms.jcrext;
18
19 import java.util.GregorianCalendar;
20
21 import javax.jcr.Node;
22 import javax.jcr.Property;
23
24 import org.apache.commons.chain.Context;
25 import org.exoplatform.services.command.action.Action;
26 import org.exoplatform.services.security.ConversationState;
27
28
29
30
31
32
33
34
35
36
37
38
39 public class ModifyNodeAction implements Action {
40
41 public boolean execute(Context context) throws Exception {
42 Object item = context.get("currentItem");
43 Node node = (item instanceof Property) ?
44 ((Property)item).getParent() :
45 (Node)item;
46 if(node.isNodeType("nt:resource")) node = node.getParent();
47 ConversationState conversationState = ConversationState.getCurrent();
48 String userName = (conversationState == null) ? node.getSession().getUserID() :
49 conversationState.getIdentity().getUserId();
50 if(node.canAddMixin("exo:modify")) {
51 node.addMixin("exo:modify");
52 }
53 node.setProperty("exo:lastModifiedDate", new GregorianCalendar());
54 node.setProperty("exo:lastModifier",userName);
55 return false;
56 }
57
58 }