2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
41
package org.netbeans.modules.exceptions.web.action;
43
import java.security.Principal;
44
import java.util.ArrayList;
45
import java.util.Collection;
46
import java.util.Collections;
47
import java.util.Iterator;
49
import java.util.logging.Handler;
50
import java.util.logging.LogRecord;
51
import javax.servlet.http.HttpServletRequest;
52
import javax.servlet.http.HttpServletResponse;
53
import org.apache.struts.action.ActionForm;
54
import org.apache.struts.action.ActionMapping;
55
import org.apache.struts.action.ActionForward;
56
import org.netbeans.modules.exceptions.entity.Comment;
57
import org.netbeans.modules.exceptions.entity.Exceptions;
58
import org.netbeans.modules.exceptions.entity.Nbuser;
59
import org.netbeans.modules.exceptions.utils.LoggerUtils;
60
import org.netbeans.modules.exceptions.utils.PersistenceUtils;
67
public class DetailAction extends ExceptionsAbstractAction {
69
/* forward name="success" path="" */
70
private final static String SUCCESS = "success";
71
private final static String LOGGER = "logger";
74
* This is the action called from the Struts framework.
75
* @param mapping The ActionMapping used to select this instance.
76
* @param form The optional ActionForm bean for this request.
77
* @param request The HTTP Request we are processing.
78
* @param response The HTTP Response we are processing.
79
* @throws java.lang.Exception
82
public ActionForward execute(ActionMapping mapping, ActionForm form,
83
HttpServletRequest request, HttpServletResponse response)
86
Integer newduplicateof = null;
87
Integer newissuezillaid = null;
88
String component = request.getParameter("component");
89
String subcomponent = request.getParameter("subcomponent");
90
String comment = request.getParameter("comment");
91
String username = request.getParameter("username");
92
String duplicateof = request.getParameter("duplicateof");
95
id = new Integer(request.getParameter("id"));
96
} catch (NumberFormatException e) {
99
newduplicateof = new Integer(duplicateof);
100
} catch (NumberFormatException e) {
103
newissuezillaid = new Integer(request.getParameter("issuezillaid"));
104
} catch (NumberFormatException e) {
108
Exceptions exceptions = (Exceptions) PersistenceUtils.getInstance().getEntity(Exceptions.class, id);
111
boolean merge = false;
112
if ((newissuezillaid != null) && (exceptions !=null)) {
113
exceptions.setIssuezillaid(newissuezillaid);
114
exceptions.setIssueManChanged(true);
118
if ((duplicateof != null) && (exceptions !=null)) {
119
Exceptions duplExc = null;
120
if (newduplicateof != null) {
121
duplExc = (Exceptions) PersistenceUtils.getInstance().getEntity(Exceptions.class, newduplicateof);
123
// if (duplicateof != null) {
124
exceptions.setDuplicateof(duplExc);
125
exceptions.setDuplicateManChanged(true);
130
if ((subcomponent != null) && (subcomponent.length() > 0) && (component != null) && (component.length() > 0)) {
131
exceptions.setComponentAndSubcomponent(component, subcomponent);
132
exceptions.setComponentManChanged(true);
136
if ((comment != null) && (comment.length() > 0)) {
137
Comment commentEntity = new Comment();
138
commentEntity.setComment(comment);
139
Principal p = request.getUserPrincipal();
141
System.err.println("** " + p.getName());
142
Collection col = PersistenceUtils.getInstance().find(Nbuser.class,(Map) java.util.Collections.singletonMap("name", Collections.singletonList(p.getName())));
143
if (!col.isEmpty()) {
144
Nbuser nbuser = (Nbuser) col.iterator().next();
145
commentEntity.setNbuserId(nbuser);
147
commentEntity.setExceptionId(exceptions);
148
exceptions.getCommentCollection().add(commentEntity);
154
if (checkPrivileges(request)) {
155
PersistenceUtils.getInstance().merge(exceptions);
157
return mapping.findForward(LOGIN);
160
response.sendRedirect("detail.do?id=" + exceptions.getId());
163
request.setAttribute("exceptions", exceptions);
170
String logger = request.getParameter("logger");
171
if ((logger != null) && (exceptions != null)) {
174
LoggerUtils.getLogRecord(exceptions.getLoggername(), handler);
175
ArrayList lines = new ArrayList();
176
for (Iterator<LogRecord> it = handler.nr.iterator(); it.hasNext();) {
177
LogRecord record = it.next();
178
lines.add(LoggerUtils.getLine(record));
180
request.setAttribute("logger",lines);
181
return mapping.findForward(LOGGER);
184
request.setAttribute("components", PersistenceUtils.getInstance().getComponents().getComponentsSet());
186
return mapping.findForward(SUCCESS);
190
class H extends Handler {
191
public ArrayList<LogRecord> nr = new ArrayList<LogRecord>();
193
public void publish(LogRecord arg0) {
197
public void flush() {
200
public void close() throws SecurityException {