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 javax.jcr.Node;
20 import javax.jcr.Property;
21
22 import org.apache.commons.chain.Context;
23 import org.exoplatform.services.cms.impl.Utils;
24 import org.exoplatform.services.command.action.Action;
25 import org.exoplatform.services.wcm.core.NodetypeConstant;
26
27
28
29
30
31
32
33
34
35
36
37
38 public class AddNodeNameAction implements Action {
39
40 public boolean execute(Context context) throws Exception {
41 Object item = context.get("currentItem");
42 Node node = (item instanceof Property) ? ((Property)item).getParent() :
43 (Node)item;
44 if(node.isNodeType("nt:resource")) node = node.getParent();
45
46 if(node.canAddMixin("exo:sortable")) {
47 node.addMixin("exo:sortable");
48 }
49
50 if (!node.hasProperty("exo:name")) {
51 node.setProperty("exo:name", node.getName());
52 }
53
54 if(node.isNodeType(NodetypeConstant.EXO_SYMLINK)) {
55 if (!node.hasProperty("exo:title")) {
56 node.setProperty("exo:title", Utils.getTitle(node));
57 }
58 }
59
60 return false;
61 }
62
63 }