Subversion Repositories SmartDukaan

Rev

Rev 37473 | Rev 37483 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37473 Rev 37478
Line 1... Line 1...
1
package com.spice.profitmandi.service.mail;
1
package com.spice.profitmandi.service.mail;
2
 
2
 
-
 
3
import com.spice.profitmandi.common.mail.MailQueue;
-
 
4
import com.spice.profitmandi.common.mail.MailRequest;
-
 
5
import com.spice.profitmandi.common.mail.MailSenderType;
3
import com.spice.profitmandi.common.util.Utils;
6
import com.spice.profitmandi.common.util.Utils;
4
import com.spice.profitmandi.dao.entity.mail.MailOutbox;
7
import com.spice.profitmandi.dao.entity.mail.MailOutbox;
5
import com.spice.profitmandi.dao.entity.mail.MailOutboxAttachment;
8
import com.spice.profitmandi.dao.entity.mail.MailOutboxAttachment;
6
import com.spice.profitmandi.dao.repository.mail.MailOutboxRepository;
9
import com.spice.profitmandi.dao.repository.mail.MailOutboxRepository;
7
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.LogManager;
Line 27... Line 30...
27
import java.time.LocalDateTime;
30
import java.time.LocalDateTime;
28
import java.util.ArrayList;
31
import java.util.ArrayList;
29
import java.util.List;
32
import java.util.List;
30
 
33
 
31
@Service
34
@Service
32
public class MailOutboxService {
35
public class MailOutboxService implements MailQueue {
33
 
36
 
34
    private static final Logger LOGGER = LogManager.getLogger(MailOutboxService.class);
37
    private static final Logger LOGGER = LogManager.getLogger(MailOutboxService.class);
35
 
38
 
36
    /**
39
    /**
37
     * The two ways this system can send mail. There is no third.
40
     * The two ways this system can send mail. There is no third.
Line 151... Line 154...
151
 
154
 
152
    public void queueMailWithAttachmentsViaRelay(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, Utils.Attachment... attachments) {
155
    public void queueMailWithAttachmentsViaRelay(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, Utils.Attachment... attachments) {
153
        queueMailWithAttachments(emailTo, cc, bcc, subject, body, html, source, SENDER_RELAY, attachments);
156
        queueMailWithAttachments(emailTo, cc, bcc, subject, body, html, source, SENDER_RELAY, attachments);
154
    }
157
    }
155
 
158
 
-
 
159
    // ---- The single entry point ----
-
 
160
 
-
 
161
    /**
-
 
162
     * Every other queueing method on this class is a delegate to this one. They
-
 
163
     * are kept because ~112 call sites use them; new code should use this.
-
 
164
     */
-
 
165
    @Override
-
 
166
    public void queue(MailRequest request) {
-
 
167
        String senderType = request.getSender() == MailSenderType.GOOGLE ? SENDER_GOOGLE : SENDER_RELAY;
-
 
168
        if (request.hasAttachments()) {
-
 
169
            queueMailWithAttachments(request.getTo(), request.getCc(), request.getBcc(),
-
 
170
                    request.getSubject(), request.getBody(), request.isHtml(),
-
 
171
                    request.getSource(), senderType, request.getAttachments());
-
 
172
        } else {
-
 
173
            queueMail(request.getTo(), request.getCc(), request.getBcc(),
-
 
174
                    request.getSubject(), request.getBody(), request.isHtml(),
-
 
175
                    request.getSource(), senderType, (AttachmentData[]) null);
-
 
176
        }
-
 
177
    }
-
 
178
 
156
    // ---- Internal methods ----
179
    // ---- Internal methods ----
157
 
180
 
158
    private void queueMailWithAttachments(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, String senderType, Utils.Attachment... attachments) {
181
    private void queueMailWithAttachments(String[] emailTo, String[] cc, String[] bcc, String subject, String body, boolean html, String source, String senderType, Utils.Attachment... attachments) {
159
        AttachmentData[] attachmentDataArray = null;
182
        AttachmentData[] attachmentDataArray = null;
160
        if (attachments != null && attachments.length > 0) {
183
        if (attachments != null && attachments.length > 0) {