I’m stuck to make some changes on this coding, to ensure no emails sent via bpaNotificationService
if email in orderContacts
object is null, so it doesn’t throw error logs? And also to include an info logger to say that “not sending email because no email is given”.
This is only if it’s email notification only, which is checking whether email notification key is not null.
@EEAction(value = "customer.sendNotification")
public class SendNotificationAction extends EEWorkflowAction {
private final NotificationService novusNotificationService;
private final sg.com.bpa.executionengine.notification.service.NotificationService bpaNotificationService;
public SendNotificationAction(NotificationService novusNotificationService, sg.com.bpa.executionengine.notification.service.NotificationService bpaNotificationService) {
this.novusNotificationService = novusNotificationService;
this.bpaNotificationService = bpaNotificationService;
}
@Override
public EEActionResponse executeEEAction(EEActionRequest actionRequest, CustomerOrder customerOrder) {
log.info("Sending Notification for {} with notification type: {}",
OrderAttributeKey.BILLING_ACCOUNT_ID.getValue(customerOrder), actionRequest.getProcessVariable(ProcessVariable.NOTIFICATION_TYPE));
if (MailTemplate.doesNotificationExist(actionRequest.getProcessVariable(ProcessVariable.NOTIFICATION_TYPE)) ||
SmsTemplate.doesNotificationExist(actionRequest.getProcessVariable(ProcessVariable.NOTIFICATION_TYPE))) {
bpaNotificationService.sendNotification(actionRequest, customerOrder);
} else {
novusNotificationService.sendNotification(actionRequest, customerOrder);
}
return createResponse();
}
}