cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation SendMailTransformer.java
Date Thu, 06 Nov 2003 08:58:58 GMT
cziegeler    2003/11/06 00:58:58

  Modified:    src/blocks/mail/java/org/apache/cocoon/mail/transformation
                        SendMailTransformer.java
  Log:
  Applying fix for correcting namespace handling in the mail transformer submitted by Martin
Holz (holz@fiz-chemie.de)
  
  Revision  Changes    Path
  1.7       +38 -29    cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
  
  Index: SendMailTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SendMailTransformer.java	7 Oct 2003 13:53:24 -0000	1.6
  +++ SendMailTransformer.java	6 Nov 2003 08:58:58 -0000	1.7
  @@ -223,10 +223,10 @@
       public static final String ELEMENT_ATTACHMENT         = "attachment";
       public static final String ELEMENT_ATTACHMENT_CONTENT = "content";
       public static final String ELEMENT_EMAIL_PREFIX       = "email";
  -    public static final String ELEMENT_EMAIL_SUCCESS      = ELEMENT_EMAIL_PREFIX +
  -                                                            ":success";
  -    public static final String ELEMENT_EMAIL_FAILURE      = ELEMENT_EMAIL_PREFIX +
  -                                                            ":failure";
  +    public static final String ELEMENT_ERROR              = "error";
  +    public static final String ELEMENT_SUCCESS            = "success";
  +    public static final String ELEMENT_FAILURE            = "failure";
  +    public static final String ELEMENT_RESULT              = "result";
   
       /*
        * mode-constants
  @@ -298,12 +298,15 @@
           this.attachments = new Vector();
           this.appendToAddress(s, ";");
   
  -        try {
  -            this.subject = new StringBuffer(par.getParameter(PARAM_SUBJECT));
  -            this.body    = new StringBuffer(par.getParameter(PARAM_BODY));
  -        } catch (Exception e) {
  -            this.getLogger().error("Error while retrieving Parameter", e);
  -        }
  +	try {
  +	    this.subject = new StringBuffer(par.getParameter(PARAM_SUBJECT));
  +	} catch (ParameterException pe) {
  +	    this.getLogger().debug("Parameter <subject> not set."); 
  +	} try {
  +	    this.body    = new StringBuffer(par.getParameter(PARAM_BODY));
  +	} catch (ParameterException pe) {
  +	    this.getLogger().debug("Parameter <body> not set."); 
  +	}				    
   
           this.defaultNamespaceURI = NAMESPACE;
       }
  @@ -456,18 +459,20 @@
               props.put("mail.smtp.host", this.mailHost);
   
               if (this.subject == null) {
  -                super.sendStartElementEvent("email:error");
  +		        this.ignoreHooksCount++;
  +                super.sendStartElementEventNS(ELEMENT_ERROR);
                   super.sendTextEvent("Subject not available - sending mail aborted");
  -                super.sendEndElementEvent("email:error");
  -
  +                super.sendEndElementEventNS(ELEMENT_ERROR);
  +		        this.ignoreHooksCount--;
                   return;
               }
   
               if ((this.body == null) && (this.bodyURI == null)) {
  -                super.sendStartElementEvent("email:error");
  +		        this.ignoreHooksCount++;
  +                super.sendStartElementEventNS(ELEMENT_ERROR);
                   super.sendTextEvent("Mailbody not available - sending mail aborted");
  -                super.sendEndElementEvent("email:error");
  -
  +                super.sendEndElementEventNS(ELEMENT_ERROR);
  +		        this.ignoreHooksCount--;
                   return;
               }
   
  @@ -479,7 +484,8 @@
   
               this.smtpMessage = setUpMessage(session);
   
  -            super.sendStartElementEvent("email:result");
  +	        this.ignoreHooksCount++;
  +            super.sendStartElementEventNS(ELEMENT_RESULT);
   
               if (this.sendPartial == true) {
                   for (int i = 0; i < this.toAddresses.size(); i++) {
  @@ -492,7 +498,8 @@
               }
   
               trans.close();
  -            super.sendEndElementEvent("email:result");
  +            super.sendEndElementEventNS(ELEMENT_RESULT);
  +	    this.ignoreHooksCount--;
           } catch (Exception sE) {
               this.getLogger().error("sendMail-Error", sE);
               this.sendExceptionElement(sE);
  @@ -648,27 +655,28 @@
               String tmpAddress = addressArr[i].getAddress().getAddress();
   
               if (addressArr[i].getSendMailResult() == null) {
  -                impl.addAttribute(NAMESPACE, ELEMENT_EMAIL_SUCCESS, "to",
  +                impl.addAttribute("", "to", "to",
                                     "CDATA", tmpAddress);
  -                super.sendStartElementEvent(ELEMENT_EMAIL_SUCCESS, impl);
  +                super.sendStartElementEventNS(ELEMENT_SUCCESS, impl);
                   super.sendTextEvent("Mail sent");
  -                super.sendEndElementEvent(ELEMENT_EMAIL_SUCCESS);
  +                super.sendEndElementEventNS(ELEMENT_SUCCESS);
               } else {
  -                impl.addAttribute(NAMESPACE, ELEMENT_EMAIL_FAILURE, "to",
  +                impl.addAttribute("", "to", "to",
                                     "CDATA", tmpAddress);
  -                super.sendStartElementEvent(ELEMENT_EMAIL_FAILURE, impl);
  +                super.sendStartElementEventNS(ELEMENT_FAILURE, impl);
                   super.sendTextEvent(addressArr[i].getSendMailResult());
  -                super.sendEndElementEvent(ELEMENT_EMAIL_FAILURE);
  +                super.sendEndElementEventNS(ELEMENT_FAILURE);
               }
           }
       }
   
       private void sendExceptionElement(Exception ex) {
           try {
  -            super.sendStartElementEvent("email:exception");
  -            super.sendStartElementEvent("email:message");
  +	    this.ignoreHooksCount++;
  +            super.sendStartElementEventNS("exception");
  +            super.sendStartElementEventNS("message");
               super.sendTextEvent(ex.getMessage());
  -            super.sendEndElementEvent("email:message");
  +            super.sendEndElementEventNS("message");
               
               /* only with jdk 1.4
               super.sendStartElementEvent("email:stacktrace");
  @@ -680,7 +688,8 @@
   
               super.sendEndElementEvent("email:stacktrace");*/ 
               
  -            super.sendEndElementEvent("email:exception");
  +            super.sendEndElementEventNS("exception");
  +	    this.ignoreHooksCount--;
           } catch (SAXException e) {
               this.getLogger().error("Error while sending a SAX-Event", e);
           }
  
  
  

Mime
View raw message