コード例 #1
0
  /**
   * Returns the relative path to the document directory in the request environment. If the document
   * or one of it's parent sections aren't found in the request environment, null is returned. The
   * path is relative to the request URL and may be empty if the request environment points to the
   * document. Otherwise the path ends with an "/" character.
   *
   * @param content the content document
   * @return the relative path to the document directory, or null if not in the request environment
   */
  private String getDocEnvPath(Content content) {
    RequestEnvironment env = context.getRequest().getEnvironment();
    ContentSection section = env.getSection();
    ContentDocument doc = env.getDocument();
    String path = "";

    if (doc != null) {
      if (doc.getId() == content.getId()) {
        return "";
      }
    } else if (section != null) {
      while (content != null) {
        if (section.getId() == content.getId()) {
          return path;
        }
        path = content.getName() + "/" + path;
        try {
          content = content.getParent();
        } catch (ContentException e) {
          LOG.error(e.getMessage());
          return null;
        }
      }
    }
    return null;
  }
コード例 #2
0
ファイル: SectionBean.java プロジェクト: cederberg/liquidsite
  /**
   * Returns all sections in this section. The sections will be ordered by their name.
   *
   * @return a list of the sections found (as section beans)
   */
  public ArrayList getSections() {
    ArrayList results = new ArrayList();
    ContentSelector selector;
    Content[] content;

    if (getContent() != null) {
      try {
        selector = new ContentSelector(getContent().getDomain());
        selector.requireParent(getContent());
        selector.requireCategory(Content.SECTION_CATEGORY);
        selector.sortByName(true);
        selector.limitResults(0, 100);
        content = getContext().findContent(selector);
        for (int i = 0; i < content.length; i++) {
          results.add(getContext().createContentBean(content[i]));
        }
      } catch (ContentException e) {
        LOG.error(e.getMessage());
      }
    }
    return results;
  }