1 13 14 package org.ejbca.util; 15 16 import java.util.HashMap ; 17 18 import javax.mail.MessagingException ; 19 import javax.mail.Session ; 20 import javax.mail.internet.MimeMessage ; 21 22 43 public class TemplateMimeMessage extends MimeMessage { 44 45 46 private HashMap patterns; 47 48 56 public TemplateMimeMessage(HashMap patterns, Session session) { 57 super(session); 58 this.patterns = patterns; 59 } 60 61 public void setSubject(String s) throws MessagingException { 62 setSubject(s, null); 63 } 64 65 public void setSubject(String s, String s1) throws MessagingException { 66 String interpolatedContent = interpolate(s); 67 super.setSubject(interpolatedContent, s1); 68 } 69 70 public void setContent(Object content, String s) throws MessagingException { 71 if(!(content instanceof String )) { 73 throw new MessagingException ("Requires a String content, was given object of type " + content.getClass().toString()); 74 } 75 String interpolatedContent = interpolate((String )content); 76 super.setContent(interpolatedContent, s); 77 } 78 79 80 85 protected String interpolate(String input) { 86 return NotificationParamGen.interpolate(patterns, input); 87 } 88 89 } 90 | Popular Tags |