IPBanList.getInstance().addBannedIp(request.getRemoteAddr());
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
WeblogCommentRequest commentRequest = null;
try {
commentRequest = new WeblogCommentRequest(request);
// lookup weblog specified by comment request
UserManager uMgr = RollerFactory.getRoller().getUserManager();
weblog = uMgr.getWebsiteByHandle(commentRequest.getWeblogHandle());
if(weblog == null) {
throw new RollerException("unable to lookup weblog: "+
commentRequest.getWeblogHandle());
}
// lookup entry specified by comment request
WeblogManager weblogMgr = RollerFactory.getRoller().getWeblogManager();
entry = weblogMgr.getWeblogEntryByAnchor(weblog, commentRequest.getWeblogAnchor());
if(entry == null) {
throw new RollerException("unable to lookup entry: "+
commentRequest.getWeblogAnchor());
}
// we know what the weblog entry is, so setup our urls
dispatch_url = "/roller-ui/rendering/page/"+weblog.getHandle();
if(commentRequest.getLocale() != null) {
dispatch_url += "/"+commentRequest.getLocale();
}
dispatch_url += "/entry/"+URLUtilities.encode(commentRequest.getWeblogAnchor());
} catch (Exception e) {
// some kind of error parsing the request or looking up weblog
log.debug("error creating page request", e);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
log.debug("Doing comment posting for entry = "+entry.getPermaLink());
// collect input from request params and construct new comment object
// fields: name, email, url, content, notify
// TODO: data validation on collected comment data
CommentData comment = new CommentData();
comment.setName(commentRequest.getName());
comment.setEmail(commentRequest.getEmail());
comment.setUrl(commentRequest.getUrl());
comment.setContent(commentRequest.getContent());
comment.setNotify(new Boolean(commentRequest.isNotify()));
comment.setWeblogEntry(entry);
comment.setRemoteHost(request.getRemoteHost());
comment.setPostTime(new Timestamp(System.currentTimeMillis()));
WeblogEntryCommentForm cf = new WeblogEntryCommentForm();