X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=crawler%2Fkiss%2Fsrc%2Forg%2Fwamblee%2Fcrawler%2Fkiss%2Fnotification%2FMailNotifier.java;h=8d2ccf97422186687ff2bcac47deccbca941c359;hb=4ca88c7dec30b0fae2338844b44f43d4592a42c6;hp=1c970a7151f11f1260583a873636299b3397ab5b;hpb=3477b9963f17a8d32a1b62a80f80bcac9df939cf;p=utils diff --git a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailNotifier.java b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailNotifier.java index 1c970a71..8d2ccf97 100644 --- a/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailNotifier.java +++ b/crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailNotifier.java @@ -4,8 +4,6 @@ */ package org.wamblee.crawler.kiss.notification; -import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Date; @@ -16,13 +14,9 @@ import javax.xml.transform.TransformerException; import org.apache.commons.mail.EmailException; import org.apache.commons.mail.HtmlEmail; -import org.apache.xml.serialize.OutputFormat; -import org.apache.xml.serialize.XMLSerializer; import org.dom4j.Element; -import org.w3c.dom.Document; -import org.wamblee.io.FileResource; -import org.wamblee.io.InputResource; -import org.wamblee.xml.XSLT; +import org.wamblee.xml.ClasspathUriResolver; +import org.wamblee.xml.XslTransformer; /** * A notifier that uses SMTP to notify users by mail. @@ -84,10 +78,8 @@ public class MailNotifier implements Notifier { mail.setSentDate(new Date()); mail.setSubject(_subject); - String htmlText = transformReport(aReport, new FileResource( - new File(_htmlXslt))); - String plainText = transformReport(aReport, new FileResource( - new File(_textXslt))); + String htmlText = transformReport(aReport, _htmlXslt); + String plainText = transformReport(aReport, _textXslt); mail.setHtmlMsg(htmlText); mail.setTextMsg(plainText); @@ -117,9 +109,10 @@ public class MailNotifier implements Notifier { * @throws TransformerException * In case of problems transforming. */ - private String transformReport(Element aReport, InputResource aXslt) + private String transformReport(Element aReport, String aXslt) throws IOException, TransformerException { String reportXmlText = aReport.asXML(); - return new XSLT().textTransform(reportXmlText.getBytes(), aXslt); + XslTransformer xsltProcessor = new XslTransformer(new ClasspathUriResolver()); + return xsltProcessor.textTransform(reportXmlText.getBytes(), xsltProcessor.resolve(aXslt)); } }