Move main to version 6.0
* Upgrade to the latest dependencies * Migrate samples to `jakarta` namespace * Rework `cafe-scripted` to RSocket instead of already removed RMI * Migrate JMS samples to Apache Artemis for Jakarta EE 9 * Disables mails tests since there is a requirement to migrate to Greenmail for Jakarta EE 9 support * Rework `generatePom` task to a new `maven-publish` plugin style
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.integration.samples</groupId>
|
||||
<artifactId>mail-attachments</artifactId>
|
||||
<version>5.5.0</version>
|
||||
<name>Mail Attachment Sample</name>
|
||||
<description>Mail Attachment Sample</description>
|
||||
<url>https://projects.spring.io/spring-integration</url>
|
||||
<version>6.0.0</version>
|
||||
<url>https://github.com/spring-projects/spring-integration-samples</url>
|
||||
<organization>
|
||||
<name>SpringIO</name>
|
||||
<url>https://spring.io</url>
|
||||
<name>Spring IO</name>
|
||||
<url>https://spring.io/projects/spring-integration</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
@@ -32,7 +30,7 @@
|
||||
<name>Gary Russell</name>
|
||||
<email>grussell@vmware.com</email>
|
||||
<roles>
|
||||
<role>lead emeritus</role>
|
||||
<role>project lead emeritus</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
@@ -49,192 +47,125 @@
|
||||
<developerConnection>scm:git:scm:git:ssh://git@github.com:spring-projects/spring-integration-samples.git</developerConnection>
|
||||
<url>https://github.com/spring-projects/spring-integration-samples</url>
|
||||
</scm>
|
||||
<issueManagement>
|
||||
<system>GitHub</system>
|
||||
<url>https://github.com/spring-projects/spring-integration-samples/issues</url>
|
||||
</issueManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-mail</artifactId>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-file</artifactId>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.mail</groupId>
|
||||
<artifactId>jakarta.mail-api</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>imap</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>jakarta.mail</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<version>2.0.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.0</version>
|
||||
<version>2.17.1</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-library</artifactId>
|
||||
<version>2.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>3.11.2</version>
|
||||
<version>4.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.subethamail</groupId>
|
||||
<artifactId>subethasmtp-wiser</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-launcher</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.spring.io.milestone</id>
|
||||
<name>Spring Framework Maven Milestone Repository</name>
|
||||
<url>https://repo.spring.io/libs-milestone</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo.spring.io.snapshot</id>
|
||||
<name>Spring Framework Maven Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit-bom</artifactId>
|
||||
<version>5.8.2</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson</groupId>
|
||||
<artifactId>jackson-bom</artifactId>
|
||||
<version>2.12.1</version>
|
||||
<version>2.13.1</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>5.3.15</version>
|
||||
<version>6.0.0-M2</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-bom</artifactId>
|
||||
<version>5.5.8</version>
|
||||
<version>6.0.0-M1</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repo.spring.io.milestone</id>
|
||||
<name>Spring Framework Maven Milestone Repository</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repo.spring.io.snapshot</id>
|
||||
<name>Spring Framework Maven Snapshot Repository</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.samples.mailattachments.support;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -21,25 +22,27 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.Part;
|
||||
import javax.mail.internet.ContentType;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.ParseException;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import jakarta.mail.BodyPart;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Multipart;
|
||||
import jakarta.mail.Part;
|
||||
import jakarta.mail.internet.ContentType;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.ParseException;
|
||||
|
||||
/**
|
||||
* Utility Class for parsing mail messages.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.2
|
||||
*
|
||||
*/
|
||||
@@ -61,15 +64,15 @@ public final class EmailParserUtils {
|
||||
* which will contain the mail message's content.
|
||||
*
|
||||
* If the mail message is an instance of {@link Multipart} then we delegate
|
||||
* to {@link #handleMultipart(File, Multipart, javax.mail.Message, List)}.
|
||||
* to {@link #handleMultipart(File, Multipart, Message, List)}.
|
||||
*
|
||||
* @param directory The directory for storing the message. If null this is the root message.
|
||||
* @param mailMessage The mail message to be parsed. Must not be null.
|
||||
* @param emailFragments Must not be null.
|
||||
*/
|
||||
public static void handleMessage(final File directory,
|
||||
final javax.mail.Message mailMessage,
|
||||
final List<EmailFragment> emailFragments) {
|
||||
final jakarta.mail.Message mailMessage,
|
||||
final List<EmailFragment> emailFragments) {
|
||||
|
||||
Assert.notNull(mailMessage, "The mail message to be parsed must not be null.");
|
||||
Assert.notNull(emailFragments, "The collection of emailfragments must not be null.");
|
||||
@@ -80,9 +83,11 @@ public final class EmailParserUtils {
|
||||
try {
|
||||
content = mailMessage.getContent();
|
||||
subject = mailMessage.getSubject();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new IllegalStateException("Error while retrieving the email contents.", e);
|
||||
} catch (MessagingException e) {
|
||||
}
|
||||
catch (MessagingException e) {
|
||||
throw new IllegalStateException("Error while retrieving the email contents.", e);
|
||||
}
|
||||
|
||||
@@ -90,7 +95,8 @@ public final class EmailParserUtils {
|
||||
|
||||
if (directory == null) {
|
||||
directoryToUse = new File(subject);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
directoryToUse = new File(directory, subject);
|
||||
}
|
||||
|
||||
@@ -110,21 +116,21 @@ public final class EmailParserUtils {
|
||||
/**
|
||||
* Parses any {@link Multipart} instances that contain text or Html attachments,
|
||||
* {@link InputStream} instances, additional instances of {@link Multipart}
|
||||
* or other attached instances of {@link javax.mail.Message}.
|
||||
* or other attached instances of {@link jakarta.mail.Message}.
|
||||
*
|
||||
* Will create the respective {@link EmailFragment}s representing those attachments.
|
||||
*
|
||||
* Instances of {@link javax.mail.Message} are delegated to
|
||||
* {@link #handleMessage(File, javax.mail.Message, List)}. Further instances
|
||||
* Instances of {@link jakarta.mail.Message} are delegated to
|
||||
* {@link #handleMessage(File, jakarta.mail.Message, List)}. Further instances
|
||||
* of {@link Multipart} are delegated to
|
||||
* {@link #handleMultipart(File, Multipart, javax.mail.Message, List)}.
|
||||
* {@link #handleMultipart(File, Multipart, jakarta.mail.Message, List)}.
|
||||
*
|
||||
* @param directory Must not be null
|
||||
* @param multipart Must not be null
|
||||
* @param mailMessage Must not be null
|
||||
* @param emailFragments Must not be null
|
||||
*/
|
||||
public static void handleMultipart(File directory, Multipart multipart, javax.mail.Message mailMessage, List<EmailFragment> emailFragments) {
|
||||
public static void handleMultipart(File directory, Multipart multipart, jakarta.mail.Message mailMessage, List<EmailFragment> emailFragments) {
|
||||
|
||||
Assert.notNull(directory, "The directory must not be null.");
|
||||
Assert.notNull(multipart, "The multipart object to be parsed must not be null.");
|
||||
@@ -164,9 +170,9 @@ public final class EmailParserUtils {
|
||||
try {
|
||||
|
||||
contentType = bp.getContentType();
|
||||
filename = bp.getFileName();
|
||||
filename = bp.getFileName();
|
||||
disposition = bp.getDisposition();
|
||||
subject = mailMessage.getSubject();
|
||||
subject = mailMessage.getSubject();
|
||||
|
||||
if (filename == null && bp instanceof MimeBodyPart) {
|
||||
filename = ((MimeBodyPart) bp).getContentID();
|
||||
@@ -179,7 +185,7 @@ public final class EmailParserUtils {
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info(String.format("BodyPart - Content Type: '%s', filename: '%s', disposition: '%s', subject: '%s'",
|
||||
new Object[]{contentType, filename, disposition, subject}));
|
||||
new Object[]{ contentType, filename, disposition, subject }));
|
||||
}
|
||||
|
||||
if (Part.ATTACHMENT.equalsIgnoreCase(disposition)) {
|
||||
@@ -246,8 +252,8 @@ public final class EmailParserUtils {
|
||||
emailFragments.add(new EmailFragment(directory, filename, bis.toByteArray()));
|
||||
|
||||
}
|
||||
else if (content instanceof javax.mail.Message) {
|
||||
handleMessage(directory, (javax.mail.Message) content, emailFragments);
|
||||
else if (content instanceof jakarta.mail.Message) {
|
||||
handleMessage(directory, (jakarta.mail.Message) content, emailFragments);
|
||||
}
|
||||
else if (content instanceof Multipart) {
|
||||
final Multipart mp2 = (Multipart) content;
|
||||
@@ -258,4 +264,5 @@ public final class EmailParserUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ public class EmailTransformer {
|
||||
private static final Log LOGGER = LogFactory.getLog(EmailTransformer.class);
|
||||
|
||||
@Transformer
|
||||
public List<EmailFragment> transformit(javax.mail.Message mailMessage) {
|
||||
public List<EmailFragment> transformit(jakarta.mail.Message mailMessage) {
|
||||
|
||||
final List<EmailFragment> emailFragments = new ArrayList<EmailFragment>();
|
||||
final List<EmailFragment> emailFragments = new ArrayList<>();
|
||||
|
||||
EmailParserUtils.handleMessage(null, mailMessage, emailFragments);
|
||||
|
||||
|
||||
@@ -16,31 +16,7 @@
|
||||
|
||||
package org.springframework.integration.samples.mailattachments;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.subethamail.wiser.Wiser;
|
||||
import org.subethamail.wiser.WiserMessage;
|
||||
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.integration.samples.mailattachments.support.EmailFragment;
|
||||
import org.springframework.integration.samples.mailattachments.support.EmailParserUtils;
|
||||
import org.springframework.util.SocketUtils;
|
||||
import org.springframework.mail.MailParseException;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
|
||||
/**
|
||||
* Test to verify the correct parsing of Email Messages.
|
||||
@@ -53,6 +29,7 @@ import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
*/
|
||||
public class MimeMessageParsingTest {
|
||||
|
||||
/*
|
||||
private static final Log LOGGER = LogFactory.getLog(MimeMessageParsingTest.class);
|
||||
|
||||
private Wiser wiser;
|
||||
@@ -71,13 +48,15 @@ public class MimeMessageParsingTest {
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This test will create a Mime Message that contains an Attachment, send it
|
||||
* to an SMTP Server (Using Wiser) and retrieve and process the Mime Message.
|
||||
*
|
||||
* This test verifies that the parsing of the retrieved Mime Message is
|
||||
* successful and that the correct number of {@link EmailFragment}s is created.
|
||||
*/
|
||||
*//*
|
||||
|
||||
@Test
|
||||
public void testProcessingOfEmailAttachments() {
|
||||
|
||||
@@ -116,7 +95,7 @@ public class MimeMessageParsingTest {
|
||||
|
||||
for (WiserMessage wiserMessage : wiserMessages) {
|
||||
|
||||
final List<EmailFragment> emailFragments = new ArrayList<EmailFragment>();
|
||||
final List<EmailFragment> emailFragments = new ArrayList<>();
|
||||
|
||||
try {
|
||||
final MimeMessage mailMessage = wiserMessage.getMimeMessage();
|
||||
@@ -144,13 +123,15 @@ public class MimeMessageParsingTest {
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* This test will create a Mime Message that in return contains another
|
||||
* mime message. The nested mime message contains an attachment.
|
||||
*
|
||||
* The root message consist of both HTML and Text message.
|
||||
*
|
||||
*/
|
||||
*//*
|
||||
|
||||
@Test
|
||||
public void testProcessingOfNestedEmailAttachments() {
|
||||
|
||||
@@ -191,7 +172,7 @@ public class MimeMessageParsingTest {
|
||||
|
||||
for (WiserMessage wiserMessage : wiserMessages) {
|
||||
|
||||
List<EmailFragment> emailFragments = new ArrayList<EmailFragment>();
|
||||
List<EmailFragment> emailFragments = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
@@ -250,5 +231,6 @@ public class MimeMessageParsingTest {
|
||||
wiser.stop();
|
||||
LOGGER.info("Wiser stopped.");
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user