String ipAddress = request.getRemoteAddr();
if (url == null || url.length() == 0) {
getModel().put("errorCode", new Integer(1));
getModel().put("message", "The URL (permalink) must be specified for TrackBacks");
return new TrackBackResponseView();
} else if (!TrackBackTokenManager.getInstance().isValid(token)) {
getModel().put("errorCode", new Integer(1));
getModel().put("message", "The token has expired or is invalid");
return new TrackBackResponseView();
} else {
BlogService service = new BlogService();
blogEntry = service.getBlogEntry(blog, entry);
// only add the TrackBack if they are enabled for the entry
if (blogEntry.isTrackBacksEnabled()) {
TrackBack trackBack = blogEntry.createTrackBack(title, excerpt, url, blogName, ipAddress);
blogEntry.addTrackBack(trackBack);
service.putBlogEntry(blogEntry);
TrackBackTokenManager.getInstance().expire(token);
getModel().put("errorCode", new Integer(0));
return new TrackBackResponseView();
} else {
getModel().put("errorCode", new Integer(1));
getModel().put("message", "TrackBacks are not enabled for this blog entry");
return new TrackBackResponseView();
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();