}
RollerSession rses = RollerSession.getRollerSession(request);
try {
if (rses.isGlobalAdminUser()
|| (rreq.getWebsite()!=null && rses.isUserAuthorizedToAuthor(rreq.getWebsite())) ) {
WeblogManager mgr= RollerFactory.getRoller().getWeblogManager();
// delete all comments with delete box checked
CommentData deleteComment = null;
String[] deleteIds = queryForm.getDeleteComments();
List deletedList = Arrays.asList(deleteIds);
if (deleteIds != null && deleteIds.length > 0) {
for(int j=0; j < deleteIds.length; j++) {
deleteComment = mgr.getComment(deleteIds[j]);
mgr.removeComment(deleteComment);
}
}
// Collect comments approved for first time, so we can send
// out comment approved notifications later
List approvedComments = new ArrayList();
// loop through IDs of all comments displayed on page
String[] ids = Utilities.stringToStringArray(queryForm.getIds(),",");
List flushList = new ArrayList();
for (int i=0; i<ids.length; i++) {
if (deletedList.contains(ids[i])) continue;
CommentData comment = mgr.getComment(ids[i]);
// apply spam checkbox
List spamIds = Arrays.asList(queryForm.getSpamComments());
if (spamIds.contains(ids[i])) {
comment.setSpam(Boolean.TRUE);
} else {
comment.setSpam(Boolean.FALSE);
}
// Only participate in comment review workflow if we're
// working within one specfic weblog. Global admins should
// be able to mark-as-spam and delete comments without
// interfering with moderation by bloggers.
if (rreq.getWebsite() != null) {
// all comments reviewed, so they're no longer pending
if (comment.getPending() != null && comment.getPending().booleanValue()) {
comment.setPending(Boolean.FALSE);
approvedComments.add(comment);
}
// apply pending checkbox
List approvedIds =
Arrays.asList(queryForm.getApprovedComments());
if (approvedIds.contains(ids[i])) {
comment.setApproved(Boolean.TRUE);
} else {
comment.setApproved(Boolean.FALSE);
}
}
mgr.saveComment(comment);
flushList.add(comment);
}
RollerFactory.getRoller().flush();
for (Iterator comments=flushList.iterator(); comments.hasNext();) {