org.webdocwf.util.smime.exception
Class SMIMEException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--org.webdocwf.util.smime.exception.SMIMEException
All Implemented Interfaces:
java.io.Serializable

public class SMIMEException
extends java.lang.Exception

SMIMEException is exception which is thrown in the classes specific for SMIME and in the processes associated with SMIME. It contains messages describing appeared problems and contains name of the class where the exception was thrown.

SMIMEException, as one of his arguments, can convey non SMIME exception (if it is reason of rising SMIMEException). Later this argument (Exception) can be restored by getNonSMIMEException method and examined (for example by using instanceof operator).

This exception also has posibilities for displaying errors or warnings on screen, and for logging errors and warnings into SMIMEerr.log file (at defined directory).

See Also:
Serialized Form

Field Summary
static java.lang.String errorFileName
          File for logging errors (SMIMEerr.log) .
 
Constructor Summary
SMIMEException(java.lang.Object obj0, int errNumb0)
          Construction with the given object and the appropriate error number.
SMIMEException(java.lang.Object obj0, java.lang.String text0)
          Construction with the given object and the error text message
 
Method Summary
 void addNonSMIMEException(java.lang.Exception exception0, java.lang.String exceptionName0)
          Stores non SMIME exception (reason for rising SMIMEException) inside of SMIMEException object.
 void displayErrors(java.lang.String errorText0)
          Prints error messages to screen.
 java.lang.String getClassOfException()
          Returns the class name of the object where exception arrised
static java.lang.String getErrorFilePath(java.lang.String path0)
          Gets SMIMEerror.log file path.
 java.lang.String getInformation()
          Returns message of the exception with the specified location of the exception
static SMIMEException getInstance(java.lang.Object obj0, java.lang.Exception e0, java.lang.String method0)
          Static metod which constructs and returns SMIMEException object with the given object, exception, and name of method inside which this method is called.
 java.lang.Exception getNonSMIMEException()
          Returns non SMIME exception stored inside of SMIMEException object, which was the reason for rising SMIMEException.
 java.lang.String getNonSMIMEExceptionName()
          Gets external exception name (non SMIME exception which is reason for rising SMIMEException).
 void loggingErrors(java.lang.String errorText0)
          Prints error messages to SMIMEerror.log file.
static void setErrorFilePath(java.lang.String path0)
          Sets path for SMIMEerr.log file.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace, printStackTrace, printStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

errorFileName

public static final java.lang.String errorFileName
File for logging errors (SMIMEerr.log) .
Constructor Detail

SMIMEException

public SMIMEException(java.lang.Object obj0,
                      java.lang.String text0)
Construction with the given object and the error text message
Parameters:
obj0 - class type - origin of exception (represented by key word "this"). In static classes, objO is String which represents the class name.
text0 - message of the exception

SMIMEException

public SMIMEException(java.lang.Object obj0,
                      int errNumb0)
Construction with the given object and the appropriate error number.
Parameters:
obj0 - class type - origin of exception (represented by key word "this"). In static classes, objO is String which represents the class name.
errNumb0 - error number corresponds to appropriate error message stored in ErrorStorage class.
Method Detail

getInstance

public static SMIMEException getInstance(java.lang.Object obj0,
                                         java.lang.Exception e0,
                                         java.lang.String method0)
Static metod which constructs and returns SMIMEException object with the given object, exception, and name of method inside which this method is called. This construction is designed for handling non SMIMEExceptions. In the process of construction, given exception object is explored and stored in inner private variable. This constructor replaces many lines of code which can look like following:

if (e instanceof javax.mail.MessagingException)
excType = "javax.mail.MessagingException";
else if (e instanceof java.io.IOException)
excType = "java.io.IOException";
else if(e instanceof java.io.UnsupportedEncodingException)
excType = "java.io.UnsupportedEncodingException";

String err = ErrorStorage.getErrorMesage(1999) +
System.getProperty("line.separator") +
e.getMessage() +
System.getProperty("line.separator") +
excType + " captured in MessageConvertor method of" +
" MimeAssist class and thrown as SMIMEException.";

SMIMEException es = new
SMIMEException("org.webdocwf.util.smime.util.MimeAssist", err);
es.addNonSMIMEException(e, excType);

If unknown non SMIMEException is stored inside of SMIMEException object getNonSMIMEExceptionName() method will return string: "java.lang.Exception". SMIMEException could not be stored inside other SMIMEException object, and returned value of this method will be the same SMIMEException passed to this method as argument.
Parameters:
obj0 - class type - origin of exception (represented by key word "this"). In static classes, objO is String which represents the class name.
exception0 - non SMIME Exception which will by carried inside of the generated SMIMEException object.
method0 - name of method where this method is used. If it is left as null, it will get value "unknown"

getClassOfException

public java.lang.String getClassOfException()
Returns the class name of the object where exception arrised
Returns:
Name of the class

getInformation

public java.lang.String getInformation()
Returns message of the exception with the specified location of the exception
Returns:
Information message about arrised Exception

setErrorFilePath

public static void setErrorFilePath(java.lang.String path0)
Sets path for SMIMEerr.log file.
Parameters:
path0 - path for logging error file. If entered path is invalid, SMIMEerr.log file will be placed at default location.

getErrorFilePath

public static java.lang.String getErrorFilePath(java.lang.String path0)
Gets SMIMEerror.log file path.
Returns:
Error logging file path.

displayErrors

public void displayErrors(java.lang.String errorText0)
Prints error messages to screen.
Parameters:
errorText0 - error text which will be displayed at screen. If it is null, error message returned by getInformation() method will be displayed.

loggingErrors

public void loggingErrors(java.lang.String errorText0)
Prints error messages to SMIMEerror.log file. If destination of log directory or SMIMEerr.log file do not exist, they will be created.
Parameters:
errorText0 - error text which will be logged to file. If it is null, error message returned by getInformation() method will be printed to file.

addNonSMIMEException

public void addNonSMIMEException(java.lang.Exception exception0,
                                 java.lang.String exceptionName0)
Stores non SMIME exception (reason for rising SMIMEException) inside of SMIMEException object.
Parameters:
exception0 - non SMIME exception which must extend Exception class.
exceptionName0 - name of non SMIMEException. Default value is: org.webdocwf.util.smime.exception.SMIMEException which means that reason for that exception is not non SMIME exception.

getNonSMIMEException

public java.lang.Exception getNonSMIMEException()
Returns non SMIME exception stored inside of SMIMEException object, which was the reason for rising SMIMEException. This method has sense only if non SMIME exception object was previosly added to SMIMEException object by addNonSMIMEException() method. Otherwise, it returns null.

getNonSMIMEExceptionName

public java.lang.String getNonSMIMEExceptionName()
Gets external exception name (non SMIME exception which is reason for rising SMIMEException).
Returns:
Name of external exception (non SMIME exception).


Copyright © 2002-2002 Together Teamlösungen. All Rights Reserved.