// delete all comments with delete box checked
List<String> deletes = Arrays.asList(getBean().getDeleteComments());
if(deletes != null && deletes.size() > 0) {
log.debug("Processing deletes - "+deletes.size());
WeblogEntryComment deleteComment = null;
for(String deleteId : deletes) {
deleteComment = wmgr.getComment(deleteId);
// make sure comment is tied to action weblog
if(getActionWeblog().equals(deleteComment.getWeblogEntry().getWebsite())) {
flushList.add(deleteComment);
reindexList.add(deleteComment.getWeblogEntry());
wmgr.removeComment(deleteComment);
}
}
}
// loop through IDs of all comments displayed on page
List<String> approvedIds = Arrays.asList(getBean().getApprovedComments());
List<String> spamIds = Arrays.asList(getBean().getSpamComments());
log.debug(spamIds.size()+" comments marked as spam");
// track comments approved via moderation
List<WeblogEntryComment> approvedComments = new ArrayList();
String[] ids = Utilities.stringToStringArray(getBean().getIds(),",");
for (int i=0; i < ids.length; i++) {
log.debug("processing id - "+ ids[i]);
// if we already deleted it then skip forward
if(deletes.contains(ids[i])) {
log.debug("Already deleted, skipping - "+ids[i]);
continue;
}
WeblogEntryComment comment = wmgr.getComment(ids[i]);
// make sure comment is tied to action weblog
if(getActionWeblog().equals(comment.getWeblogEntry().getWebsite())) {
// comment approvals and mark/unmark spam
if(approvedIds.contains(ids[i])) {
// if a comment was previously PENDING then this is
// it's first approval, so track it for notification
if(WeblogEntryComment.PENDING.equals(comment.getStatus())) {
approvedComments.add(comment);
}
log.debug("Marking as approved - "+comment.getId());
comment.setStatus(WeblogEntryComment.APPROVED);
wmgr.saveComment(comment);
flushList.add(comment);
reindexList.add(comment.getWeblogEntry());
} else if(spamIds.contains(ids[i])) {
log.debug("Marking as spam - "+comment.getId());
comment.setStatus(WeblogEntryComment.SPAM);
wmgr.saveComment(comment);
flushList.add(comment);
reindexList.add(comment.getWeblogEntry());
} else if(!WeblogEntryComment.DISAPPROVED.equals(comment.getStatus())) {
log.debug("Marking as disapproved - "+comment.getId());
comment.setStatus(WeblogEntryComment.DISAPPROVED);
wmgr.saveComment(comment);
flushList.add(comment);
reindexList.add(comment.getWeblogEntry());
}
}
}
WebloggerFactory.getWeblogger().flush();