org.shaker.dwu
Class BugProfile

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--org.shaker.dwu.BugProfile
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public final class BugProfile
extends java.util.Properties

Objects of this class describe occured Bugs by collecting specific informations like the machine/program state, the exception stuff and further more. The profile can be extended with formerly collected infos and gets finally exported into a mail. Supported formats:

Author:
Philipp Bartsch (codeshaker@gmx.net), GPL License
See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
private  BugMail bugMail
           
protected static java.lang.String DATE
          Date key
static java.lang.String ERROR_CLASS
          Error class key
static java.lang.String MAIL_TO
          Recipient key
static java.lang.String MESSAGE
          Message key
static java.lang.String PRODUCT_NAME
          Product name key
static java.lang.String PRODUCT_VERSION
          (Product) Version key
private  java.io.File profileFile
          The physical file representation of this BugProfile
protected static java.util.ArrayList propertyFilter
          Positive property filter list
static java.lang.String SEND_FORMAT
          The mail format
private static Settings SETTINGS
          A reference to the settings
protected static java.lang.String STACK_TRACE
          Stacktrace key
private  java.lang.String stackHash
          String representation of the hashvalue
static java.lang.String USER_COMMENT
          User comment key
 
Fields inherited from class java.util.Properties
defaults, hexDigit, keyValueSeparators, serialVersionUID, specialSaveChars, strictKeyValueSeparators, whiteSpaceChars
 
Fields inherited from class java.util.Hashtable
count, emptyEnumerator, emptyIterator, ENTRIES, entrySet, KEYS, keySet, loadFactor, modCount, table, threshold, values, VALUES
 
Constructor Summary
(package private) BugProfile(java.lang.Object message, int hashSig, java.lang.String errorclass, java.lang.String mailTo)
          Creates a BugProfile based on a error string, using a manually created hashcode signature.
(package private) BugProfile(java.lang.Object message, java.lang.String stackTrace, java.lang.String errorclass, java.lang.String mailTo)
          Creates a BugProfile that is based on a thrown exception.
(package private) BugProfile(java.lang.String fileName)
          Creates a BugProfile by passing a BugProfile file of the queue.
 
Method Summary
private  BugMail getBugMail(java.lang.String format)
          Sets the BugMail based on the format argument.
(package private)  java.lang.String getHashSig()
          This Method returns its unique StackTrace HashCode
(package private)  java.lang.String getMailBody()
          Returns a mail body formatted on the given custom or default format.
(package private)  java.lang.String getMimeType()
          Returns the MIME type of the BugMail.
private static java.util.ArrayList getPropertyFilter()
          Returns the default system properties filter.
(package private)  javax.mail.internet.InternetAddress getRecipient()
          Returns a InternetAddress object of the recipient
(package private)  java.lang.String getSubjectLine()
          Creates a unique subjectline for mailreports
private  void importOldProfile()
          This Method imports old BugProfiles and keeps user`s comments in mind.
(package private)  void killPhysically()
          Deletes the locally stored BugProfile file.
private  void saveProfileToDisk()
          Saves the profile to disk.
 java.lang.Object setProperty(java.lang.String key, java.lang.String value)
          Sets a property (each piece of information regarding the error is a property).
private  boolean validateState()
          Validates the worth of this Profile.
 
Methods inherited from class java.util.Properties
, continueLine, enumerate, getProperty, getProperty, list, list, load, loadConvert, propertyNames, save, saveConvert, store, toHex, writeln
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, getEnumeration, getIterator, hashCode, isEmpty, keys, keySet, put, putAll, readObject, rehash, remove, size, toString, values, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

STACK_TRACE

protected static final java.lang.String STACK_TRACE
Stacktrace key

ERROR_CLASS

public static final java.lang.String ERROR_CLASS
Error class key

USER_COMMENT

public static final java.lang.String USER_COMMENT
User comment key

MAIL_TO

public static final java.lang.String MAIL_TO
Recipient key

MESSAGE

public static final java.lang.String MESSAGE
Message key

DATE

protected static final java.lang.String DATE
Date key

PRODUCT_VERSION

public static final java.lang.String PRODUCT_VERSION
(Product) Version key

PRODUCT_NAME

public static final java.lang.String PRODUCT_NAME
Product name key

SEND_FORMAT

public static final java.lang.String SEND_FORMAT
The mail format

propertyFilter

protected static final java.util.ArrayList propertyFilter
Positive property filter list

SETTINGS

private static final Settings SETTINGS
A reference to the settings

profileFile

private final java.io.File profileFile
The physical file representation of this BugProfile

stackHash

private final java.lang.String stackHash
String representation of the hashvalue

bugMail

private BugMail bugMail
Constructor Detail

BugProfile

BugProfile(java.lang.Object message,
           java.lang.String stackTrace,
           java.lang.String errorclass,
           java.lang.String mailTo)
     throws java.lang.Exception
Creates a BugProfile that is based on a thrown exception.
Parameters:
message - the exception message (!null)
stackTrace - the StackTrace (!null and not empty)
errorclass - the error class identifier
mailTo - the recipient
Throws:
java.lang.Exception - an exception is thrown, if this profile (and its sig is known as already submitted. This prevents further submissions.

BugProfile

BugProfile(java.lang.Object message,
           int hashSig,
           java.lang.String errorclass,
           java.lang.String mailTo)
     throws java.lang.Exception
Creates a BugProfile based on a error string, using a manually created hashcode signature.
Parameters:
message - the exception message (!null)
hashSig - the hashcode signature
errorclass - the error class identifier
mailTo - the recipient
Throws:
java.lang.Exception - an exception is thrown, if this profile (and its sig is known as already submitted. This prevents further submissions.

BugProfile

BugProfile(java.lang.String fileName)
     throws java.io.IOException
Creates a BugProfile by passing a BugProfile file of the queue.
Parameters:
fileName - the filename
Throws:
java.io.IOException - in case of unexpected filecontent
Method Detail

validateState

private boolean validateState()
Validates the worth of this Profile. This function creates a hash of the current stacktrace and looks into the dwu-propertyfile (property "submitted") wheter this hash is known or not (which indicates that this BugProfile has already been submitted). If the hash is new and unknown, it searches for a file named hashvalue. bug in the report-queue directory (currently the standard dwu-output dir). If this file exists, the current Bug already appeared (n times), but it has never been submitted (thatīs why it has been saved to disk). Afterwards, the older (proposed to be useful) usercomments get imported.
Returns:
BugProfile returns itself if it has never been submitted or null

importOldProfile

private void importOldProfile()
                       throws java.io.IOException
This Method imports old BugProfiles and keeps user`s comments in mind.
Throws:
java.io.IOException - when the import can`t be performed

saveProfileToDisk

private void saveProfileToDisk()
                        throws java.io.IOException
Saves the profile to disk. The profile contains optional older comments.
Throws:
java.io.IOException - thrown in case of error

killPhysically

void killPhysically()
Deletes the locally stored BugProfile file. When this method is called, it is already obsolete, because the profile has been reported!

getHashSig

java.lang.String getHashSig()
This Method returns its unique StackTrace HashCode
Returns:
String hashCode of this StackTrace

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.String value)
Sets a property (each piece of information regarding the error is a property). Standard properties are: If you define own properties: keep in mind that the key string is used as the value label in the submitted mail. So choose "speaking" keynames!
Overrides:
setProperty in class java.util.Properties
Parameters:
key - an int key representation of the current value
value - a string representation of the value
Returns:
the previous value or null

getRecipient

javax.mail.internet.InternetAddress getRecipient()
Returns a InternetAddress object of the recipient
Returns:
InternetAddress the address

getSubjectLine

java.lang.String getSubjectLine()
Creates a unique subjectline for mailreports
Returns:
String the subject (DWU_stackmessage_date)

getMailBody

final java.lang.String getMailBody()
Returns a mail body formatted on the given custom or default format. If the format is not satisfied, this method switches to the default or text format and returns its body.
Returns:
the BugMail
See Also:
what format satisfaction means

getMimeType

final java.lang.String getMimeType()
Returns the MIME type of the BugMail. This type is requested by the internal mail preview pane of DocWhatsUp and the (Mail-)Message object.
Returns:
the MIME type of the BugMail object (something like text/plain, text/html ...)

getBugMail

private final BugMail getBugMail(java.lang.String format)
Sets the BugMail based on the format argument.
Parameters:
format - the format (html, bugzilla or text expected); text used on fault
Returns:
the BugMail object

getPropertyFilter

private static final java.util.ArrayList getPropertyFilter()
Returns the default system properties filter. It is extracted from the shipped jar file or created locally in case of an error.
Returns:
the system properties whitelist