feature[TW19999]: Migrate ATS off osee.mail service
Change-Id: Ic6ac7a15ba521dec6fd72431d64641e1edb38e03
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/AbstractAtsNotificationService.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/AbstractAtsNotificationService.java
index 0a1c430..c178dfe 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/AbstractAtsNotificationService.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/AbstractAtsNotificationService.java
@@ -36,7 +36,7 @@
/**
* @author Donald G. Dunne
*/
-public abstract class AbstractAtsNotificationService implements IAtsNotificationService {
+public abstract class AbstractAtsNotificationService implements IAtsNotificationService, OseeEmailCreator {
private volatile boolean emailEnabled = true;
protected AtsApi atsApi;
@@ -134,8 +134,8 @@
@Override
public void sendNotifications(String fromUserEmail, String testingUserEmail, String subject, String body, Collection<? extends AtsNotificationEvent> notificationEvents) {
- SendNotificationEvents job = new SendNotificationEvents(createOseeEmail(), atsApi, fromUserEmail,
- testingUserEmail, subject, body, notificationEvents, atsApi.getUserService());
+ SendNotificationEvents job = new SendNotificationEvents(this, atsApi, fromUserEmail, testingUserEmail, subject,
+ body, notificationEvents, atsApi.getUserService());
job.run();
}
@@ -163,7 +163,8 @@
}
}
- protected abstract OseeEmail createOseeEmail();
+ @Override
+ public abstract OseeEmail createOseeEmail();
private String getFromUserEmail(AtsNotificationCollector notifications) {
String email = atsApi.getConfigValue("NoReplyEmail");
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/OseeEmailCreator.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/OseeEmailCreator.java
new file mode 100644
index 0000000..3911d27
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/OseeEmailCreator.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2022 Boeing.
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.core.notify;
+
+import org.eclipse.osee.framework.core.util.OseeEmail;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface OseeEmailCreator {
+
+ public OseeEmail createOseeEmail();
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/SendNotificationEvents.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/SendNotificationEvents.java
index 2b25d93..1a54024 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/SendNotificationEvents.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/notify/SendNotificationEvents.java
@@ -40,12 +40,12 @@
private final String body;
private final String fromUserEmail;
private final String testingUserEmail;
- private final OseeEmail oseeEmail;
+ private final OseeEmailCreator oseeEmailCreator;
private final AtsApi atsApi;
private final IAtsUserService userService;
- public SendNotificationEvents(OseeEmail oseeEmail, AtsApi atsApi, String fromUserEmail, String testingUserEmail, String subject, String body, Collection<? extends AtsNotificationEvent> notificationEvents, IAtsUserService userService) {
- this.oseeEmail = oseeEmail;
+ public SendNotificationEvents(OseeEmailCreator oseeEmailCreator, AtsApi atsApi, String fromUserEmail, String testingUserEmail, String subject, String body, Collection<? extends AtsNotificationEvent> notificationEvents, IAtsUserService userService) {
+ this.oseeEmailCreator = oseeEmailCreator;
this.atsApi = atsApi;
this.userService = atsApi.getUserService();
this.fromUserEmail = fromUserEmail;
@@ -187,6 +187,7 @@
System.out.println(String.format("useFromEmail [%s]", useFromEmail));
try {
+ OseeEmail oseeEmail = oseeEmailCreator.createOseeEmail();
oseeEmail.setFrom(useFromEmail);
oseeEmail.setSubject(getNotificationEmailSubject(notificationEvents));
oseeEmail.setHTMLBody(html);
diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/notify/AtsNotificationServiceImpl.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/notify/AtsNotificationServiceImpl.java
index 68224c3..5d1b9cd 100644
--- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/notify/AtsNotificationServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/notify/AtsNotificationServiceImpl.java
@@ -27,7 +27,7 @@
}
@Override
- protected OseeEmail createOseeEmail() {
+ public OseeEmail createOseeEmail() {
return OseeEmailIde.create();
}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/notify/AtsNotificationServiceImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/notify/AtsNotificationServiceImpl.java
index 3c14d3a..8dfda5a 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/notify/AtsNotificationServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/notify/AtsNotificationServiceImpl.java
@@ -27,7 +27,7 @@
}
@Override
- protected OseeEmail createOseeEmail() {
+ public OseeEmail createOseeEmail() {
return OseeEmailServer.create();
}