KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > SelectIssue


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * SelectIssue.java
21  *
22  * Created on November 20, 2006, 7:00 PM
23  */

24
25 package org.netbeans.modules.exceptions;
26
27 import java.io.IOException JavaDoc;
28 import java.io.PrintWriter JavaDoc;
29 import java.sql.ResultSet JavaDoc;
30 import java.sql.Statement JavaDoc;
31 import javax.servlet.ServletException JavaDoc;
32 import javax.servlet.http.HttpServlet JavaDoc;
33 import javax.servlet.http.HttpServletRequest JavaDoc;
34 import javax.servlet.http.HttpServletResponse JavaDoc;
35 import static org.netbeans.modules.exceptions.Utils.*;
36
37 /**
38  *
39  * @author jindra
40  * @version
41  */

42 public class SelectIssue extends HttpServlet JavaDoc {
43     private String JavaDoc issueId;
44     public static String JavaDoc ID_PARAM = "Id";
45     /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
46      * @param request servlet request
47      * @param response servlet response
48      */

49     protected void processRequest(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
50     throws ServletException JavaDoc, IOException JavaDoc {
51         try {
52             response.setContentType("text/html;charset=UTF-8");
53             PrintWriter JavaDoc out = response.getWriter();
54             issueId = request.getParameter(ID_PARAM);
55             Statement JavaDoc stmt = getConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
56             out.println("<table border='1'>");
57             // get issue according to ID
58
ResultSet JavaDoc result;
59             result = executeQuery(stmt, SELECT_ISSUE + String.valueOf(issueId));
60             String JavaDoc loggerId="";
61             if (!result.next()){
62                 out.println("Issue Id was not found in ISSUE TABLE");
63             }else{
64                 loggerId = result.getString(3);
65                 out.println(createTableRow("Issue Id", result.getString(1)));
66                 out.println(createTableRow("Summary",result.getString(2)));
67                 out.println(createTableRow("LoggerId",loggerId));
68                 out.println(createTableRow("VM",result.getString(4)));
69                 out.println(createTableRow("Product version",result.getString(5)));
70                 out.println(createTableRow("Component",result.getString(6)));
71                 out.println(createTableRow("SubComponent",result.getString(7)));
72                 out.println(createTableRow("Assign to",result.getString(8)));
73                 out.println(createTableRow("Operating System",result.getString(9)));
74                 out.println(createTableRow("Severity", result.getString(10)));
75             }
76             // select User
77
result = executeQuery(stmt, SELECT_USER + String.valueOf(issueId));
78             if (!result.next()){
79                 out.println("Issue Id was not found in IssueNbUser TABLE");
80             }else{
81                 out.println(createTableRow("Date", result.getString(1)));
82                 out.println(createTableRow("User Name", result.getString(2)));
83             }
84             // select HASHCODE
85
result = executeQuery(stmt, SELECT_HASH_BY_ISSUE + String.valueOf(issueId));
86             if (!result.next()){
87                 out.println("Issue Id was not found in HASHCODE");
88             }else{
89                 out.println(createTableRow("HASH", result.getString(1)));
90             }
91             out.println("</table>");
92             // select StackTrace
93
out.println("<h3>STACK_TRACE:</h3>");
94             result = executeQuery(stmt, SELECT_STACKTRACE + String.valueOf(issueId));
95             if (!result.next()){
96                 out.println("IssueId was not found in StackTrace TABLE");
97             }else{
98                 out.println("<b>MESSAGE:</b>" + result.getString(1)+"<br/>\n");
99                 out.println(result.getString(2)+":<br/>\n");
100             }
101             //select stackTrace lines
102
out.println("<blockquote>");
103             result = executeQuery(stmt, SELECT_LINES + String.valueOf(issueId)+ " order by Line_Order");
104             while (result.next()){
105                 out.println(result.getString(1)+"("+result.getString(2)+":"+result.getString(3)+")<br/>\n");
106             }
107             out.println("</blockquote>");
108             //select comments
109
out.println("<h3>COMMENTS:</h3>");
110             result = executeQuery(stmt, SELECT_COMMENT + String.valueOf(issueId));
111             while (result.next()){
112                 out.println("<p>\n");
113                 out.println("<b>"+result.getString(1)+":</b>");
114                 out.println(result.getString(2)+"\n");
115                 out.println("</p>\n");
116             }
117             result = executeQuery(stmt, SELECT_LOGGER + String.valueOf(loggerId));
118             out.println("<h3>LOGGER:</h3>");
119             String JavaDoc str;
120             while (result.next()){
121                 out.println("<p>\n");
122                 str = Utils.getHTMLLog(result);
123                 out.println(str+"\n");
124                 out.println("</p>\n");
125             }
126             stmt.close();
127         } catch (Exception JavaDoc ex) {
128             java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE,
129                                                              ex.getMessage(), ex);
130         }
131     }
132     private String JavaDoc createTableRow(String JavaDoc name, String JavaDoc value){
133          return "<tr><td>"+name+"</td><td>"+value+"</td></tr>";
134     }
135     
136     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
137
/** Handles the HTTP <code>GET</code> method.
138      * @param request servlet request
139      * @param response servlet response
140      */

141     protected void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
142     throws ServletException JavaDoc, IOException JavaDoc {
143         processRequest(request, response);
144     }
145     
146     /** Handles the HTTP <code>POST</code> method.
147      * @param request servlet request
148      * @param response servlet response
149      */

150     protected void doPost(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
151     throws ServletException JavaDoc, IOException JavaDoc {
152         processRequest(request, response);
153     }
154     
155     /** Returns a short description of the servlet.
156      */

157     public String JavaDoc getServletInfo() {
158         return "This servlet is for showing content of an issue";
159     }
160     // </editor-fold>
161
}
162
Popular Tags