KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > web > actions > my > ListTrackbacksAction


1 /*
2  * $Id: ListTrackbacksAction.java,v 1.2 2005/01/17 21:35:45 michelson Exp $
3  * Created on 10.01.2005
4  * Last commit on $Date: 2005/01/17 21:35:45 $ by $Author: michelson $
5  * Copyright (c) 2005 j2biz Group, http://www.j2biz.com
6  * Koeln / Duesseldorf , Germany
7  *
8  * @author Juan Antonio Agudo
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.web.actions.my;
27
28 import java.util.List JavaDoc;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35
36 import com.j2biz.blogunity.dao.EntryDAO;
37 import com.j2biz.blogunity.dao.TrackbackDAO;
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.pojo.Trackback;
43 import com.j2biz.blogunity.web.ActionResultFactory;
44 import com.j2biz.blogunity.web.IActionResult;
45 import com.j2biz.blogunity.web.actions.AbstractAction;
46
47 /**
48  * @author tag Juan Antonio Agudo
49  * @since 0.2.2 (Cian)
50  */

51 public class ListTrackbacksAction extends AbstractAction {
52
53     /**
54      * Logger for this class
55      */

56     private static final Log log = LogFactory.getLog(ListTrackbacksAction.class);
57
58     private static final IActionResult ENTRIES_LIST_FORWARD = ActionResultFactory
59             .buildForward("/jsp/my/listTrackbacks.jsp");
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see com.j2biz.blogunity.web.actions.AbstractAction#execute(javax.servlet.http.HttpServletRequest,
65      * javax.servlet.http.HttpServletResponse)
66      */

67     public IActionResult execute(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
68             throws BlogunityException {
69
70         String JavaDoc 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 trackbacks for entry : " + entryId);
76         }
77
78         Entry e = (new EntryDAO()).getEntryByID(new Long JavaDoc(entryId));
79
80         if (log.isDebugEnabled()) {
81             log.debug("Entry with ID='" + e.getId() + "' and TITLE='" + e.getTitle() + "' found");
82         }
83
84         List JavaDoc trackbacks = (new TrackbackDAO()).getTrackbacksForEntryAndDirection(e.getId(),
85                 Trackback.DIRECTION_INCOMING);
86
87         if (log.isDebugEnabled()) {
88             log.debug("Found " + trackbacks.size() + " trackbacks...");
89             log.debug("Set attributes 'entry' and 'trackbacks' to request...");
90         }
91
92         request.setAttribute("entry", e);
93         request.setAttribute("trackbacks", trackbacks);
94
95         navigationStack.push(ActionResultFactory.buildRedirect(
96                 I18N.MESSAGES.NAVI_LIST_ENTRY_TRACKBACKS, currentActionPath));
97
98         return ENTRIES_LIST_FORWARD;
99     }
100
101 }
Popular Tags