Beispiel #1
0
 /**
  * We currently support 2 modes : MODE_LIVE : PUBLISHED state only MODE_EDIT : PUBLISHED, DRAFT,
  * PENDING, STAGED, APPROVED allowed.
  *
  * @param mode the current mode (MODE_LIVE or MODE_EDIT)
  * @return the allowed states
  */
 public List<String> getAllowedStates(String mode) {
   List<String> states = new ArrayList<String>();
   if (MODE_LIVE.equals(mode)) {
     states.add(PublicationDefaultStates.PUBLISHED);
   } else if (MODE_EDIT.equals(mode)) {
     states.add(PublicationDefaultStates.PUBLISHED);
     states.add(PublicationDefaultStates.DRAFT);
     states.add(PublicationDefaultStates.PENDING);
     states.add(PublicationDefaultStates.STAGED);
     states.add(PublicationDefaultStates.APPROVED);
   }
   return states;
 }
Beispiel #2
0
  public Result getPaginatedContents(
      NodeLocation nodeLocation, HashMap<String, String> filters, SessionProvider sessionProvider)
      throws Exception {
    String path = nodeLocation.getPath();
    String workspace = nodeLocation.getWorkspace();

    String mode = filters.get(FILTER_MODE);
    String version = filters.get(FILTER_VERSION);
    String orderBy = filters.get(FILTER_ORDER_BY);
    String orderType = filters.get(FILTER_ORDER_TYPE);
    String visibility = filters.get(FILTER_VISIBILITY);
    long offset = (filters.get(FILTER_OFFSET) != null) ? new Long(filters.get(FILTER_OFFSET)) : 0;
    long totalSize = (filters.get(FILTER_TOTAL) != null) ? new Long(filters.get(FILTER_TOTAL)) : 0;

    String remoteUser = getRemoteUser();

    if (MODE_EDIT.equals(mode) && "publication:liveDate".equals(orderBy)) {
      orderBy = "exo:dateModified";
      filters.put(FILTER_ORDER_BY, orderBy);
    }
    if (MODE_LIVE.equals(mode) && "exo:title".equals(orderBy)) {
      orderBy = "exo:titlePublished " + orderType + ", exo:title";
      filters.put(FILTER_ORDER_BY, orderBy);
    }

    if (LOG.isDebugEnabled())
      LOG.debug(
          "##### " + path + ":" + version + ":" + remoteUser + ":" + orderBy + ":" + orderType);

    NodeIterator nodeIterator;
    if (totalSize == 0) {
      SessionProvider systemProvider = WCMCoreUtils.getSystemSessionProvider();
      nodeIterator = getViewableContents(workspace, path, filters, systemProvider, false);
      if (nodeIterator != null) {
        totalSize = nodeIterator.getSize();
      }
    }

    if (WCMComposer.VISIBILITY_PUBLIC.equals(visibility) && MODE_LIVE.equals(mode)) {
      sessionProvider =
          remoteUser == null
              ? aclSessionProviderService.getAnonymSessionProvider()
              : aclSessionProviderService.getACLSessionProvider(getAnyUserACL());
    }

    nodeIterator = getViewableContents(workspace, path, filters, sessionProvider, true);
    List<Node> nodes = new ArrayList<Node>();
    Node node = null, viewNode = null;
    if (nodeIterator != null) {
      while (nodeIterator.hasNext()) {
        node = nodeIterator.nextNode();
        viewNode = getViewableContent(node, filters);
        if (viewNode != null) {
          nodes.add(viewNode);
        }
      }
    }
    Result result = new Result(nodes, offset, totalSize, nodeLocation, filters);

    return result;
  }
Beispiel #3
0
  public List<Node> getContents(
      String workspace,
      String path,
      HashMap<String, String> filters,
      SessionProvider sessionProvider)
      throws Exception {
    String mode = filters.get(FILTER_MODE);
    String version = filters.get(FILTER_VERSION);
    String orderBy = filters.get(FILTER_ORDER_BY);
    String orderType = filters.get(FILTER_ORDER_TYPE);
    String visibility = filters.get(FILTER_VISIBILITY);
    String remoteUser = null;
    if (WCMComposer.VISIBILITY_PUBLIC.equals(visibility)) {
      remoteUser = "******";
    } else {
      remoteUser = getRemoteUser();
    }

    if (MODE_EDIT.equals(mode) && "publication:liveDate".equals(orderBy)) {
      orderBy = "exo:dateModified";
      filters.put(FILTER_ORDER_BY, orderBy);
    }
    if ("exo:title".equals(orderBy)) {
      if (MODE_LIVE.equals(mode)) {
        orderBy = "exo:titlePublished " + orderType + ", exo:title";
      }
      if ("exo:taxonomy".equals(this.getTypeFromPath(workspace, path, sessionProvider))) {
        orderBy = "exo:name " + orderType + ", " + orderBy;
      }
      filters.put(FILTER_ORDER_BY, orderBy);
    }

    List<Node> nodes = new ArrayList<Node>();
    try {
      if (WCMComposer.VISIBILITY_PUBLIC.equals(visibility)
          && MODE_LIVE.equals(mode)
          && remoteUser != null) {
        sessionProvider = aclSessionProviderService.getACLSessionProvider(getAnyUserACL());
      }
      if (LOG.isDebugEnabled())
        LOG.debug(
            "##### " + path + ":" + version + ":" + remoteUser + ":" + orderBy + ":" + orderType);
      NodeIterator nodeIterator =
          getViewableContents(workspace, path, filters, sessionProvider, false);

      Node node = null, viewNode = null;
      while (nodeIterator != null && nodeIterator.hasNext()) {
        node = nodeIterator.nextNode();
        viewNode = getViewableContent(node, filters);
        if (viewNode != null) {
          nodes.add(viewNode);
        }
      }
    } catch (Exception e) {
      if (LOG.isWarnEnabled()) {
        LOG.warn(e.getMessage());
      }
    }

    return nodes;
  }