ACS-9199 Bump subethasmtp version to 7.1.3 (#3207)

* ACS-9199 Bump subethasmtp to 7.1.3

* ACS-9199 Bump subethasmtp to 7.1.3

* ACS-9199 Use org.eclipse.angus

* ACS-9199 Update notice.txt

* ACS-9199 Remove provided scope for jakarta.mail:mail-api

* ACS-9199 Fix ags

* ACS-9199 Remove verbose
This commit is contained in:
Damian Ujma
2025-02-19 15:42:14 +01:00
committed by GitHub
parent 85c0d7896e
commit 1adddb0f7f
8 changed files with 2069 additions and 2108 deletions

View File

@@ -1377,7 +1377,7 @@
"filename": "repository/src/test/java/org/alfresco/repo/imap/ImapMessageTest.java", "filename": "repository/src/test/java/org/alfresco/repo/imap/ImapMessageTest.java",
"hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997", "hashed_secret": "d033e22ae348aeb5660fc2140aec35850c4da997",
"is_verified": false, "is_verified": false,
"line_number": 118, "line_number": 116,
"is_secret": false "is_secret": false
} }
], ],
@@ -1868,5 +1868,5 @@
} }
] ]
}, },
"generated_at": "2025-02-11T13:28:51Z" "generated_at": "2025-02-18T15:50:35Z"
} }

View File

@@ -63,10 +63,6 @@
<groupId>jakarta.servlet</groupId> <groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId> <artifactId>jakarta.servlet-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.alfresco.surf</groupId> <groupId>org.alfresco.surf</groupId>
<artifactId>spring-webscripts</artifactId> <artifactId>spring-webscripts</artifactId>

View File

@@ -180,13 +180,13 @@ Lightbox JS http://lokeshdhakar.com/projects/lightbox/
=== Eclipse Public License 1.0 === === Eclipse Public License 1.0 ===
Angus Mail Provider https://eclipse-ee4j.github.io/angus-mail/
AspectJ http://eclipse.org/aspectj/ AspectJ http://eclipse.org/aspectj/
Bliki http://code.google.com/p/gwtwiki/ Bliki http://code.google.com/p/gwtwiki/
JUnit http://junit.org/ JUnit http://junit.org/
TrueLicense http://truelicense.java.net/ TrueLicense http://truelicense.java.net/
truezip http://truezip.java.net/ truezip http://truezip.java.net/
=== ICU License === === ICU License ===
icu4j http://icu-project.org/ icu4j http://icu-project.org/

View File

@@ -57,8 +57,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.mail</groupId> <groupId>org.eclipse.angus</groupId>
<artifactId>jakarta.mail</artifactId> <artifactId>angus-mail</artifactId>
</dependency> </dependency>
<dependency> <dependency>

10
pom.xml
View File

@@ -97,6 +97,7 @@
<dependency.jdom2.version>2.0.6.1</dependency.jdom2.version> <dependency.jdom2.version>2.0.6.1</dependency.jdom2.version>
<dependency.pooled-jms.version>3.1.6</dependency.pooled-jms.version> <dependency.pooled-jms.version>3.1.6</dependency.pooled-jms.version>
<dependency.kxml2.version>2.3.0</dependency.kxml2.version> <dependency.kxml2.version>2.3.0</dependency.kxml2.version>
<dependency.angus-mail.version>2.0.3</dependency.angus-mail.version>
<dependency.jakarta-ee-jaxb-api.version>4.0.2</dependency.jakarta-ee-jaxb-api.version> <dependency.jakarta-ee-jaxb-api.version>4.0.2</dependency.jakarta-ee-jaxb-api.version>
<dependency.jakarta-ee-jaxb-impl.version>4.0.5</dependency.jakarta-ee-jaxb-impl.version> <dependency.jakarta-ee-jaxb-impl.version>4.0.5</dependency.jakarta-ee-jaxb-impl.version>
@@ -105,7 +106,7 @@
<dependency.jakarta-annotation-api.version>3.0.0</dependency.jakarta-annotation-api.version> <dependency.jakarta-annotation-api.version>3.0.0</dependency.jakarta-annotation-api.version>
<dependency.jakarta-transaction-api.version>2.0.1</dependency.jakarta-transaction-api.version> <dependency.jakarta-transaction-api.version>2.0.1</dependency.jakarta-transaction-api.version>
<dependency.jakarta-jws-api.version>3.0.0</dependency.jakarta-jws-api.version> <dependency.jakarta-jws-api.version>3.0.0</dependency.jakarta-jws-api.version>
<dependency.jakarta-ee-mail.version>2.0.1</dependency.jakarta-ee-mail.version> <dependency.jakarta-ee-mail.version>2.1.3</dependency.jakarta-ee-mail.version>
<dependency.jakarta-ee-activation.version>2.0.1</dependency.jakarta-ee-activation.version> <dependency.jakarta-ee-activation.version>2.0.1</dependency.jakarta-ee-activation.version>
<dependency.jakarta-ee-jms.version>3.1.0</dependency.jakarta-ee-jms.version> <dependency.jakarta-ee-jms.version>3.1.0</dependency.jakarta-ee-jms.version>
<dependency.java-ee-activation.version>1.2.0</dependency.java-ee-activation.version> <dependency.java-ee-activation.version>1.2.0</dependency.java-ee-activation.version>
@@ -219,15 +220,14 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.mail</groupId> <groupId>org.eclipse.angus</groupId>
<artifactId>jakarta.mail</artifactId> <artifactId>angus-mail</artifactId>
<version>${dependency.jakarta-ee-mail.version}</version> <version>${dependency.angus-mail.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jakarta.mail</groupId> <groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId> <artifactId>jakarta.mail-api</artifactId>
<version>${dependency.jakarta-ee-mail.version}</version> <version>${dependency.jakarta-ee-mail.version}</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.activation</groupId> <groupId>com.sun.activation</groupId>

View File

@@ -56,8 +56,8 @@
<artifactId>jakarta.mail-api</artifactId> <artifactId>jakarta.mail-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.mail</groupId> <groupId>org.eclipse.angus</groupId>
<artifactId>jakarta.mail</artifactId> <artifactId>angus-mail</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@@ -190,7 +190,7 @@
<dependency> <dependency>
<groupId>com.github.davidmoten</groupId> <groupId>com.github.davidmoten</groupId>
<artifactId>subethasmtp</artifactId> <artifactId>subethasmtp</artifactId>
<version>6.0.6</version> <version>7.1.3</version>
<exclusions> <exclusions>
<!-- Duplicate classes from com.sun.mail:jakarta.mail --> <!-- Duplicate classes from com.sun.mail:jakarta.mail -->
<exclusion> <exclusion>

View File

@@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited * Copyright (C) 2005 - 2025 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
@@ -35,12 +35,17 @@ import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.Vector; import java.util.Vector;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import jakarta.mail.Message; import jakarta.mail.Message;
import jakarta.mail.Session; import jakarta.mail.Session;
import jakarta.mail.internet.InternetAddress; import jakarta.mail.internet.InternetAddress;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.angus.mail.smtp.SMTPMessage;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import org.alfresco.email.server.handler.FolderEmailMessageHandler; import org.alfresco.email.server.handler.FolderEmailMessageHandler;
import org.alfresco.email.server.impl.subetha.SubethaEmailMessage; import org.alfresco.email.server.impl.subetha.SubethaEmailMessage;
@@ -48,8 +53,8 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel; import org.alfresco.model.ForumModel;
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transfer.TransferModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transfer.TransferModel;
import org.alfresco.service.cmr.email.EmailDelivery; import org.alfresco.service.cmr.email.EmailDelivery;
import org.alfresco.service.cmr.email.EmailMessageException; import org.alfresco.service.cmr.email.EmailMessageException;
import org.alfresco.service.cmr.email.EmailService; import org.alfresco.service.cmr.email.EmailService;
@@ -65,17 +70,10 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.testing.category.LuceneTests;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import com.sun.mail.smtp.SMTPMessage;
/** /**
* Unit test of EmailServiceImplTest * Unit test of EmailServiceImplTest
*
* @author mrogers * @author mrogers
* *
*/ */
@@ -133,19 +131,15 @@ public class EmailServiceImplTest extends TestCase
personService.deletePerson(TEST_USER); personService.deletePerson(TEST_USER);
} }
catch (Exception e) catch (Exception e)
{ {}
}
} }
/** /**
* Test the from name. * Test the from name.
* *
* Step 1: * Step 1: User admin will map to the "unknownUser" which out of the box is "anonymous" Sending email From "admin" will fail.
* User admin will map to the "unknownUser" which out of the box is "anonymous"
* Sending email From "admin" will fail.
* *
* Step 2: * Step 2: Send from the test user to the test' user's home folder.
* Send from the test user to the test' user's home folder.
*/ */
public void testFromName() throws Exception public void testFromName() throws Exception
{ {
@@ -189,9 +183,7 @@ public class EmailServiceImplTest extends TestCase
String testUserHomeDBID = ((Long) nodeService.getProperty(testUserHomeFolder, ContentModel.PROP_NODE_DBID)).toString() + "@Alfresco.com"; String testUserHomeDBID = ((Long) nodeService.getProperty(testUserHomeFolder, ContentModel.PROP_NODE_DBID)).toString() + "@Alfresco.com";
/** /**
* Step 1 * Step 1 Negative test - send from "Bert" who does not exist. User will be mapped to anonymous who is not an email contributor.
* Negative test - send from "Bert" who does not exist.
* User will be mapped to anonymous who is not an email contributor.
*/ */
try try
{ {
@@ -266,8 +258,7 @@ public class EmailServiceImplTest extends TestCase
/** /**
* Step 3 * Step 3
* *
* message.from From with "name" < name@ domain > format * message.from From with "name" < name@ domain > format SMTP.FROM="dummy"
* SMTP.FROM="dummy"
* *
* Send From the test user <TEST_EMAIL> to the test user's home * Send From the test user <TEST_EMAIL> to the test user's home
*/ */
@@ -382,10 +373,8 @@ public class EmailServiceImplTest extends TestCase
// } // }
} }
/** /**
* ALF-9544 * ALF-9544 ALF-751
* ALF-751
* *
* Inbound email to a folder restricts file name to 86 characters or less. * Inbound email to a folder restricts file name to 86 characters or less.
* *
@@ -509,7 +498,6 @@ public class EmailServiceImplTest extends TestCase
emailService.importMessage(delivery, m); emailService.importMessage(delivery, m);
} }
// ALF-751 Email ends with period // ALF-751 Email ends with period
{ {
Session sess = Session.getDefaultInstance(new Properties()); Session sess = Session.getDefaultInstance(new Properties());
@@ -623,7 +611,6 @@ public class EmailServiceImplTest extends TestCase
String TEST_LONG_SUBJECT = "This is a very very long name in particular it is greater than eitghty six characters which was a problem explored in ALF-9544"; String TEST_LONG_SUBJECT = "This is a very very long name in particular it is greater than eitghty six characters which was a problem explored in ALF-9544";
// TODO Investigate why setting PROP_EMAIL on createPerson does not work. // TODO Investigate why setting PROP_EMAIL on createPerson does not work.
NodeRef person = personService.getPerson(TEST_USER); NodeRef person = personService.getPerson(TEST_USER);
if (person == null) if (person == null)
@@ -735,8 +722,7 @@ public class EmailServiceImplTest extends TestCase
assertEquals("assocs not 5", 5, assocs.size()); assertEquals("assocs not 5", 5, assocs.size());
/** /**
* Check assoc rename with long names and an extension. So truncation and rename need to * Check assoc rename with long names and an extension. So truncation and rename need to work together and not muck up a .extension.
* work together and not muck up a .extension.
*/ */
logger.debug("Step 4: turn off Overwite Duplicates with long subject name with extension"); logger.debug("Step 4: turn off Overwite Duplicates with long subject name with extension");
String EXT_NAME = "Blob.xls"; String EXT_NAME = "Blob.xls";
@@ -785,13 +771,13 @@ public class EmailServiceImplTest extends TestCase
class ConcurrentMessageImporter implements Runnable class ConcurrentMessageImporter implements Runnable
{ {
private Throwable throwable; private Throwable throwable;
@Override @Override
public void run() public void run()
{ {
try try
{ {
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
{
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
cdl.countDown(); cdl.countDown();
@@ -808,8 +794,7 @@ public class EmailServiceImplTest extends TestCase
} }
ConcurrentMessageImporter messageImporter = new ConcurrentMessageImporter(); ConcurrentMessageImporter messageImporter = new ConcurrentMessageImporter();
final Thread messageImporterThread = new Thread(messageImporter); final Thread messageImporterThread = new Thread(messageImporter);
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
{
public Void execute() throws Throwable public Void execute() throws Throwable
{ {
emailService.importMessage(delivery, m); emailService.importMessage(delivery, m);
@@ -907,7 +892,6 @@ public class EmailServiceImplTest extends TestCase
assertEquals(1, assocs.size()); assertEquals(1, assocs.size());
} }
/** /**
* ALF-12297 * ALF-12297
* *
@@ -923,7 +907,6 @@ public class EmailServiceImplTest extends TestCase
String TEST_LONG_SUBJECT = "This is a very very long name in particular it is greater than eitghty six characters which was a problem explored in ALF-9544"; String TEST_LONG_SUBJECT = "This is a very very long name in particular it is greater than eitghty six characters which was a problem explored in ALF-9544";
// TODO Investigate why setting PROP_EMAIL on createPerson does not work. // TODO Investigate why setting PROP_EMAIL on createPerson does not work.
NodeRef person = personService.getPerson(TEST_USER); NodeRef person = personService.getPerson(TEST_USER);
if (person == null) if (person == null)
@@ -963,7 +946,6 @@ public class EmailServiceImplTest extends TestCase
nodeService.deleteNode(assoc.getChildRef()); nodeService.deleteNode(assoc.getChildRef());
} }
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_NAME, "bees"); properties.put(ContentModel.PROP_NAME, "bees");
properties.put(ContentModel.PROP_DESCRIPTION, "bees - test doc for email tests"); properties.put(ContentModel.PROP_DESCRIPTION, "bees - test doc for email tests");
@@ -1007,11 +989,8 @@ public class EmailServiceImplTest extends TestCase
assertTrue(nodeService.hasAspect(testDocNodeRef, ForumModel.ASPECT_DISCUSSABLE)); assertTrue(nodeService.hasAspect(testDocNodeRef, ForumModel.ASPECT_DISCUSSABLE));
} // end of test sending to cm:content node } // end of test sending to cm:content node
/** /**
* ENH-560 - Inbound email server not working with custom types * ENH-560 - Inbound email server not working with custom types
*/ */
@@ -1025,7 +1004,6 @@ public class EmailServiceImplTest extends TestCase
String TEST_LONG_SUBJECT = "This is a very very long name in particular it is greater than eitghty six characters which was a problem explored in ALF-9544"; String TEST_LONG_SUBJECT = "This is a very very long name in particular it is greater than eitghty six characters which was a problem explored in ALF-9544";
// TODO Investigate why setting PROP_EMAIL on createPerson does not work. // TODO Investigate why setting PROP_EMAIL on createPerson does not work.
NodeRef person = personService.getPerson(TEST_USER); NodeRef person = personService.getPerson(TEST_USER);
if (person == null) if (person == null)
@@ -1065,7 +1043,6 @@ public class EmailServiceImplTest extends TestCase
nodeService.deleteNode(assoc.getChildRef()); nodeService.deleteNode(assoc.getChildRef());
} }
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_NAME, "hamster"); properties.put(ContentModel.PROP_NAME, "hamster");
properties.put(ContentModel.PROP_DESCRIPTION, "syrian hamsters - test doc for email tests, sending to a subtype of cm:content"); properties.put(ContentModel.PROP_DESCRIPTION, "syrian hamsters - test doc for email tests, sending to a subtype of cm:content");
@@ -1111,10 +1088,6 @@ public class EmailServiceImplTest extends TestCase
} // end of test sending to trx:transferReport } // end of test sending to trx:transferReport
/** /**
* The Email contributors authority controls who can add email. * The Email contributors authority controls who can add email.
* *
@@ -1163,11 +1136,9 @@ public class EmailServiceImplTest extends TestCase
String testUserHomeDBID = ((Long) nodeService.getProperty(testUserHomeFolder, ContentModel.PROP_NODE_DBID)).toString() + "@Alfresco.com"; String testUserHomeDBID = ((Long) nodeService.getProperty(testUserHomeFolder, ContentModel.PROP_NODE_DBID)).toString() + "@Alfresco.com";
/** /**
* Step 1 * Step 1 Set the email contributors authority to EVERYONE
* Set the email contributors authority to EVERYONE
* *
* Test that TEST_USER is allowed to send email - so even though TEST_USER is not * Test that TEST_USER is allowed to send email - so even though TEST_USER is not a contributor
* a contributor
*/ */
emailServiceImpl.setEmailContributorsAuthority("EVERYONE"); emailServiceImpl.setEmailContributorsAuthority("EVERYONE");
@@ -1198,8 +1169,7 @@ public class EmailServiceImplTest extends TestCase
emailService.importMessage(delivery, m); emailService.importMessage(delivery, m);
/** /**
* Step 2 * Step 2 Negative test
* Negative test
* *
* Send From the test user TEST_EMAIL to the test user's home * Send From the test user TEST_EMAIL to the test user's home
*/ */

View File

@@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
* Copyright (C) 2005 - 2023 Alfresco Software Limited * Copyright (C) 2005 - 2025 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
@@ -25,6 +25,8 @@
*/ */
package org.alfresco.repo.imap; package org.alfresco.repo.imap;
import static org.alfresco.model.ContentModel.PROP_MODIFIED;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@@ -37,7 +39,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import jakarta.mail.Address; import jakarta.mail.Address;
import jakarta.mail.Folder; import jakarta.mail.Folder;
import jakarta.mail.Message; import jakarta.mail.Message;
@@ -51,6 +52,23 @@ import jakarta.mail.internet.MimeUtility;
import jakarta.transaction.UserTransaction; import jakarta.transaction.UserTransaction;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.angus.mail.iap.ProtocolException;
import org.eclipse.angus.mail.iap.Response;
import org.eclipse.angus.mail.imap.IMAPFolder;
import org.eclipse.angus.mail.imap.protocol.BODY;
import org.eclipse.angus.mail.imap.protocol.FetchResponse;
import org.eclipse.angus.mail.imap.protocol.IMAPProtocol;
import org.eclipse.angus.mail.imap.protocol.IMAPResponse;
import org.eclipse.angus.mail.imap.protocol.RFC822DATA;
import org.eclipse.angus.mail.imap.protocol.UID;
import org.eclipse.angus.mail.util.ASCIIUtility;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.ImapModel; import org.alfresco.model.ImapModel;
@@ -83,26 +101,6 @@ import org.alfresco.util.PropertyMap;
import org.alfresco.util.config.RepositoryFolderConfigBean; import org.alfresco.util.config.RepositoryFolderConfigBean;
import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.LuceneTests;
import org.alfresco.util.testing.category.RedundantTests; import org.alfresco.util.testing.category.RedundantTests;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.javamail.MimeMessageHelper;
import com.sun.mail.iap.ProtocolException;
import com.sun.mail.iap.Response;
import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.protocol.BODY;
import com.sun.mail.imap.protocol.FetchResponse;
import com.sun.mail.imap.protocol.IMAPProtocol;
import com.sun.mail.imap.protocol.IMAPResponse;
import com.sun.mail.imap.protocol.RFC822DATA;
import com.sun.mail.imap.protocol.UID;
import com.sun.mail.util.ASCIIUtility;
import static org.alfresco.model.ContentModel.PROP_MODIFIED;
@Category({OwnJVMTestsCategory.class, LuceneTests.class}) @Category({OwnJVMTestsCategory.class, LuceneTests.class})
public class ImapMessageTest extends TestCase public class ImapMessageTest extends TestCase
@@ -159,7 +157,6 @@ public class ImapMessageTest extends TestCase
namespaceService = serviceRegistry.getNamespaceService(); namespaceService = serviceRegistry.getNamespaceService();
fileFolderService = serviceRegistry.getFileFolderService(); fileFolderService = serviceRegistry.getFileFolderService();
// start the transaction // start the transaction
UserTransaction txn = transactionService.getUserTransaction(); UserTransaction txn = transactionService.getUserTransaction();
txn.begin(); txn.begin();
@@ -220,7 +217,6 @@ public class ImapMessageTest extends TestCase
imapHome.setFolderPath(NamespaceService.CONTENT_MODEL_PREFIX + ":" + IMAP_FOLDER_NAME); imapHome.setFolderPath(NamespaceService.CONTENT_MODEL_PREFIX + ":" + IMAP_FOLDER_NAME);
imapServiceImpl.setImapHome(imapHome); imapServiceImpl.setImapHome(imapHome);
// Starting IMAP // Starting IMAP
imapServiceImpl.startupInTxn(true); imapServiceImpl.startupInTxn(true);
@@ -228,10 +224,7 @@ public class ImapMessageTest extends TestCase
namespaceService, false); namespaceService, false);
testImapFolderNodeRef = nodeRefs.get(0); testImapFolderNodeRef = nodeRefs.get(0);
/* /* Importing test folders: Test folder contains: "___-___folder_a" "___-___folder_a" contains: "___-___folder_a_a", "___-___file_a", "Message_485.eml" (this is IMAP Message) "___-___folder_a_a" contains: "____-____file_a_a" */
* Importing test folders: Test folder contains: "___-___folder_a" "___-___folder_a" contains: "___-___folder_a_a", "___-___file_a", "Message_485.eml" (this is IMAP
* Message) "___-___folder_a_a" contains: "____-____file_a_a"
*/
importInternal("imap/imapservice_test_folder_a.acp", testImapFolderNodeRef); importInternal("imap/imapservice_test_folder_a.acp", testImapFolderNodeRef);
txn.commit(); txn.commit();
@@ -349,8 +342,7 @@ public class ImapMessageTest extends TestCase
fail("Should raise an IOException"); fail("Should raise an IOException");
} }
catch (IOException e) catch (IOException e)
{ {}
}
} }
public void dontTestMessageCache() throws Exception public void dontTestMessageCache() throws Exception
@@ -411,8 +403,7 @@ public class ImapMessageTest extends TestCase
{ {
Locale.setDefault(Locale.FRENCH); Locale.setDefault(Locale.FRENCH);
String dateStr = "12-Jul-2020"; String dateStr = "12-Jul-2020";
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand() final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand() {
{
@Override @Override
public Object doCommand(IMAPProtocol protocol) public Object doCommand(IMAPProtocol protocol)
{ {
@@ -445,8 +436,7 @@ public class ImapMessageTest extends TestCase
Locale.setDefault(Locale.FRENCH); Locale.setDefault(Locale.FRENCH);
String dateStr = "12-juil.-2020"; String dateStr = "12-juil.-2020";
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand() final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand() {
{
@Override @Override
public Object doCommand(IMAPProtocol protocol) public Object doCommand(IMAPProtocol protocol)
{ {
@@ -607,8 +597,6 @@ public class ImapMessageTest extends TestCase
lfolder.appendMessages(messages); lfolder.appendMessages(messages);
// The search is not implemented. // The search is not implemented.
// SearchTerm term = new HeaderTerm("X-Alfresco-Unique", "test8bit"); // SearchTerm term = new HeaderTerm("X-Alfresco-Unique", "test8bit");
// messages = folder.search(term); // messages = folder.search(term);
@@ -626,7 +614,6 @@ public class ImapMessageTest extends TestCase
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, messageXPath, params, namespaceService, true); List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, messageXPath, params, namespaceService, true);
// does the message exist // does the message exist
assertEquals(1, nodeRefs.size()); assertEquals(1, nodeRefs.size());
@@ -646,8 +633,10 @@ public class ImapMessageTest extends TestCase
} }
finally finally
{ {
if (messageFileInputStream1 != null) messageFileInputStream1.close(); if (messageFileInputStream1 != null)
if (messageFileInputStream2 != null) messageFileInputStream2.close(); messageFileInputStream1.close();
if (messageFileInputStream2 != null)
messageFileInputStream2.close();
} }
// close connection // close connection
@@ -656,11 +645,9 @@ public class ImapMessageTest extends TestCase
} }
private static RFC822DATA getRFC822Message(final IMAPFolder folder, final long uid) throws MessagingException private static RFC822DATA getRFC822Message(final IMAPFolder folder, final long uid) throws MessagingException
{ {
return (RFC822DATA) folder.doCommand(new IMAPFolder.ProtocolCommand() return (RFC822DATA) folder.doCommand(new IMAPFolder.ProtocolCommand() {
{
public Object doCommand(IMAPProtocol p) throws ProtocolException public Object doCommand(IMAPProtocol p) throws ProtocolException
{ {
Response[] r = p.command("UID FETCH " + uid + " (RFC822)", null); Response[] r = p.command("UID FETCH " + uid + " (RFC822)", null);
@@ -681,17 +668,20 @@ public class ImapMessageTest extends TestCase
/** /**
* Returns BODY object containing desired message fragment * Returns BODY object containing desired message fragment
* *
* @param folder Folder containing the message * @param folder
* @param uid Message UID * Folder containing the message
* @param from starting byte * @param uid
* @param count bytes to read * Message UID
* @param from
* starting byte
* @param count
* bytes to read
* @return BODY containing desired message fragment * @return BODY containing desired message fragment
* @throws MessagingException * @throws MessagingException
*/ */
private static BODY getMessageBodyPart(IMAPFolder folder, final Long uid, final Integer from, final Integer count) throws MessagingException private static BODY getMessageBodyPart(IMAPFolder folder, final Long uid, final Integer from, final Integer count) throws MessagingException
{ {
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand() return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand() {
{
public Object doCommand(IMAPProtocol p) throws ProtocolException public Object doCommand(IMAPProtocol p) throws ProtocolException
{ {
Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[]<" + from + "." + count + ">)", null); Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[]<" + from + "." + count + ">)", null);
@@ -705,7 +695,7 @@ public class ImapMessageTest extends TestCase
} }
FetchResponse fetchResponse = (FetchResponse) r[0]; FetchResponse fetchResponse = (FetchResponse) r[0];
BODY body = (BODY) fetchResponse.getItem(com.sun.mail.imap.protocol.BODY.class); BODY body = (BODY) fetchResponse.getItem(BODY.class);
return body; return body;
} }
}); });
@@ -715,7 +705,8 @@ public class ImapMessageTest extends TestCase
/** /**
* Finds node by its path * Finds node by its path
* *
* @param path String * @param path
* String
* @return NodeRef * @return NodeRef
*/ */
private NodeRef findNode(String path) private NodeRef findNode(String path)
@@ -727,15 +718,16 @@ public class ImapMessageTest extends TestCase
/** /**
* Returns the UID of the first message in folder * Returns the UID of the first message in folder
* *
* @param folder Folder containing the message * @param folder
* @param msn message sequence number * Folder containing the message
* @param msn
* message sequence number
* @return UID of the first message * @return UID of the first message
* @throws MessagingException * @throws MessagingException
*/ */
private static Long getMessageUid(IMAPFolder folder, final int msn) throws MessagingException private static Long getMessageUid(IMAPFolder folder, final int msn) throws MessagingException
{ {
return (Long) folder.doCommand(new IMAPFolder.ProtocolCommand() return (Long) folder.doCommand(new IMAPFolder.ProtocolCommand() {
{
public Object doCommand(IMAPProtocol p) throws ProtocolException public Object doCommand(IMAPProtocol p) throws ProtocolException
{ {
String command = "FETCH " + msn + " (UID)"; String command = "FETCH " + msn + " (UID)";
@@ -761,8 +753,7 @@ public class ImapMessageTest extends TestCase
} }
/** /**
* Uh-oh - this is where we would intermittently fall over with a class cast exception. * Uh-oh - this is where we would intermittently fall over with a class cast exception. The following code probes why we don't have a FetchResponse
* The following code probes why we don't have a FetchResponse
*/ */
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("command=" + command); sb.append("command=" + command);
@@ -788,8 +779,10 @@ public class ImapMessageTest extends TestCase
/** /**
* Returns size of the message * Returns size of the message
* *
* @param folder Folder containing the message * @param folder
* @param uid Message UID * Folder containing the message
* @param uid
* Message UID
* @return Returns size of the message * @return Returns size of the message
* @throws MessagingException * @throws MessagingException
*/ */
@@ -801,15 +794,16 @@ public class ImapMessageTest extends TestCase
/** /**
* Returns a full message body * Returns a full message body
* *
* @param folder Folder containing the message * @param folder
* @param uid Message UID * Folder containing the message
* @param uid
* Message UID
* @return Returns size of the message * @return Returns size of the message
* @throws MessagingException * @throws MessagingException
*/ */
private static BODY getMessageBody(IMAPFolder folder, final Long uid) throws MessagingException private static BODY getMessageBody(IMAPFolder folder, final Long uid) throws MessagingException
{ {
return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand() return (BODY) folder.doCommand(new IMAPFolder.ProtocolCommand() {
{
public Object doCommand(IMAPProtocol p) throws ProtocolException public Object doCommand(IMAPProtocol p) throws ProtocolException
{ {
Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[])", null); Response[] r = p.command("UID FETCH " + uid + " (FLAGS BODY.PEEK[])", null);
@@ -831,7 +825,8 @@ public class ImapMessageTest extends TestCase
/** /**
* Simple util for logging response * Simple util for logging response
* *
* @param r response * @param r
* response
*/ */
private static void logResponse(Response[] r) private static void logResponse(Response[] r)
{ {