use of oap.mail.MailException in project oap by oaplatform.
the class XmlMessageParser method parse.
public Message parse(String content) {
try {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
SaxMessageParser handler = new SaxMessageParser();
parser.parse(new ByteArrayInputStream(content.getBytes(UTF_8)), handler);
return handler.getMessage();
} catch (ParserConfigurationException | SAXException | IOException e) {
throw new MailException(e);
}
}
use of oap.mail.MailException in project oap by oaplatform.
the class VelocityTemplateTransformer method transform.
public synchronized String transform(Template template) {
try {
VelocityContext context = new VelocityContext();
Map<String, Object> parameters = template.getParameters();
for (String key : parameters.keySet()) context.put(key, parameters.get(key));
StringWriter writer = new StringWriter();
engine.evaluate(context, writer, "mail", template.getContent());
writer.close();
return writer.toString();
} catch (ParseErrorException | MethodInvocationException | ResourceNotFoundException | IOException e) {
throw new MailException(e);
}
}
Aggregations