/** * Peforms the processing associated with this action. * * @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) request.getAttribute(Constants.BLOG_KEY); StringBuffer query = new StringBuffer(); addTerm(query, "title", request.getParameter("title")); addTerm(query, "body", request.getParameter("body")); addTerms(query, "category", request.getParameterValues("category")); addTerm(query, "author", request.getParameter("author")); String tags = request.getParameter("tags"); if (tags != null) { String s[] = tags.split(","); for (int i = 0; i < s.length; i++) { s[i] = Tag.encode(s[i].trim()); } addTerms(query, "tag", s); } try { String encodedQuery = URLEncoder.encode(query.toString(), blog.getCharacterEncoding()); return new ForwardView("/search.action?query=" + encodedQuery); } catch (UnsupportedEncodingException uee) { throw new ServletException(uee); } }
/** * Peforms the processing associated with this action. * * @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 email = request.getParameter("email"); email = StringUtils.filterHTML(email); if (email != null && email.length() > 0) { blog.getEmailSubscriptionList().addEmailAddress(email); blog.info(email + " has subscribed to this blog."); getModel().put("email", email); return new SubscribedView(); } return new SubscribeView(); }
/** * Peforms the processing associated with this action. * * @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 id = request.getParameter("entry"); String confirm = request.getParameter("confirm"); String submit = request.getParameter("submit"); BlogService service = new BlogService(); BlogEntry blogEntry = null; try { blogEntry = service.getBlogEntry(blog, id); } catch (BlogServiceException e) { throw new ServletException(e); } if (blogEntry == null) { return new NotFoundView(); } if (submit.equals("Edit")) { return new ForwardView("/editBlogEntry.secureaction?entry=" + id); } else if (submit.equals("Publish") || submit.equals("Unpublish")) { getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry); return new PublishBlogEntryView(); } else if (submit.equals("Clone")) { return new ForwardView("/addBlogEntry.secureaction?entryToClone=" + blogEntry.getId()); } else if (confirm != null && confirm.equals("true")) { if (submit.equalsIgnoreCase("Remove")) { try { service.removeBlogEntry(blogEntry); blog.info( "Blog entry \"" + StringUtils.transformHTML(blogEntry.getTitle()) + "\" removed."); } catch (BlogServiceException be) { throw new ServletException(be); } return new ForwardView("/viewHomePage.action"); } } return new RedirectView(blogEntry.getLocalPermalink()); }
private String buildPermalink(BlogEntry blogEntry) { String title = getCuratedPermalinkTitle(blogEntry, "_"); Blog blog = blogEntry.getBlog(); Date date = blogEntry.getDate(); DateFormat year = new SimpleDateFormat("yyyy"); year.setTimeZone(blog.getTimeZone()); DateFormat month = new SimpleDateFormat("MM"); month.setTimeZone(blog.getTimeZone()); DateFormat day = new SimpleDateFormat("dd"); day.setTimeZone(blog.getTimeZone()); StringBuffer buf = new StringBuffer(); buf.append("/"); buf.append(year.format(date)); buf.append("/"); buf.append(month.format(date)); buf.append("/"); buf.append(day.format(date)); buf.append("/"); buf.append(title); return buf.toString(); }
/** * Gets the content type of this view. * * @return the content type as a String */ public String getContentType() { Blog blog = (Blog) getModel().get(Constants.BLOG_KEY); return "application/xml; charset=" + blog.getCharacterEncoding(); }
/** * Gets the URI that this view represents. * * @return the URI as a String */ public String getUri() { Blog blog = (Blog) getModel().get(Constants.BLOG_KEY); TrackBackConfirmationStrategy strategy = blog.getTrackBackConfirmationStrategy(); return strategy.getUri(); }