Skip to content
Snippets Groups Projects
Commit 872bdc66 authored by cramakri's avatar cramakri
Browse files

LMS-1449 Added send email with attachment method to IMailClient.

SVN: 15162
parent b746b792
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package ch.systemsx.cisd.common.mail; package ch.systemsx.cisd.common.mail;
import javax.activation.DataHandler;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
/** /**
...@@ -38,4 +40,17 @@ public interface IMailClient ...@@ -38,4 +40,17 @@ public interface IMailClient
public void sendMessage(String subject, String content, String replyToOrNull, From fromOrNull, public void sendMessage(String subject, String content, String replyToOrNull, From fromOrNull,
String... recipients) throws EnvironmentFailureException; String... recipients) throws EnvironmentFailureException;
/**
* Sends a mail with given <var>subject</var> and <var>content</var> to given
* <var>recipients</var>, includig the given <var>attachment</var>
*
* @param replyToOrNull reply-to part of the email header. Can be <code>null</code>.
* @param fromOrNull from part of the email header. Can be <code>null</code>. If specified -
* will overwrite the 'from' value specified for the client.
* @param recipients list of recipients (of type <code>Message.RecipientType.TO</code>)
*/
public void sendMessageWithAttachment(final String subject, final String content,
final String filename, final DataHandler attachmentContent, final String replyToOrNull,
final From fromOrNull, final String... recipients) throws EnvironmentFailureException;
} }
\ No newline at end of file
...@@ -21,7 +21,6 @@ import java.util.Properties; ...@@ -21,7 +21,6 @@ import java.util.Properties;
import ch.systemsx.cisd.cina.dss.info.EntityRegistrationSuccessEmail; import ch.systemsx.cisd.cina.dss.info.EntityRegistrationSuccessEmail;
import ch.systemsx.cisd.common.mail.IMailClient; import ch.systemsx.cisd.common.mail.IMailClient;
import ch.systemsx.cisd.common.mail.MailClient;
import ch.systemsx.cisd.etlserver.AbstractDelegatingStorageProcessor; import ch.systemsx.cisd.etlserver.AbstractDelegatingStorageProcessor;
import ch.systemsx.cisd.etlserver.IStorageProcessor; import ch.systemsx.cisd.etlserver.IStorageProcessor;
import ch.systemsx.cisd.etlserver.ITypeExtractor; import ch.systemsx.cisd.etlserver.ITypeExtractor;
...@@ -75,21 +74,9 @@ public class StorageProcessor extends AbstractDelegatingStorageProcessor ...@@ -75,21 +74,9 @@ public class StorageProcessor extends AbstractDelegatingStorageProcessor
emailAddress = defaultEmailAddress; emailAddress = defaultEmailAddress;
} }
// WORKAROUND: The IMailClient interface is used in many places. I added the mailClient.sendMessageWithAttachment(successEmail.getSubject(), successEmail
// sendMessageWithAttachment method to the MailClient class, but I don't want to make a .getContentMimeText(), successEmail.getContentMimeAttachmentFileName(),
// large, global change to introduce the method into the interface, so I do an instanceof successEmail.getContentMimeAttachmentContent(), null, null, emailAddress);
// test here.
if (mailClient instanceof MailClient)
{
((MailClient) mailClient).sendMessageWithAttachment(successEmail.getSubject(),
successEmail.getContentMimeText(), successEmail
.getContentMimeAttachmentFileName(), successEmail
.getContentMimeAttachmentContent(), null, null, emailAddress);
} else
{
mailClient.sendMessage(successEmail.getSubject(), successEmail.getContentTextOnly(),
null, null, emailAddress);
}
return answer; return answer;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment