Esempio n. 1
0
  public void delete(boolean removeFromParent) {
    AjaxServlet.invalidateFrontPageCache(getGroup().getId());
    if (parent == null) {
      // we're a toplevel post

      if (getWhiteboard() == null) {
        Iterator<PostModel> it = replies.iterator();
        while (it.hasNext()) {
          PostModel reply = it.next();
          reply.delete(false);
          it.remove();
          reply.setParent(null);
        }
      } else {
        getWhiteboard().delete();
      }
    } else {
      // we're a reply
      subject = "reply";
      intro = "parent's subject was: " + parent.getSubject();

      Calendar lReply = GregorianCalendar.getInstance();
      Calendar rCal = GregorianCalendar.getInstance();
      lReply.setTime(parent.getDate());

      for (PostModel r : parent.getReplies()) {
        rCal.setTime(r.getDate());
        if (!r.getGroup().equals(Helpers.getGroup("DeletedPosts"))
            && lReply.before(rCal)
            && !r.equals(this)) {
          lReply.setTime(r.getDate());
        }
      }

      parent.setLastReply(lReply.getTime());
      if (removeFromParent) {
        parent.getReplies().remove(this);
        parent = null;
      }
    }

    subject = "*deleted* " + subject;
    intro =
        "deleted "
            + (new Date()).toString()
            + ", original group was: "
            + group.getName()
            + "\n- - -\n"
            + intro;
    this.group = Helpers.getGroup("DeletedPosts");
    getSearchable().delete();
  }
Esempio n. 2
0
 public void delete() {
   delete(true);
 }