Ejemplo n.º 1
0
  /** @return Returns a list of pages or returns null if has not any page. */
  public List<PageModel> next() {
    ExoContainer container = PortalContainer.getInstance();
    PageService pageService = (PageService) container.getComponentInstance(PageService.class);
    QueryResult<PageContext> result =
        pageService.findPages(
            currentIndex,
            pageSize + 1,
            SiteType.valueOf(ownerType.toUpperCase()),
            ownerId,
            name,
            title);

    int size = result.getSize();
    hasNext = size > pageSize;

    //
    if (size > 0) {
      int hsize = hasNext ? pageSize : size;
      List<PageModel> holder = new ArrayList<PageModel>(hsize);

      Iterator<PageContext> iterator = result.iterator();
      while (holder.size() < hsize) {
        holder.add(new PageModel(iterator.next()));
      }

      currentIndex += holder.size();
      return holder;
    } else {
      return null;
    }
  }
Ejemplo n.º 2
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());
 }
Ejemplo n.º 3
0
  public boolean hasNext() {
    if (hasNext && currentIndex == 0) {
      ExoContainer container = PortalContainer.getInstance();
      PageService pageService = (PageService) container.getComponentInstance(PageService.class);
      QueryResult<PageContext> result =
          pageService.findPages(
              0, 1, SiteType.valueOf(ownerType.toUpperCase()), ownerId, name, title);

      hasNext = result.getSize() > 0;
    }

    //
    return hasNext;
  }
Ejemplo n.º 4
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();
 }
Ejemplo n.º 5
0
 public static String getRestContextName(String portalContainerName) {
   ExoContainer container = ExoContainerContext.getCurrentContainer();
   PortalContainerConfig portalContainerConfig =
       (PortalContainerConfig) container.getComponentInstance(PortalContainerConfig.class);
   return portalContainerConfig.getRestContextName(portalContainerName);
 }
Ejemplo n.º 6
0
 public static NodeFinder getNodeFinder() {
   ExoContainer context = ExoContainerContext.getCurrentContainer();
   return (NodeFinder) context.getComponentInstance(NodeFinder.class);
 }