Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DS-1364 checker-emailer ignores advanced mail configuration

  • Loading branch information...
commit 3aa695cadccecfc85faf5ccf9617de7ccfe86791 1 parent b10be85
Ariel J. Lira authored helix84 committed
View
53 dspace-api/src/main/java/org/dspace/checker/DailyReportEmailer.java
@@ -36,6 +36,7 @@
import org.apache.commons.cli.PosixParser;
import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
+import org.dspace.core.Email;
/**
* <p>
@@ -75,48 +76,16 @@ public DailyReportEmailer()
* @throws javax.mail.MessagingException
* if message cannot be sent.
*/
- public void sendReport(File attachment, int numberOfBitstreams)
- throws IOException, javax.mail.MessagingException
- {
- // Get the mail configuration properties
- String server = ConfigurationManager.getProperty("mail.server");
-
- // Set up properties for mail session
- Properties props = System.getProperties();
- props.put("mail.smtp.host", server);
-
- // Get session
- Session session = Session.getInstance(props, null);
-
- MimeMessage msg = new MimeMessage(session);
- Multipart multipart = new MimeMultipart();
-
- // create the first part of the email
- BodyPart messageBodyPart = new MimeBodyPart();
- messageBodyPart
- .setText("This is the checksum checker report, see attachment for details \n"
- + numberOfBitstreams
- + " Bitstreams found with POSSIBLE issues");
- multipart.addBodyPart(messageBodyPart);
-
- // add the file
- messageBodyPart = new MimeBodyPart();
-
- DataSource source = new FileDataSource(attachment);
- messageBodyPart.setDataHandler(new DataHandler(source));
- messageBodyPart.setFileName("checksum_checker_report.txt");
- multipart.addBodyPart(messageBodyPart);
- msg.setContent(multipart);
- msg.setFrom(new InternetAddress(ConfigurationManager
- .getProperty("mail.from.address")));
- msg.addRecipient(Message.RecipientType.TO, new InternetAddress(
- ConfigurationManager.getProperty("mail.admin")));
-
- msg.setSentDate(new Date());
- msg.setSubject("Checksum checker Report - " + numberOfBitstreams
- + " Bitstreams found with POSSIBLE issues");
- Transport.send(msg);
- }
+ public void sendReport(File attachment, int numberOfBitstreams)
+ throws IOException, javax.mail.MessagingException
+ {
+ Email email = new Email();
+ email.setSubject("Checksum checker Report - " + numberOfBitstreams + " Bitstreams found with POSSIBLE issues");
+ email.setContent("report is attached ...");
+ email.addAttachment(attachment, "checksum_checker_report.txt");
+ email.addRecipient(ConfigurationManager.getProperty("mail.admin"));
+ email.send();
+ }
/**
* Allows users to have email sent to them. The default is to send all
View
6 dspace-api/src/main/java/org/dspace/core/Email.java
@@ -130,7 +130,7 @@
/**
* Create a new email message.
*/
- Email()
+ public Email()
{
arguments = new ArrayList<Object>(50);
recipients = new ArrayList<String>(50);
@@ -160,7 +160,7 @@ public void addRecipient(String email)
* @param cnt
* the content of the message
*/
- void setContent(String cnt)
+ public void setContent(String cnt)
{
content = cnt;
arguments = new ArrayList<Object>();
@@ -172,7 +172,7 @@ void setContent(String cnt)
* @param s
* the subject of the message
*/
- void setSubject(String s)
+ public void setSubject(String s)
{
subject = s;
}
Please sign in to comment.
Something went wrong with that request. Please try again.