You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by vd...@apache.org on 2003/11/19 13:00:52 UTC

cvs commit: xml-security/src/org/apache/xml/security/exceptions XMLSecurityException.java

vdkoogh     2003/11/19 04:00:52

  Modified:    src/org/apache/xml/security/exceptions
                        XMLSecurityException.java
  Log:
  roll back to version 1.6. Version 1.7+ are dependent on JDK1.4
  
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.9       +134 -7    xml-security/src/org/apache/xml/security/exceptions/XMLSecurityException.java
  
  Index: XMLSecurityException.java
  ===================================================================
  RCS file: /home/cvs/xml-security/src/org/apache/xml/security/exceptions/XMLSecurityException.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XMLSecurityException.java	23 Sep 2003 23:26:31 -0000	1.8
  +++ XMLSecurityException.java	19 Nov 2003 12:00:52 -0000	1.9
  @@ -60,8 +60,11 @@
   
   
   
  +import java.io.PrintStream;
  +import java.io.PrintWriter;
   import java.text.MessageFormat;
   
  +import org.apache.xml.security.utils.Constants;
   import org.apache.xml.security.utils.I18n;
   
   
  @@ -98,12 +101,23 @@
    * @author Christian Geuer-Pollmann
    */
   public class XMLSecurityException extends Exception {
  +
  +   /** Field originalException */
  +   protected Exception originalException = null;
  +
  +   /** Field msgID */
  +   protected String msgID;
  +
      /**
       * Constructor XMLSecurityException
       *
       */
      public XMLSecurityException() {
  -      super();
  +
  +      super("Missing message string");
  +
  +      this.msgID = null;
  +      this.originalException = null;
      }
   
      /**
  @@ -111,8 +125,12 @@
       *
       * @param msgID
       */
  -   public XMLSecurityException(String message) {
  -      super(message);
  +   public XMLSecurityException(String msgID) {
  +
  +      super(I18n.getExceptionMessage(msgID));
  +
  +      this.msgID = msgID;
  +      this.originalException = null;
      }
   
      /**
  @@ -122,7 +140,11 @@
       * @param exArgs
       */
      public XMLSecurityException(String msgID, Object exArgs[]) {
  +
         super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs));
  +
  +      this.msgID = msgID;
  +      this.originalException = null;
      }
   
      /**
  @@ -130,8 +152,15 @@
       *
       * @param originalException
       */
  -   public XMLSecurityException(Throwable cause) {
  -		super(cause);
  +   public XMLSecurityException(Exception originalException) {
  +
  +      super("Missing message ID to locate message string in resource bundle \""
  +            + Constants.exceptionMessagesResourceBundleBase
  +            + "\". Original Exception was a "
  +            + originalException.getClass().getName() + " and message "
  +            + originalException.getMessage());
  +
  +      this.originalException = originalException;
      }
   
      /**
  @@ -140,8 +169,12 @@
       * @param msgID
       * @param originalException
       */
  -   public XMLSecurityException(String message, Throwable cause) {
  -		super(message, cause);
  +   public XMLSecurityException(String msgID, Exception originalException) {
  +
  +      super(I18n.getExceptionMessage(msgID, originalException));
  +
  +      this.msgID = msgID;
  +      this.originalException = originalException;
      }
   
      /**
  @@ -153,6 +186,100 @@
       */
      public XMLSecurityException(String msgID, Object exArgs[],
                                  Exception originalException) {
  +
         super(MessageFormat.format(I18n.getExceptionMessage(msgID), exArgs));
  +
  +      this.msgID = msgID;
  +      this.originalException = originalException;
  +   }
  +
  +   /**
  +    * Method getMsgID
  +    *
  +    *
  +    */
  +   public String getMsgID() {
  +
  +      if (msgID == null) {
  +         return "Missing message ID";
  +      } else {
  +         return msgID;
  +      }
  +   }
  +
  +   /**
  +    * Method toString
  +    *
  +    *
  +    */
  +   public String toString() {
  +
  +      String s = this.getClass().getName();
  +      String message = super.getLocalizedMessage();
  +
  +      if (message != null) {
  +         message = s + ": " + message;
  +      } else {
  +         message = s;
  +      }
  +
  +      if (originalException != null) {
  +         message = message + "\nOriginal Exception was "
  +                   + originalException.toString();
  +      }
  +
  +      return message;
  +   }
  +
  +   /**
  +    * Method printStackTrace
  +    *
  +    */
  +   public void printStackTrace() {
  +
  +      synchronized (System.err) {
  +         super.printStackTrace(System.err);
  +
  +         if (this.originalException != null) {
  +            this.originalException.printStackTrace(System.err);
  +         }
  +      }
  +   }
  +
  +   /**
  +    * Method printStackTrace
  +    *
  +    * @param printwriter
  +    */
  +   public void printStackTrace(PrintWriter printwriter) {
  +
  +      super.printStackTrace(printwriter);
  +
  +      if (this.originalException != null) {
  +         this.originalException.printStackTrace(printwriter);
  +      }
  +   }
  +
  +   /**
  +    * Method printStackTrace
  +    *
  +    * @param printstream
  +    */
  +   public void printStackTrace(PrintStream printstream) {
  +
  +      super.printStackTrace(printstream);
  +
  +      if (this.originalException != null) {
  +         this.originalException.printStackTrace(printstream);
  +      }
  +   }
  +
  +   /**
  +    * Method getOriginalException
  +    *
  +    *
  +    */
  +   public Exception getOriginalException() {
  +      return originalException;
      }
   }