ate         2005/03/07 06:00:03

  Modified:    jetspeed-api/src/java/org/apache/jetspeed/exception
                        JetspeedRuntimeException.java
                        JetspeedException.java
  Log:
  Enhancements to JetspeedException and JetspeedRuntimeException to support 
KeyedMessages for message definition.
  See: http://issues.apache.org/jira/browse/JS2-219
  
  Revision  Changes    Path
  1.3       +52 -0     
jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/exception/JetspeedRuntimeException.java
  
  Index: JetspeedRuntimeException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/exception/JetspeedRuntimeException.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedRuntimeException.java     20 Jul 2004 18:51:39 -0000      1.2
  +++ JetspeedRuntimeException.java     7 Mar 2005 14:00:02 -0000       1.3
  @@ -15,6 +15,11 @@
    */
   package org.apache.jetspeed.exception;
   
  +import java.util.Locale;
  +import java.util.ResourceBundle;
  +
  +import org.apache.jetspeed.i18n.KeyedMessage;
  +
   
   /**
    * Base exception for all RuntimeExceptions defined within Jetspeed.
  @@ -23,6 +28,10 @@
   public class JetspeedRuntimeException extends RuntimeException
   {
   
  +    public static final String KEYED_MESSAGE_BUNDLE = 
"org.apache.jetspeed.exception.JetspeedExceptionMessages";
  +    
  +    private KeyedMessage keyedMessage;
  +    
       /**
        * 
        */
  @@ -39,6 +48,12 @@
           super(arg0);
       }
   
  +    public JetspeedRuntimeException(KeyedMessage typedMessage) 
  +    {
  +        super(typedMessage.getMessage());
  +        this.keyedMessage = typedMessage;
  +    }
  +    
       /**
        * @param arg0
        */
  @@ -56,4 +71,41 @@
           super(arg0, arg1);
       }
   
  +    public JetspeedRuntimeException(KeyedMessage keyedMessage, Throwable 
nested)
  +    {
  +        super(keyedMessage.getMessage(), nested);
  +        this.keyedMessage = keyedMessage;
  +    }
  +    
  +    public KeyedMessage getKeyedMessage()
  +    {
  +        return keyedMessage;
  +    }
  +    
  +    public String getMessage()
  +    {
  +        if ( keyedMessage != null )
  +        {
  +            return keyedMessage.getMessage();
  +        }
  +        return super.getMessage();
  +    }
  +    
  +    public String getMessage(ResourceBundle bundle)
  +    {
  +        if ( keyedMessage != null )
  +        {
  +            return keyedMessage.getMessage(bundle);
  +        }
  +        return super.getMessage();
  +    }
  +
  +    public String getMessage(Locale locale)
  +    {
  +        if ( keyedMessage != null )
  +        {
  +            return keyedMessage.getMessage(locale);
  +        }
  +        return super.getMessage();
  +    }
   }
  
  
  
  1.3       +52 -3     
jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/exception/JetspeedException.java
  
  Index: JetspeedException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/exception/JetspeedException.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedException.java    20 Jul 2004 18:51:39 -0000      1.2
  +++ JetspeedException.java    7 Mar 2005 14:00:02 -0000       1.3
  @@ -15,6 +15,11 @@
    */
   package org.apache.jetspeed.exception;
   
  +import java.util.Locale;
  +import java.util.ResourceBundle;
  +
  +import org.apache.jetspeed.i18n.KeyedMessage;
  +
   
   /**
    * Occurs when anything unexpected happens within Jetspeed.Any defined 
exceptions
  @@ -26,7 +31,10 @@
   
   public class JetspeedException extends Exception 
   {
  -
  +    public static final String KEYED_MESSAGE_BUNDLE = 
"org.apache.jetspeed.exception.JetspeedExceptionMessages";
  +    
  +    private KeyedMessage keyedMessage;
  +    
       public JetspeedException() 
       {
           super();
  @@ -37,6 +45,12 @@
           super(message);
       }
       
  +    public JetspeedException(KeyedMessage typedMessage) 
  +    {
  +        super(typedMessage.getMessage());
  +        this.keyedMessage = typedMessage;
  +    }
  +    
       public JetspeedException(Throwable nested)
       {
           super(nested);
  @@ -47,6 +61,41 @@
           super(msg, nested);
       }
       
  +    public JetspeedException(KeyedMessage keyedMessage, Throwable nested)
  +    {
  +        super(keyedMessage.getMessage(), nested);
  +        this.keyedMessage = keyedMessage;
  +    }
  +    
  +    public KeyedMessage getKeyedMessage()
  +    {
  +        return keyedMessage;
  +    }
  +    
  +    public String getMessage()
  +    {
  +        if ( keyedMessage != null )
  +        {
  +            return keyedMessage.getMessage();
  +        }
  +        return super.getMessage();
  +    }
  +    
  +    public String getMessage(ResourceBundle bundle)
  +    {
  +        if ( keyedMessage != null )
  +        {
  +            return keyedMessage.getMessage(bundle);
  +        }
  +        return super.getMessage();
  +    }
   
  -
  +    public String getMessage(Locale locale)
  +    {
  +        if ( keyedMessage != null )
  +        {
  +            return keyedMessage.getMessage(locale);
  +        }
  +        return super.getMessage();
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to