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

Quick Search    Search Deep

Source code: org/sbugs/actions/CreateDefect.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  
16  package org.sbugs.actions;
17  
18  import org.apache.struts.action.*;
19  import javax.servlet.http.*;
20  import java.sql.*;
21  
22  import org.sbugs.forms.CreateDefectForm;
23  import org.sbugs.model.defect.Defect;
24  import org.sbugs.logic.defect.DefectLogic;
25  
26  public class CreateDefect extends Action
27  {
28    public ActionForward perform( ActionMapping mapping,
29                    ActionForm form,
30                    HttpServletRequest request,
31                    HttpServletResponse response )
32    {
33      CreateDefectForm newDefect = (CreateDefectForm)form;
34      
35      if( newDefect.readyToCreate() )
36      {
37        try
38        {
39          Defect defect = new Defect( newDefect.getHeadline() );
40          defect.setEmailAddresses( newDefect.getAddlEmailAddr() );
41          defect.setDescription( newDefect.getDescription() );
42          defect.setPriorityId( newDefect.getPriorityId() );
43          defect.setSeverityId( newDefect.getSeverityId() );
44          if( (newDefect.getOwnerId() != null)
45            && !("".equals( newDefect.getOwnerId() ) ) )
46          {
47            defect.setOwnerId( Integer.parseInt( newDefect.getOwnerId() ) );
48          }
49          
50          DefectLogic.getInstance().createDefect( defect );
51          
52          request.removeAttribute( "createDefectForm" );
53          request.setAttribute( "success", "create.defect.success" );
54        }
55        catch( SQLException sqle )
56        {
57          getServlet().log( sqle.getMessage(), sqle );
58          request.setAttribute( Action.ERROR_KEY, sqle.getMessage() );
59        }
60      }
61      
62      return mapping.findForward( "new_defect" );
63    }
64  }