Skip to content

Commit

Permalink
rename EmailAttachment impls
Browse files Browse the repository at this point in the history
add InputStreamEmailAttachment
  • Loading branch information
codylerum committed Feb 28, 2011
1 parent 72d21eb commit 405f1fb
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 26 deletions.
Expand Up @@ -11,9 +11,9 @@

import com.google.common.io.ByteStreams;

public class EmailAttachmentFromClassPath extends BaseEmailAttachment
public class ClassPathEmailAttachment extends BaseEmailAttachment
{
public EmailAttachmentFromClassPath(String fileName, String mimeType, ContentDisposition contentDisposition)
public ClassPathEmailAttachment(String fileName, String mimeType, ContentDisposition contentDisposition)
{
super();

Expand All @@ -30,7 +30,7 @@ public EmailAttachmentFromClassPath(String fileName, String mimeType, ContentDis
}
}

public EmailAttachmentFromClassPath(String fileName, String mimeType, ContentDisposition contentDisposition, String contentClass)
public ClassPathEmailAttachment(String fileName, String mimeType, ContentDisposition contentDisposition, String contentClass)
{
this(fileName, mimeType, contentDisposition);
super.addHeader(new Header("Content-Class", contentClass));
Expand Down
Expand Up @@ -14,9 +14,9 @@
* @author Cody Lerum
*
*/
public class EmailAttachmentFromFile extends BaseEmailAttachment
public class FileEmailAttachment extends BaseEmailAttachment
{
public EmailAttachmentFromFile(File file, ContentDisposition contentDisposition)
public FileEmailAttachment(File file, ContentDisposition contentDisposition)
{
super();

Expand All @@ -35,7 +35,7 @@ public EmailAttachmentFromFile(File file, ContentDisposition contentDisposition)
}
}

public EmailAttachmentFromFile(File file, ContentDisposition contentDisposition, String contentClass)
public FileEmailAttachment(File file, ContentDisposition contentDisposition, String contentClass)
{
this(file, contentDisposition);
super.addHeader(new Header("Content-Class", contentClass));
Expand Down
@@ -0,0 +1,39 @@
package org.jboss.seam.mail.core;

import java.io.IOException;
import java.io.InputStream;

import org.jboss.seam.mail.core.enumurations.ContentDisposition;

import com.google.common.io.ByteStreams;

/**
*
* @author Cody Lerum
*
*/
public class InputStreamEmailAttachment extends BaseEmailAttachment
{
public InputStreamEmailAttachment(InputStream inputStream, String fileName, String mimeType, ContentDisposition contentDisposition)
{
super();

try
{
super.setFileName(fileName);
super.setMimeType(mimeType);
super.setContentDisposition(contentDisposition);
super.setBytes(ByteStreams.toByteArray(inputStream));
}
catch (IOException e)
{
throw new AttachmentException("Wasn't able to create email attachment from InputStream");
}
}

public InputStreamEmailAttachment(InputStream inputStream, String fileName, String mimeType, ContentDisposition contentDisposition, String contentClass)
{
this(inputStream, fileName, mimeType, contentDisposition);
super.addHeader(new Header("Content-Class", contentClass));
}
}
Expand Up @@ -8,9 +8,9 @@

import org.jboss.seam.mail.core.enumurations.ContentDisposition;

public class EmailAttachmentFromURL extends BaseEmailAttachment
public class URLEmailAttachment extends BaseEmailAttachment
{
public EmailAttachmentFromURL(String url, String fileName, ContentDisposition contentDisposition)
public URLEmailAttachment(String url, String fileName, ContentDisposition contentDisposition)
{
super();

Expand Down Expand Up @@ -38,7 +38,7 @@ public EmailAttachmentFromURL(String url, String fileName, ContentDisposition co
}
}

public EmailAttachmentFromURL(String url, String fileName, ContentDisposition contentDisposition, String contentClass)
public URLEmailAttachment(String url, String fileName, ContentDisposition contentDisposition, String contentClass)
{
this(url, fileName, contentDisposition);
super.addHeader(new Header("Content-Class", contentClass));
Expand Down
Expand Up @@ -25,8 +25,8 @@
import javax.mail.Session;

import org.jboss.seam.mail.api.MailMessage;
import org.jboss.seam.mail.core.EmailAttachmentFromClassPath;
import org.jboss.seam.mail.core.EmailAttachmentFromURL;
import org.jboss.seam.mail.core.ClassPathEmailAttachment;
import org.jboss.seam.mail.core.URLEmailAttachment;
import org.jboss.seam.mail.core.enumurations.ContentDisposition;
import org.jboss.seam.mail.core.enumurations.MessagePriority;
import org.jboss.seam.mail.templating.VelocityMailMessage;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void sendHTML() throws MalformedURLException
.bodyHtml(new VelocityClassPathTemplate("template.html.vm"))
.put("version", "Seam 3")
.importance(MessagePriority.HIGH)
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send(session.get());
}

Expand All @@ -88,8 +88,8 @@ public void sendHTMLwithAlternative() throws MalformedURLException
.importance(MessagePriority.LOW)
.deliveryReceipt("seam@jboss.org")
.readReceipt("seam@jboss.org")
.addAttachment(new EmailAttachmentFromClassPath("template.html.vm", "text/html", ContentDisposition.ATTACHMENT))
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new ClassPathEmailAttachment("template.html.vm", "text/html", ContentDisposition.ATTACHMENT))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send(session.get());
}
}
Expand Up @@ -31,14 +31,14 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.mail.api.MailMessage;
import org.jboss.seam.mail.core.EmailAttachmentFromClassPath;
import org.jboss.seam.mail.core.EmailAttachmentFromURL;
import org.jboss.seam.mail.core.ClassPathEmailAttachment;
import org.jboss.seam.mail.core.EmailMessage;
import org.jboss.seam.mail.core.InvalidAddressException;
import org.jboss.seam.mail.core.MailConfig;
import org.jboss.seam.mail.core.MailTestUtil;
import org.jboss.seam.mail.core.MailUtility;
import org.jboss.seam.mail.core.SendFailedException;
import org.jboss.seam.mail.core.URLEmailAttachment;
import org.jboss.seam.mail.core.enumurations.ContentDisposition;
import org.jboss.seam.mail.core.enumurations.MessagePriority;
import org.jboss.seam.mail.example.Person;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void testHTMLMailMessage() throws MalformedURLException, MessagingExcepti
.subject(subject)
.htmlBody("<html><body>Hello World!</body></html>")
.importance(MessagePriority.HIGH)
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send(session.get());
}
finally
Expand Down Expand Up @@ -222,8 +222,8 @@ public void testHTMLTextAltMailMessage() throws MalformedURLException, Messaging
.importance(MessagePriority.LOW)
.deliveryReceipt(fromAddress)
.readReceipt("seam.test")
.addAttachment(new EmailAttachmentFromClassPath("template.text.vm", "text/plain", ContentDisposition.ATTACHMENT))
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new ClassPathEmailAttachment("template.text.vm", "text/plain", ContentDisposition.ATTACHMENT))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send(session.get());
}
finally
Expand Down
Expand Up @@ -30,11 +30,11 @@

import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.mail.core.EmailAttachmentFromClassPath;
import org.jboss.seam.mail.core.EmailAttachmentFromURL;
import org.jboss.seam.mail.core.ClassPathEmailAttachment;
import org.jboss.seam.mail.core.MailConfig;
import org.jboss.seam.mail.core.MailTestUtil;
import org.jboss.seam.mail.core.SendFailedException;
import org.jboss.seam.mail.core.URLEmailAttachment;
import org.jboss.seam.mail.core.enumurations.ContentDisposition;
import org.jboss.seam.mail.core.enumurations.MessagePriority;
import org.jboss.seam.mail.example.Gmail;
Expand Down Expand Up @@ -174,7 +174,7 @@ public void testVelocityHTMLMailMessage() throws MalformedURLException, Messagin
.bodyHtml(new VelocityClassPathTemplate("template.html.vm"))
.put("version", "Seam 3")
.importance(MessagePriority.HIGH)
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send(session.get());
}
finally
Expand Down Expand Up @@ -223,8 +223,8 @@ public void testVelocityHTMLTextAltMailMessage() throws MessagingException, Malf
.importance(MessagePriority.LOW)
.deliveryReceipt(fromAddress)
.readReceipt("seam.test")
.addAttachment(new EmailAttachmentFromClassPath("template.html.vm", "text/html", ContentDisposition.ATTACHMENT))
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new ClassPathEmailAttachment("template.html.vm", "text/html", ContentDisposition.ATTACHMENT))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send();
}
finally
Expand Down Expand Up @@ -274,8 +274,8 @@ public void testSMTPSessionAuthentication() throws MessagingException, Malformed
.importance(MessagePriority.LOW)
.deliveryReceipt(fromAddress)
.readReceipt("seam.test")
.addAttachment(new EmailAttachmentFromClassPath("template.html.vm", "text/html", ContentDisposition.ATTACHMENT))
.addAttachment(new EmailAttachmentFromURL("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.addAttachment(new ClassPathEmailAttachment("template.html.vm", "text/html", ContentDisposition.ATTACHMENT))
.addAttachment(new URLEmailAttachment("http://www.seamframework.org/themes/sfwkorg/img/seam_icon_large.png", "seamLogo.png", ContentDisposition.INLINE))
.send(gmailSession);
}
finally
Expand Down

0 comments on commit 405f1fb

Please sign in to comment.