PrintWriter pw = response.getWriter();
WebsiteData weblog = null;
WeblogEntryData entry = null;
WeblogTrackbackRequest trackbackRequest = null;
if(!RollerRuntimeConfig.getBooleanProperty("users.trackbacks.enabled")) {
// TODO: i18n
error = "Trackbacks are disabled for this site";
} else {
try {
trackbackRequest = new WeblogTrackbackRequest(request);
if((trackbackRequest.getTitle() == null) ||
"".equals(trackbackRequest.getTitle())) {
trackbackRequest.setTitle(trackbackRequest.getUrl());
}
if(trackbackRequest.getExcerpt() == null) {
trackbackRequest.setExcerpt("");
} else if(trackbackRequest.getExcerpt().length() >= 255) {
trackbackRequest.setExcerpt(trackbackRequest.getExcerpt().substring(0, 252)+"...");
}
// lookup weblog specified by comment request
UserManager uMgr = RollerFactory.getRoller().getUserManager();
weblog = uMgr.getWebsiteByHandle(trackbackRequest.getWeblogHandle());
if(weblog == null) {
throw new RollerException("unable to lookup weblog: "+
trackbackRequest.getWeblogHandle());
}
// lookup entry specified by comment request
WeblogManager weblogMgr = RollerFactory.getRoller().getWeblogManager();
entry = weblogMgr.getWeblogEntryByAnchor(weblog, trackbackRequest.getWeblogAnchor());
if(entry == null) {
throw new RollerException("unable to lookup entry: "+
trackbackRequest.getWeblogAnchor());
}
} catch (Exception e) {
// some kind of error parsing the request or looking up weblog
logger.debug("error creating trackback request", e);
error = e.getMessage();
}
}
if(error != null) {
pw.println(this.getErrorResponse(error));
return;
}
try {
boolean verified = true;
// check if trackbacks are allowed for this entry
// this checks site-wide settings, weblog settings, and entry settings
if (entry != null && entry.getCommentsStillAllowed() && entry.isPublished()) {
// Track trackbacks as comments
CommentData comment = new CommentData();
comment.setContent("[Trackback] "+trackbackRequest.getExcerpt());
comment.setName(trackbackRequest.getBlogName());
comment.setUrl(trackbackRequest.getUrl());
comment.setWeblogEntry(entry);
comment.setNotify(Boolean.FALSE);
comment.setPostTime(new Timestamp(new Date().getTime()));
// If comment contains blacklisted text, mark as spam