private void writeCommentCountProperty(JSONWriter write, Session session, Content contentResult)
     throws StorageClientException, JSONException, AccessDeniedException {
   ContentManager contentManager = session.getContentManager();
   Content comments = contentManager.get(contentResult.getPath() + "/" + "comments");
   long commentCount = 0;
   if (comments != null) {
     for (@SuppressWarnings("unused") Content comment : comments.listChildren()) {
       commentCount++;
     }
   }
   write.key("commentCount");
   write.value(commentCount);
 }
Exemplo n.º 2
0
  /*
   * getPageTree: returns List of all pages under the passed path
   */
  private List<Content> getPageTree(Content pageContent) {
    List<Content> contentList = new ArrayList();

    // Add to list only if content is a page
    String resourceType = (String) pageContent.getProperty("sling:resourceType");
    if (resourceType != null && resourceType.equals("sakai/page")) {
      contentList.add(pageContent);
    }

    if (pageContent != null) {
      for (Content page : pageContent.listChildren()) {
        contentList.addAll(getPageTree(page));
      }
    }

    return contentList;
  }