Exemple #1
0
  /**
   * Checks if is node content published to page node.
   *
   * @param contentNode the content node
   * @param navNodeURI the nav node uri
   * @return true, if is node content published to page node
   * @throws Exception the exception
   */
  public static boolean isNodeContentPublishedToPageNode(Node contentNode, String navNodeURI)
      throws Exception {

    UserPortal userPortal = Util.getPortalRequestContext().getUserPortalConfig().getUserPortal();

    // make filter
    UserNodeFilterConfig.Builder filterConfigBuilder = UserNodeFilterConfig.builder();
    filterConfigBuilder
        .withReadWriteCheck()
        .withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
    filterConfigBuilder.withTemporalCheck();
    UserNodeFilterConfig filterConfig = filterConfigBuilder.build();

    // get user node
    String nodeURI =
        navNodeURI.replace("/" + Util.getPortalRequestContext().getPortalOwner() + "/", "");
    UserNode userNode;
    UserNavigation userNavigation =
        NavigationUtils.getUserNavigationOfPortal(
            userPortal, Util.getUIPortal().getSiteKey().getName());
    if (userNavigation != null) {
      userNode = userPortal.resolvePath(userNavigation, filterConfig, nodeURI);
    } else {
      userNode = userPortal.resolvePath(filterConfig, nodeURI);
    }

    if (userNode == null || userNode.getPageRef() == null) return false;

    return PublicationUtil.getValuesAsString(contentNode, "publication:webPageIDs")
        .contains(userNode.getPageRef());
  }
Exemple #2
0
  private static UserNode getEditorNode(String editorPageURI) {
    UserPortal userPortal = Util.getPortalRequestContext().getUserPortalConfig().getUserPortal();
    List<UserNavigation> allNavs = userPortal.getNavigations();

    for (UserNavigation nav : allNavs) {
      if (nav.getKey().getType().equals(SiteType.GROUP)) {
        UserNode userNode = userPortal.resolvePath(nav, null, editorPageURI);
        if (userNode != null) {
          return userNode;
        }
      }
    }
    return null;
  }
  public JSONArray getChildrenAsJSON(String nodeURI) throws Exception {
    WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
    Collection<UserNode> children = null;

    UserPortal userPortal = Util.getPortalRequestContext().getUserPortalConfig().getUserPortal();

    // make filter
    UserNodeFilterConfig.Builder filterConfigBuilder = UserNodeFilterConfig.builder();
    filterConfigBuilder
        .withReadWriteCheck()
        .withVisibility(Visibility.DISPLAYED, Visibility.TEMPORAL);
    filterConfigBuilder.withTemporalCheck();
    UserNodeFilterConfig filterConfig = filterConfigBuilder.build();

    // get user node & update children
    UserNode userNode;
    if (context.getRemoteUser() != null) {
      userNode =
          userPortal.resolvePath(Util.getUIPortal().getUserNavigation(), filterConfig, nodeURI);
    } else {
      userNode = userPortal.resolvePath(filterConfig, nodeURI);
    }

    if (userNode != null) {
      userPortal.updateNode(userNode, NavigationUtils.ECMS_NAVIGATION_SCOPE, null);
      children = userNode.getChildren();
    }

    // build JSON result
    JSONArray jsChildren = new JSONArray();
    if (children == null) {
      return null;
    }
    MimeResponse res = context.getResponse();
    for (UserNode child : children) {
      jsChildren.put(toJSON(child, res));
    }
    return jsChildren;
  }