Пример #1
0
 @Factory("blogEntry9List")
 public void initBlogEntry9List() {
   log.info("initBlogEntry9List");
   blogEntry9List = new HashMap<String, String>();
   for (Object o : em.createQuery("from " + "BlogEntry").getResultList()) {
     BlogEntry p = (BlogEntry) o;
     blogEntry9List.put(p.getName(), p.getId().toString());
   }
 }
Пример #2
0
  /**
   * 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());
  }