Skip to content

Commit 5039f1b

Browse files
authored
Upgrade to Angus Mail 2.0.3 (#6068)
1 parent 9cdee5b commit 5039f1b

9 files changed

Lines changed: 68 additions & 51 deletions

File tree

announcements/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
dependencies {
6-
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
6+
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
77
}
88

99
// TODO move resources files into resources directory to avoid this overlap

api/build.gradle

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ List runtime = [
5252
configurations {
5353
// Exclude the bundled org.json library from com.fasterxml.jackson.datatype:jackson-datatype-json-org dependency
5454
all*.exclude group: "org.apache.geronimo.bundles", module: "json"
55-
// Avoid pulling in the Activation API because we don't want to conflict with one loaded from $CATALINA_HOME/lib
56-
all*.exclude group: "jakarta.activation", module: "jakarta.activation-api"
5755

5856
// this configuration and its artifact are declared because the default outgoing variant for the api
5957
// module (runtimeElements) does not include all the class files since the classes compiled from
@@ -98,11 +96,25 @@ dependencies {
9896
runtimeOnly runtime
9997

10098
BuildUtils.addTomcatBuildDependencies(project, "implementation")
101-
// the following two libraries are required for compilation but we don't want extra ones in the classpath, so we exclude
102-
// them from external dependencies in favor of the versions in the tomcat directory (FIXME seems somewhat sketchy...)
99+
100+
// needed for compilation but Tomcat provides the implementation
103101
api "jakarta.servlet:jakarta.servlet-api:${servletApiVersion}"
104-
api "com.sun.mail:jakarta.mail:${javaMailVersion}"
105102

103+
// Angus Mail is an implementation of the Jakarta Mail API, which it pulls in as a dependency
104+
BuildUtils.addExternalDependency(
105+
project,
106+
new ExternalDependency(
107+
"org.eclipse.angus:angus-mail:${angusMailVersion}",
108+
"Angus Mail",
109+
"Eclipse Foundation",
110+
"https://eclipse-ee4j.github.io/angus-mail/",
111+
"Eclipse Public License 2.0",
112+
"https://projects.eclipse.org/license/epl-2.0",
113+
"Implementation of the Jakarta Mail API",
114+
)
115+
)
116+
117+
// Angus Activation is an implementation of the Jakarta Activation API, which it pulls in as a dependency
106118
BuildUtils.addExternalDependency(
107119
project,
108120
new ExternalDependency(
@@ -281,7 +293,7 @@ dependencies {
281293
"https://commons.apache.org/proper/commons-text/",
282294
ExternalDependency.APACHE_2_LICENSE_NAME,
283295
ExternalDependency.APACHE_2_LICENSE_URL,
284-
"String algorithms",
296+
"String algorithms"
285297
)
286298
)
287299

@@ -294,21 +306,21 @@ dependencies {
294306
"http://jakarta.apache.org/commons/validator/",
295307
ExternalDependency.APACHE_2_LICENSE_NAME,
296308
ExternalDependency.APACHE_2_LICENSE_URL,
297-
"Data validation and error messages",
309+
"Data validation and error messages"
298310
)
299311
)
300312

301313
BuildUtils.addExternalDependency(
302-
project,
303-
new ExternalDependency(
304-
"org.apache.commons:commons-vfs2:${commonsVfs2Version}",
305-
"Commons Virtual File System",
306-
"Apache",
307-
"https://commons.apache.org/proper/commons-vfs/",
308-
ExternalDependency.APACHE_2_LICENSE_NAME,
309-
ExternalDependency.APACHE_2_LICENSE_URL,
310-
"Consistent API for accessing files of different types",
311-
)
314+
project,
315+
new ExternalDependency(
316+
"org.apache.commons:commons-vfs2:${commonsVfs2Version}",
317+
"Commons Virtual File System",
318+
"Apache",
319+
"https://commons.apache.org/proper/commons-vfs/",
320+
ExternalDependency.APACHE_2_LICENSE_NAME,
321+
ExternalDependency.APACHE_2_LICENSE_URL,
322+
"Consistent API for accessing files of different types"
323+
)
312324
)
313325

314326

@@ -322,7 +334,7 @@ dependencies {
322334
"http://code.google.com/p/flying-saucer/",
323335
ExternalDependency.LGPL_LICENSE_NAME,
324336
ExternalDependency.LGPL_LICENSE_URL,
325-
"XHTML/CSS rendering library",
337+
"XHTML/CSS rendering library"
326338
)
327339
)
328340

api/src/org/labkey/api/admin/notification/NotificationService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.labkey.api.admin.notification;
1717

18+
import jakarta.mail.MessagingException;
1819
import org.jetbrains.annotations.NotNull;
1920
import org.jetbrains.annotations.Nullable;
2021
import org.labkey.api.data.Container;
@@ -25,15 +26,11 @@
2526
import org.labkey.api.util.MailHelper;
2627
import org.labkey.api.view.ActionURL;
2728

28-
import jakarta.mail.MessagingException;
29-
import jakarta.servlet.http.HttpSession;
3029
import java.io.IOException;
3130
import java.util.List;
3231

3332
/**
3433
* Service for adding/getting/removing user notifications attached to specific objects.
35-
* User: cnathe
36-
* Date: 9/14/2015
3734
*/
3835
public interface NotificationService
3936
{

api/src/org/labkey/api/util/MailHelper.java

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import jakarta.mail.internet.MimeBodyPart;
3232
import jakarta.mail.internet.MimeMessage;
3333
import jakarta.mail.internet.MimeMultipart;
34+
import jakarta.servlet.ServletContext;
3435
import org.apache.commons.lang3.StringUtils;
3536
import org.apache.logging.log4j.Level;
3637
import org.apache.logging.log4j.LogManager;
@@ -48,16 +49,16 @@
4849
import org.labkey.api.settings.StartupPropertyEntry;
4950
import org.labkey.api.util.emailTemplate.EmailTemplate;
5051

51-
import javax.naming.Context;
52-
import javax.naming.InitialContext;
5352
import java.io.IOException;
5453
import java.io.Writer;
5554
import java.util.ArrayList;
5655
import java.util.Collection;
5756
import java.util.Collections;
57+
import java.util.Enumeration;
5858
import java.util.HashMap;
5959
import java.util.List;
6060
import java.util.Map;
61+
import java.util.Objects;
6162
import java.util.Properties;
6263
import java.util.StringTokenizer;
6364

@@ -114,30 +115,37 @@ public void handle(Collection<StartupPropertyEntry> entries)
114115
entries.forEach(entry -> properties.put("mail.smtp." + entry.getName(), entry.getValue()));
115116
}
116117
});
117-
if (!properties.isEmpty())
118-
{
119-
session = Session.getInstance(properties);
120-
}
121-
else
118+
119+
/* now check if specified in tomcat config instead */
120+
if (properties.isEmpty())
122121
{
123-
/* check if specified in tomcat config */
124-
InitialContext ctx = new InitialContext();
125-
Context envCtx = (Context) ctx.lookup("java:comp/env");
126-
session = (Session) envCtx.lookup("mail/Session");
122+
ServletContext context = ModuleLoader.getServletContext();
123+
Enumeration<String> names = Objects.requireNonNull(context).getInitParameterNames();
124+
while (names.hasMoreElements())
125+
{
126+
String name = names.nextElement();
127+
if (name.startsWith("mail.smtp."))
128+
properties.put(name, context.getInitParameter(name));
129+
}
127130
}
128131

129-
if ("true".equalsIgnoreCase(session.getProperty("mail.smtp.ssl.enable")) ||
130-
"true".equalsIgnoreCase(session.getProperty("mail.smtp.starttls.enable")))
132+
if (!properties.isEmpty())
131133
{
132-
String username = session.getProperty("mail.smtp.user");
133-
String password = session.getProperty("mail.smtp.password");
134-
session = Session.getInstance(session.getProperties(), new Authenticator() {
135-
@Override
136-
protected PasswordAuthentication getPasswordAuthentication()
137-
{
138-
return new PasswordAuthentication(username, password);
139-
}
140-
});
134+
session = Session.getInstance(properties);
135+
136+
if ("true".equalsIgnoreCase(session.getProperty("mail.smtp.ssl.enable")) ||
137+
"true".equalsIgnoreCase(session.getProperty("mail.smtp.starttls.enable")))
138+
{
139+
String username = session.getProperty("mail.smtp.user");
140+
String password = session.getProperty("mail.smtp.password");
141+
session = Session.getInstance(session.getProperties(), new Authenticator() {
142+
@Override
143+
protected PasswordAuthentication getPasswordAuthentication()
144+
{
145+
return new PasswordAuthentication(username, password);
146+
}
147+
});
148+
}
141149
}
142150
}
143151
catch (Exception e)

core/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ project.tasks.register("serverSideJS", ServerSideJS) {
1515
project.tasks.named('processModuleResources').configure { dependsOn(project.tasks.serverSideJS) }
1616

1717
dependencies {
18-
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
19-
jspImplementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
18+
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
19+
jspImplementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
2020

2121
BuildUtils.addExternalDependency(
2222
project,

issues/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
dependencies {
8-
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
8+
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
99
BuildUtils.addLabKeyDependency(project: project, config: "modules", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "experiment"), depProjectConfig: "published", depExtension: "module")
1010
BuildUtils.addLabKeyDependency(project: project, config: "modules", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "search"), depProjectConfig: "published", depExtension: "module")
1111
}

pipeline/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
dependencies {
9-
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
9+
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
1010
BuildUtils.addExternalDependency(
1111
project,
1212
new ExternalDependency(

query/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ configurations {
1212
dependencies {
1313
antlr "org.antlr:antlr:${antlrVersion}"
1414
jspImplementation "org.olap4j:olap4j:${olap4jVersion}"
15-
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
15+
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
1616
// we add this bridge jar because certain Mondrian classes require the log4j interface
1717
BuildUtils.addExternalDependency(
1818
project,

study/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ sourceSets {
1414
}
1515

1616
dependencies {
17-
implementation "com.sun.mail:jakarta.mail:${javaMailVersion}"
17+
implementation "org.eclipse.angus:angus-mail:${angusMailVersion}"
1818
BuildUtils.addLabKeyDependency(project: project, config: "implementation", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "assay"), depProjectConfig: "apiJarFile")
1919
BuildUtils.addLabKeyDependency(project: project, config: "jspImplementation", depProjectPath: BuildUtils.getPlatformModuleProjectPath(project.gradle, "assay"), depProjectConfig: "apiJarFile")
2020

0 commit comments

Comments
 (0)