* @param request the HttpServletRequest instance
* @param response the HttpServletResponse instance
* @return the name of the next view
*/
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
String entryId = request.getParameter("entry");
String trackBackUrl = request.getParameter("url");
String excerpt = request.getParameter("excerpt");
String trackBackResponseMessage;
Integer trackBackResponseCode;
BlogService service = new BlogService();
BlogEntry blogEntry = null;
if (entryId != null) {
try {
blogEntry = service.getBlogEntry(blog, entryId);
} catch (BlogServiceException e) {
throw new ServletException(e);
}
}
if (blogEntry == null) {
// the entry cannot be found - it may have been removed or the
// requesting URL was wrong
return new NotFoundView();
} else if (trackBackUrl == null || trackBackUrl.trim().length() == 0) {
getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
return new TrackBackFormView();
} else {
// extract the information to send in the trackback
String title = blogEntry.getTitle();
String blogName = blogEntry.getBlog().getName();
String url = blogEntry.getPermalink();
// now send the trackback
try {
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(trackBackUrl);
postMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" + blog.getCharacterEncoding());
NameValuePair[] data = {
new NameValuePair("title", title),
new NameValuePair("url", url),
new NameValuePair("excerpt", excerpt),
new NameValuePair("blog_name", blogName)