/**
   * If the forumCallback is null no filtering is executed, else if a thread is hidden and the user
   * doesn't have moderator rights the hidden thread is not included into the archive.
   *
   * @param forumId
   * @param metaInfo
   * @return all top message nodes together with their children in a list
   */
  private List convertToThreadTrees(final long forumId, final ForumCallback forumCallback) {
    List messages;
    final List topNodeList = new ArrayList();
    final ForumManager fm = ForumManager.getInstance();
    final Long l = new Long(forumId);
    final Forum f = fm.loadForum(l);
    messages = fm.getMessagesByForum(f);

    for (final Iterator iterTop = messages.iterator(); iterTop.hasNext(); ) {
      final Message msg = (Message) iterTop.next();
      if (msg.getParent() == null) {
        iterTop.remove();
        final MessageNode topNode = new MessageNode(msg);
        if (topNode.isHidden()
            && (forumCallback == null
                || (forumCallback != null && forumCallback.mayEditMessageAsModerator()))) {
          addChildren(messages, topNode);
          topNodeList.add(topNode);
        } else if (!topNode.isHidden()) {
          addChildren(messages, topNode);
          topNodeList.add(topNode);
        }
      }
    }
    return getMessagesSorted(topNodeList);
  }
 private void addChildren(final List messages, final MessageNode mn) {
   for (final Iterator iterMsg = messages.iterator(); iterMsg.hasNext(); ) {
     final Message msg = (Message) iterMsg.next();
     if ((msg.getParent() != null) && (msg.getParent().getKey() == mn.getKey())) {
       final MessageNode childNode = new MessageNode(msg);
       mn.addChild(childNode);
       // FIXME:as:c next line is not necessary
       childNode.setParent(mn);
       addChildren(messages, childNode);
     }
   }
 }