KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > exceptions > web > ListAction


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 package org.netbeans.modules.exceptions.web;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.Arrays JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.Hashtable JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.logging.Level JavaDoc;
27 import java.util.logging.Logger JavaDoc;
28 import javax.naming.Context JavaDoc;
29 import javax.naming.InitialContext JavaDoc;
30 import javax.persistence.EntityManager;
31 import javax.persistence.EntityManagerFactory;
32 import javax.persistence.Persistence;
33 import javax.servlet.http.HttpServletRequest JavaDoc;
34 import javax.servlet.http.HttpServletResponse JavaDoc;
35 import org.apache.struts.action.Action;
36 import org.apache.struts.action.ActionForm;
37 import org.apache.struts.action.ActionMapping;
38 import org.apache.struts.action.ActionForward;
39 import org.netbeans.modules.exceptions.entity.Issue;
40 /**
41  *
42  * @author Jan Horvath
43  * @version
44  */

45
46 public class ListAction extends MyAction {
47     
48     /* forward name="success" path="" */
49     private final static String JavaDoc SUCCESS = "success";
50     private final static String JavaDoc QUERY = "query";
51     private final static String JavaDoc COUNT = "count";
52     /**
53      * This is the action called from the Struts framework.
54      * @param mapping The ActionMapping used to select this instance.
55      * @param form The optional ActionForm bean for this request.
56      * @param request The HTTP Request we are processing.
57      * @param response The HTTP Response we are processing.
58      * @throws java.lang.Exception
59      * @return
60      */

61     public ActionForward execute(ActionMapping mapping, ActionForm form,
62             HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
63             throws Exception JavaDoc {
64         
65         String JavaDoc[] components = request.getParameterValues("component");
66         String JavaDoc[] subcomponents = request.getParameterValues("subcomponent");
67         String JavaDoc[] os = request.getParameterValues("os");
68         String JavaDoc[] vm = request.getParameterValues("vm");
69         String JavaDoc username = request.getParameter("username");
70         
71         Hashtable JavaDoc params = new Hashtable JavaDoc();
72         
73         if (components != null) {
74             params.put("component", Arrays.asList(components));
75         }
76         if (subcomponents != null) {
77             params.put("subcomponent", Arrays.asList(subcomponents));
78         }
79         if (os != null) {
80             params.put("operatingsystem", Arrays.asList(os));
81         }
82         if (vm != null) {
83             params.put("vm", Arrays.asList(vm));
84         }
85         if ((username != null) && (username.length() > 0)) {
86             params.put("username", Collections.singletonList(username));
87         }
88         
89         String JavaDoc query = request.getParameter("query");
90         if (query != null) {
91             return mapping.findForward(QUERY);
92         }
93         
94         String JavaDoc unmapped = request.getParameter("unmapped");
95         if (unmapped != null) {
96             request.setAttribute("issues", findUnmapped());
97             return mapping.findForward(SUCCESS);
98         }
99         
100         
101         
102         String JavaDoc count = request.getParameter("count");
103         if (count != null) {
104             request.setAttribute("count", count(Issue.class, params));
105             return mapping.findForward(COUNT);
106         }
107         
108         request.setAttribute("issues", find(Issue.class, params));
109         return mapping.findForward(SUCCESS);
110         
111     }
112     
113     
114     
115     
116 }
117
Popular Tags