1 25 26 package com.j2biz.blogunity.web.actions.my; 27 28 import java.util.List ; 29 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 36 import com.j2biz.blogunity.dao.CommentDAO; 37 import com.j2biz.blogunity.dao.EntryDAO; 38 import com.j2biz.blogunity.exception.BlogunityException; 39 import com.j2biz.blogunity.i18n.I18N; 40 import com.j2biz.blogunity.i18n.I18NStatusFactory; 41 import com.j2biz.blogunity.pojo.Entry; 42 import com.j2biz.blogunity.web.ActionResultFactory; 43 import com.j2biz.blogunity.web.IActionResult; 44 45 52 public class ListEntryCommentsAction extends MyAbstractAction { 53 56 private static final Log log = LogFactory.getLog(ListEntryCommentsAction.class); 57 58 private static final IActionResult ENTRIES_LIST_FORWARD = ActionResultFactory 59 .buildForward("/jsp/my/listEntryComments.jsp"); 60 61 67 public IActionResult execute(HttpServletRequest request, HttpServletResponse response) 68 throws BlogunityException { 69 70 String entryId = request.getParameter("id"); 71 if (entryId == null) { throw new BlogunityException(I18NStatusFactory.create( 72 I18N.ERRORS.ID_NOT_SETTED, "Entry")); } 73 74 if (log.isDebugEnabled()) { 75 log.debug("Get list of comments for entry : " + entryId); 76 } 77 78 Entry e = (new EntryDAO()).getEntryByID(new Long (entryId)); 79 80 if (log.isDebugEnabled()) { 81 log.debug("Entry with ID='" + e.getId() + "' and TITLE='" + e.getTitle() + "' found"); 82 } 83 84 List comments = (new CommentDAO()).getPaginatedComments(e.getId(), 0, 20); 85 86 if (log.isDebugEnabled()) { 87 log.debug("Found " + comments.size() + " comments..."); 88 log.debug("Set attributes 'entry' and 'comments' to request..."); 89 } 90 91 request.setAttribute("entry", e); 92 request.setAttribute("comments", comments); 93 94 navigationStack.push(ActionResultFactory.buildRedirect( 95 I18N.MESSAGES.NAVI_LIST_ENTRY_COMMENTS, currentActionPath)); 96 97 return ENTRIES_LIST_FORWARD; 98 } 99 } | Popular Tags |