1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.exoplatform.ecm.webui.component.explorer.rightclick.manager;
19
20 import java.util.Arrays;
21 import java.util.List;
22
23 import javax.jcr.Node;
24
25 import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
26 import org.exoplatform.ecm.webui.component.explorer.control.filter.IsDocumentFilter;
27 import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter;
28 import org.exoplatform.portal.application.PortalRequestContext;
29 import org.exoplatform.portal.webui.util.Util;
30 import org.exoplatform.web.url.navigation.NavigationResource;
31 import org.exoplatform.web.url.navigation.NodeURL;
32 import org.exoplatform.webui.config.annotation.ComponentConfig;
33 import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
34 import org.exoplatform.webui.ext.filter.UIExtensionFilter;
35 import org.exoplatform.webui.ext.filter.UIExtensionFilters;
36 import org.exoplatform.webui.ext.manager.UIAbstractManager;
37 import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent;
38
39
40
41
42
43
44 @ComponentConfig(
45 lifecycle = UIContainerLifecycle.class
46 )
47 public class PermlinkActionComponent extends UIAbstractManagerComponent {
48
49 private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] {
50 new IsNotInTrashFilter(), new IsDocumentFilter() });
51
52 @UIExtensionFilters
53 public List<UIExtensionFilter> getFilters() {
54 return FILTERS;
55 }
56
57 public String getPermlink(UIJCRExplorer uiExplorer, Node node) throws Exception {
58 if (uiExplorer == null) {
59 uiExplorer = getAncestorOfType(UIJCRExplorer.class);
60 }
61 if (node == null) {
62 node = uiExplorer.getCurrentNode();
63 }
64 PortalRequestContext pcontext = Util.getPortalRequestContext();
65 String portletId = pcontext.getNodePath();
66 String drivename = uiExplorer.getDriveData().getName();
67 String nodePath = node.getPath().replaceAll("/+", "/");
68
69 String path = new StringBuilder().append(drivename)
70 .append(nodePath)
71 .toString();
72 NodeURL nodeURL = Util.getPortalRequestContext().createURL(NodeURL.TYPE);
73 NavigationResource resource = new NavigationResource(pcontext.getSiteType(), pcontext.getSiteName(), portletId);
74 nodeURL.setResource(resource);
75 nodeURL.setQueryParameterValue("path", path);
76 return nodeURL.toString();
77 }
78
79 public String getPermlink(UIJCRExplorer uiExplorer) throws Exception {
80 return getPermlink(uiExplorer, null);
81 }
82
83 public String getPermlink(Node node) throws Exception {
84 return getPermlink(null, node);
85 }
86
87 public String getPermlink() throws Exception {
88 return getPermlink(null, null);
89 }
90
91
92 @Override
93 public Class<? extends UIAbstractManager> getUIAbstractManagerClass() {
94 return null;
95 }
96
97 }