Пример #1
0
 public static String getRestContextName() {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   PortalContainerInfo containerInfo =
       (PortalContainerInfo) container.getComponentInstanceOfType(PortalContainerInfo.class);
   return portalContainerConfig.getRestContextName(containerInfo.getContainerName());
 }
Пример #2
0
 /**
  * @param : node: nt:file node with have the data stream
  * @return : Link to download the jcr:data of the given node
  * @throws Exception
  */
 public static String getDownloadRestServiceLink(Node node) throws Exception {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerInfo containerInfo =
       (PortalContainerInfo) container.getComponentInstanceOfType(PortalContainerInfo.class);
   String portalName = containerInfo.getContainerName();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   String restContextName = portalContainerConfig.getRestContextName(portalName);
   StringBuilder sb = new StringBuilder();
   Node currentNode = org.exoplatform.wcm.webui.Utils.getRealNode(node);
   String ndPath = currentNode.getPath();
   if (ndPath.startsWith("/")) {
     ndPath = ndPath.substring(1);
   }
   String encodedPath = URLEncoder.encode(ndPath, "utf-8");
   encodedPath =
       encodedPath.replaceAll("%2F", "/"); // we won't encode the slash characters in the path
   sb.append("/").append(restContextName).append("/contents/download/");
   sb.append(currentNode.getSession().getWorkspace().getName()).append("/").append(encodedPath);
   if (node.isNodeType("nt:frozenNode")) {
     sb.append("?version=" + node.getParent().getName());
   }
   return sb.toString();
 }
Пример #3
0
 public static String getRestContextName(String portalContainerName) {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   return portalContainerConfig.getRestContextName(portalContainerName);
 }