catlett     01/06/21 14:42:04

  Modified:    mailer/src/org/apache/taglibs/mailer AttachTag.java
  Log:
  updated so that an exception is thrown if the file to be attached does not exist
  
  Revision  Changes    Path
  1.2       +17 -10    
jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/AttachTag.java
  
  Index: AttachTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/AttachTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttachTag.java    2001/05/21 18:22:44     1.1
  +++ AttachTag.java    2001/06/21 21:42:03     1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/AttachTag.java,v 1.1 
2001/05/21 18:22:44 catlett Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/05/21 18:22:44 $
  + * $Header: 
/home/cvs/jakarta-taglibs/mailer/src/org/apache/taglibs/mailer/AttachTag.java,v 1.2 
2001/06/21 21:42:03 catlett Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/06/21 21:42:03 $
    *
    * ====================================================================
    *
  @@ -239,8 +239,8 @@
            throw new JspException("The URL entered as an attachment was " +
                        "incorrectly formatted please check it and try again.");
        } catch(MessagingException e) {
  -         throw new JspException("The Resource named by " + url + " could not "
  -                                + "be attached.");
  +         throw new JspException("The Resource named by " + url + " could not"
  +                                + " be attached.");
        }
   // End of added
       }
  @@ -263,12 +263,19 @@
   // Added by Jayson Falkner - 5/8/2001
        try {
            File file = new File(rpath);
  -         DataSource attachment = new FileDataSource(file);
  -         mbp.setDataHandler(new DataHandler(attachment));
  -         mbp.setFileName(file.getName());
  +         if (file.exists()) {
  +             DataSource attachment = new FileDataSource(file);
  +             mbp.setDataHandler(new DataHandler(attachment));
  +             mbp.setFileName(file.getName());
  +         } else {
  +             // if the file does not exist it is probably an error in the way
  +             // the page author is adding the path throw an exception so this
  +             // can be discovered and fixed
  +             throw new JspException("File " + rpath + " does not exist or " +
  +                                    "the path to the file is incorrect.");
        } catch(MessagingException e) {
  -         throw new JspException("The file named by " + file + " could not be "
  -                                + "attached.");
  +         throw new JspException("The file named by " + file + " could not be"
  +                                + " attached.");
        }
   
   // End of added
  
  
  

Reply via email to