Author: keith Date: Sat Jul 12 04:57:43 2008 New Revision: 19168 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19168
Log: Fixing Mashup-749 Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/email/Email.java Modified: trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/email/Email.java URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/email/Email.java?rev=19168&r1=19167&r2=19168&view=diff ============================================================================== --- trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/email/Email.java (original) +++ trunk/mashup/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/email/Email.java Sat Jul 12 04:57:43 2008 @@ -24,6 +24,9 @@ import org.wso2.mashup.MashupFault; import org.wso2.mashup.hostobjects.file.JavaScriptFileObject; import org.wso2.utils.ServerConfiguration; +import org.wso2.javascript.xmlimpl.XML; +import org.apache.axiom.om.OMNode; +import org.apache.axiom.om.OMElement; import javax.activation.DataHandler; import javax.activation.DataSource; @@ -196,11 +199,25 @@ return text; } - public void jsSet_html(String html) throws MessagingException, IOException { - this.html = html; + public void jsSet_html(Object html) throws MessagingException, IOException { + if (html instanceof String) { + this.html = (String) html; + } else if (html instanceof XML) { + OMNode node = ((XML) html).getAxiomFromXML(); + if (node instanceof OMElement) { + OMElement htmlElement = (OMElement) node; + this.html = htmlElement.toString(); + } else { + throw new MashupFault("Invalid input argument. The html function accepts " + + "either a String or an XML element."); + } + } else { + throw new MashupFault("Invalid input argument. The html function accepts " + + "either a String or an XML element."); + } BodyPart messageBodyPart = new MimeBodyPart(); DataHandler dataHandler = new DataHandler( - new ByteArrayDataSource(html, "text/html")); + new ByteArrayDataSource(this.html, "text/html")); messageBodyPart.setDataHandler(dataHandler); multipart.addBodyPart(messageBodyPart); } _______________________________________________ Mashup-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
