1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.ecm.webui.component.explorer.popup.admin;
18
19 import javax.jcr.Node;
20
21 import org.exoplatform.container.xml.PortalContainerInfo;
22 import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
23 import org.exoplatform.portal.webui.util.Util;
24 import org.exoplatform.resolver.ResourceResolver;
25 import org.exoplatform.services.cms.templates.TemplateService;
26 import org.exoplatform.services.wcm.core.NodeLocation;
27 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
28 import org.exoplatform.webui.application.WebuiRequestContext;
29 import org.exoplatform.webui.config.annotation.ComponentConfig;
30 import org.exoplatform.webui.core.UIContainer;
31
32
33
34
35
36
37
38
39 @ComponentConfig()
40
41 public class UIActionViewTemplate extends UIContainer {
42
43 private String documentType_ ;
44 private NodeLocation node_ ;
45
46 public void setTemplateNode(Node node) throws Exception {
47 node_ = NodeLocation.getNodeLocationByNode(node);
48 documentType_ = node.getPrimaryNodeType().getName() ;
49 }
50
51 public String getViewTemplatePath(){
52 TemplateService templateService = getApplicationComponent(TemplateService.class) ;
53 String userName = Util.getPortalRequestContext().getRemoteUser() ;
54 try {
55 return templateService.getTemplatePathByUser(false, documentType_, userName) ;
56 } catch (Exception e) {
57 return null ;
58 }
59 }
60
61 public String getPortalName() {
62 PortalContainerInfo containerInfo = WCMCoreUtils.getService(PortalContainerInfo.class) ;
63 return containerInfo.getContainerName() ;
64 }
65
66 public String getWorkspaceName() throws Exception {
67 return NodeLocation.getNodeByLocation(node_).getSession().getWorkspace().getName() ;
68 }
69
70 public String getTemplate() { return getViewTemplatePath() ;}
71
72 public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context, String template) {
73 return getAncestorOfType(UIJCRExplorer.class).getJCRTemplateResourceResolver() ;
74 }
75
76 public Node getNode() {
77 return NodeLocation.getNodeByLocation(node_);
78 }
79 }