From 4d46d5273386270c738f910036f9b0c500d9dfa6 Mon Sep 17 00:00:00 2001 From: oreva Date: Sun, 6 Nov 2016 10:23:19 +0200 Subject: [PATCH] Patch 0001-Code-cleanup.patch applied. --- .../baeldung/spring/app/config/AppConfig.java | 10 ----- .../spring/mail/EmailServiceImpl.java | 3 +- .../java/com/baeldung/spring/mail/Order.java | 43 ------------------- .../baeldung/spring/mail/OrderManager.java | 31 ------------- 4 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 spring-mvc-email/src/main/java/com/baeldung/spring/mail/Order.java delete mode 100644 spring-mvc-email/src/main/java/com/baeldung/spring/mail/OrderManager.java diff --git a/spring-mvc-email/src/main/java/com/baeldung/spring/app/config/AppConfig.java b/spring-mvc-email/src/main/java/com/baeldung/spring/app/config/AppConfig.java index 9f8339c2fe..9078d44764 100644 --- a/spring-mvc-email/src/main/java/com/baeldung/spring/app/config/AppConfig.java +++ b/spring-mvc-email/src/main/java/com/baeldung/spring/app/config/AppConfig.java @@ -45,16 +45,6 @@ public class AppConfig extends WebMvcConfigurerAdapter { return resolver; } - @Bean - public SimpleMailMessage templateOrderMessage() { - SimpleMailMessage message = new SimpleMailMessage(); - message.setText("Dear %s %s, \nthank you for placing order.\n" + - "\n" + - "Sincerely yours,\n" + - "Yourcompany."); - return message; - } - @Bean public SimpleMailMessage templateSimpleMessage() { SimpleMailMessage message = new SimpleMailMessage(); diff --git a/spring-mvc-email/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java b/spring-mvc-email/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java index dab5400d25..ca418a7d90 100644 --- a/spring-mvc-email/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java +++ b/spring-mvc-email/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java @@ -24,7 +24,6 @@ public class EmailServiceImpl implements EmailService { public void sendSimpleMessage(String to, String subject, String text) { try { SimpleMailMessage message = new SimpleMailMessage(); - message.setTo(to); message.setSubject(subject); message.setText(text); @@ -40,7 +39,7 @@ public class EmailServiceImpl implements EmailService { String subject, SimpleMailMessage template, String ...templateArgs) { - String text = String.format(template.getText(), templateArgs); + String text = String.format(template.getText(), templateArgs); sendSimpleMessage(to, subject, text); } diff --git a/spring-mvc-email/src/main/java/com/baeldung/spring/mail/Order.java b/spring-mvc-email/src/main/java/com/baeldung/spring/mail/Order.java deleted file mode 100644 index cd1448b84b..0000000000 --- a/spring-mvc-email/src/main/java/com/baeldung/spring/mail/Order.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.spring.mail; - -/** - * Created by Olga on 8/22/2016. - */ -public class Order { - - public Order(String customerEmail, - String customerFirstName, - String customerLastName) { - this.customerEmail = customerEmail; - this.customerFirstName = customerFirstName; - this.customerLastName = customerLastName; - } - - private String customerEmail; - private String customerFirstName; - private String customerLastName; - - public String getCustomerEmail() { - return customerEmail; - } - - public void setCustomerEmail(String customerEmail) { - this.customerEmail = customerEmail; - } - - public String getCustomerFirstName() { - return customerFirstName; - } - - public void setCustomerFirstName(String customerFirstName) { - this.customerFirstName = customerFirstName; - } - - public String getCustomerLastName() { - return customerLastName; - } - - public void setCustomerLastName(String customerLastName) { - this.customerLastName = customerLastName; - } -} diff --git a/spring-mvc-email/src/main/java/com/baeldung/spring/mail/OrderManager.java b/spring-mvc-email/src/main/java/com/baeldung/spring/mail/OrderManager.java deleted file mode 100644 index 5dfe25f20f..0000000000 --- a/spring-mvc-email/src/main/java/com/baeldung/spring/mail/OrderManager.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.spring.mail; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.stereotype.Component; - -/** - * Created by Olga on 8/22/2016. - */ -@Component -public class OrderManager { - @Autowired - public EmailService emailService; - - @Value("${attachment.invoice}") - private String invoiceAttachmentPath; - - @Autowired() - @Qualifier("templateOrderMessage") - public SimpleMailMessage template; - - public void placeOrder(Order order) { - emailService.sendSimpleMessageUsingTemplate(order.getCustomerEmail(), - "Order Confirmation", - template, - order.getCustomerFirstName(), - order.getCustomerLastName()); - } -}