KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > server > uihandler > Exceptions


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  * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
16  */

17
18 package org.netbeans.server.uihandler;
19
20 import java.awt.EventQueue JavaDoc;
21 import java.util.Collections JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24 import java.util.logging.Level JavaDoc;
25 import java.util.logging.LogRecord JavaDoc;
26 import java.util.logging.Logger JavaDoc;
27
28 /**LogRecord number 0 contains userData(operating system, virtual machine,
29  * NetBeans product version, user name, summary and comment
30  * LogRecord number 1 contains lastly thrown exception
31  * LogRecord number 2 contains issueId if duplicate
32  *
33  * @author jindra
34  */

35 public class Exceptions extends Statistics<Map JavaDoc<Integer JavaDoc,LogRecord JavaDoc>> {
36     private static final Logger JavaDoc LOG = Logger.getLogger(Exceptions.class.getName());
37     public static final String JavaDoc USER_CONFIGURATION = "UI_USER_CONFIGURATION"; // NOI18N
38

39     /** Creates a new instance of Exceptions */
40     
41     public Exceptions() {
42         super("Exceptions");
43     }
44     
45     protected Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> newData() {
46         return Collections.emptyMap();
47     }
48     
49     protected Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> process(LogRecord JavaDoc rec) {
50         Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> coll = new HashMap JavaDoc<Integer JavaDoc, LogRecord JavaDoc>();
51         if (USER_CONFIGURATION.equals(rec.getMessage())){
52             coll.put(0, rec);
53         }
54         if (rec.getThrown()!= null){
55             coll.put(1, rec);
56             
57         }
58         return coll;
59     }
60     
61     protected Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> join(Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> one,
62             Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> two) {
63         Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> result = new HashMap JavaDoc<Integer JavaDoc, LogRecord JavaDoc>();
64         // there is only one user data in one report
65
if (one.get(0) != null) result.put(0, one.get(0));
66         else if (two.get(0) != null) result.put(0, two.get(0));
67         //user last exception you get
68
if (two.get(1)!=null) result.put(1, two.get(1));
69         else if (one.get(1) != null) result.put(1, one.get(1));
70         return result;
71     }
72     
73     /*
74      * @return CheckIssue value in LogRecord 2
75      */

76     protected Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> finishSessionUpload(String JavaDoc userId,
77             int sessionNumber,
78             boolean initialParse,
79             Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> data) {
80         int issueId = -2;
81         if (initialParse){
82             LogRecord JavaDoc metaData = data.get(0);
83             if (metaData==null) LOG.info("METADATA = NULL"); // NOI18N
84
else if (metaData.getParameters()==null) LOG.info("PARAMETERS = NULL"); // NOI18N
85
else{
86                 int length = metaData.getParameters().length;
87                 if (length==6){// summary and comment are send => report
88
Throwable JavaDoc thrown = null;
89                     if (data.get(1) != null) thrown = data.get(1).getThrown();
90                     if (thrown != null){
91                         EventQueue.invokeLater(new DbInsertion(metaData, thrown,
92                                 userId + "." + Integer.toString(sessionNumber))); // NOI18N
93
issueId = Utils.checkIssue(thrown);
94                     }else{
95                         LOG.info("THROWN = NULL"); // NOI18N
96
}
97                 }
98             }
99         }
100         LogRecord JavaDoc log = new LogRecord JavaDoc(Level.CONFIG, Integer.toString(issueId));
101         Map JavaDoc<Integer JavaDoc, LogRecord JavaDoc> d = new HashMap JavaDoc<Integer JavaDoc, LogRecord JavaDoc>();
102         d.put(2, log);
103         LOG.finest("EXCEPTIONS UPLOAD FINISHED"); // NOI18N
104
return d;
105     }
106     
107 }
108
Popular Tags