diff options
author | Shawn F. Cook | 2011-06-10 22:55:16 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-06-10 22:55:16 +0000 |
commit | a3c3a6627070de0da987309e0c1b97cf3ff7b3b5 (patch) | |
tree | 86ad82d46561be31eee9633d3c3de38ae7008efb | |
parent | 891ee1250f302b9d6664023978d3898d54dde210 (diff) | |
download | org.eclipse.osee-a3c3a6627070de0da987309e0c1b97cf3ff7b3b5.tar.gz org.eclipse.osee-a3c3a6627070de0da987309e0c1b97cf3ff7b3b5.tar.xz org.eclipse.osee-a3c3a6627070de0da987309e0c1b97cf3ff7b3b5.zip |
refinement[bgz_349095]: Move MailcapCommandMap type-to-handler mappings into new utility method
-rw-r--r-- | plugins/org.eclipse.osee.mail.admin/src/org/eclipse/osee/mail/admin/internal/MailSendOperation.java | 8 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.mail/src/org/eclipse/osee/mail/MailUtils.java | 13 |
2 files changed, 15 insertions, 6 deletions
diff --git a/plugins/org.eclipse.osee.mail.admin/src/org/eclipse/osee/mail/admin/internal/MailSendOperation.java b/plugins/org.eclipse.osee.mail.admin/src/org/eclipse/osee/mail/admin/internal/MailSendOperation.java index 999ee81da3e..77e86acfa10 100644 --- a/plugins/org.eclipse.osee.mail.admin/src/org/eclipse/osee/mail/admin/internal/MailSendOperation.java +++ b/plugins/org.eclipse.osee.mail.admin/src/org/eclipse/osee/mail/admin/internal/MailSendOperation.java @@ -21,6 +21,7 @@ import javax.mail.internet.MimeMessage; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osee.framework.core.operation.AbstractOperation; import org.eclipse.osee.mail.MailMessage; +import org.eclipse.osee.mail.MailUtils; import org.eclipse.osee.mail.SendMailOperation; /** @@ -53,12 +54,7 @@ public final class MailSendOperation extends AbstractOperation implements SendMa @Override protected void doWork(IProgressMonitor monitor) throws Exception { - MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); - mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); - mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); - mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); - mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); - mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); + MailcapCommandMap mc = MailUtils.getMailcapCommandMap(); CommandMap.setDefaultCommandMap(mc); //ClassLoader original = Thread.currentThread().getContextClassLoader(); diff --git a/plugins/org.eclipse.osee.mail/src/org/eclipse/osee/mail/MailUtils.java b/plugins/org.eclipse.osee.mail/src/org/eclipse/osee/mail/MailUtils.java index e808d5fae28..8546b65be98 100644 --- a/plugins/org.eclipse.osee.mail/src/org/eclipse/osee/mail/MailUtils.java +++ b/plugins/org.eclipse.osee.mail/src/org/eclipse/osee/mail/MailUtils.java @@ -16,7 +16,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Date; +import javax.activation.CommandMap; import javax.activation.DataSource; +import javax.activation.MailcapCommandMap; import javax.mail.BodyPart; import javax.mail.MessagingException; import javax.mail.MultipartDataSource; @@ -33,6 +35,17 @@ public final class MailUtils { // Utility Class } + public static MailcapCommandMap getMailcapCommandMap() { + MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap(); + mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html"); + mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml"); + mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain"); + mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed"); + mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822"); + return mc; + } + + //The String.format can handle the '%' character. public static DataSource createFromString(String name, String message, Object... args) { String data = String.format(message, args); StringDataSource dataSource = new StringDataSource(name, data); |