Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/sbugs/actions/EditDefect.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  
22  import org.sbugs.model.user.User;
23  import org.sbugs.forms.EditDefectForm;
24  import org.sbugs.logic.defect.DefectLogic;
25  
26  public class EditDefect extends ProtectedAction
27  {
28    public ActionForward doPerform( ActionMapping mapping,
29                    ActionForm form,
30                    HttpServletRequest request,
31                    HttpServletResponse response )
32    {
33      EditDefectForm editForm = (EditDefectForm)form;
34      if( !editForm.ready() )
35      {
36        request.setAttribute( "editMode", "editMode" );
37        return mapping.findForward( "edit" );
38      }
39      
40      int defectId = Integer.parseInt( request.getParameter( "defectId" ) );
41  
42      if( defectId == 0 )
43      {
44        return mapping.findForward( "search" );
45      }
46      
47      try
48      {
49        DefectLogic.getInstance().updateDefect( getCurrentUser( request ),
50                            defectId,
51                            editForm.getSeverityId(),
52                            editForm.getPriorityId(),
53                            editForm.getNote() );
54        return mapping.findForward( "success" );
55      }
56      catch( SQLException sqle )
57      {
58        getServlet().log( "EditDefect:db_error", sqle );
59        return mapping.findForward( "error" );
60      }
61    }
62  }