Source code: org/sbugs/actions/DisplayDefect.java
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; version 2 only.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14 */
15 package org.sbugs.actions;
16
17 import org.apache.struts.action.*;
18 import javax.servlet.http.*;
19 import java.sql.*;
20
21 import org.sbugs.model.defect.Defect;
22 import org.sbugs.logic.defect.DefectLogic;
23
24 public class DisplayDefect extends Action
25 {
26 public ActionForward perform( ActionMapping mapping,
27 ActionForm form,
28 HttpServletRequest request,
29 HttpServletResponse response )
30 {
31 String defectId = request.getParameter( "defectId" );
32 if( defectId == null )
33 {
34 return mapping.findForward( "search" );
35 }
36
37 try
38 {
39 Defect foundDefect = DefectLogic
40 .getInstance()
41 .loadDefect( Integer.parseInt( defectId ) );
42 request.setAttribute( "defect", foundDefect );
43
44 return mapping.findForward( "result" );
45 }
46 catch( SQLException sqle )
47 {
48 getServlet().log( sqle.getMessage(), sqle );
49 return mapping.findForward( "error" );
50 }
51 }
52 }