diff --git a/imixs-archive-importer/pom.xml b/imixs-archive-importer/pom.xml index f69b139..205c27e 100644 --- a/imixs-archive-importer/pom.xml +++ b/imixs-archive-importer/pom.xml @@ -1,20 +1,15 @@ - - 4.0.0 - - org.imixs.workflow - imixs-archive - 3.0.1-SNAPSHOT - - imixs-archive-importer - - - - - javax - javaee-api - 8.0 - provided - + + 4.0.0 + + org.imixs.workflow + imixs-archive + 3.0.1-SNAPSHOT + + imixs-archive-importer + + org.imixs.workflow imixs-workflow-core @@ -23,15 +18,22 @@ org.imixs.workflow imixs-workflow-engine - + + + + org.eclipse.angus + jakarta.mail + 2.0.2 + + commons-net commons-net compile - + - - Imixs-Archive Importer + + Imixs-Archive Importer \ No newline at end of file diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPAuthenticator.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPAuthenticator.java index 3fbaea4..fa2c3b8 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPAuthenticator.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPAuthenticator.java @@ -30,11 +30,11 @@ import java.util.Properties; -import javax.mail.MessagingException; -import javax.mail.Store; - import org.imixs.workflow.ItemCollection; +import jakarta.mail.MessagingException; +import jakarta.mail.Store; + /** * The IMAPAuthenticator defines the interface to authenticate against a Mail * Store. Depending on the Mail system authentication can be very different. @@ -55,6 +55,6 @@ public interface IMAPAuthenticator { * @return * @throws MessagingException */ - public Store openMessageStore(ItemCollection sourceConfig, Properties sourceOptions) throws MessagingException; + public Store openMessageStore(ItemCollection sourceConfig, Properties sourceOptions) throws MessagingException; } diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPBasicAuthenticator.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPBasicAuthenticator.java index 7e4059f..0680d47 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPBasicAuthenticator.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPBasicAuthenticator.java @@ -33,14 +33,13 @@ import java.util.Properties; import java.util.logging.Logger; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Store; - import org.imixs.archive.importer.DocumentImportService; import org.imixs.workflow.ItemCollection; import jakarta.inject.Named; +import jakarta.mail.MessagingException; +import jakarta.mail.Session; +import jakarta.mail.Store; /** * The IMAPBasicAuthenticator authenticates against an Mail store using BASIC diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportHelper.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportHelper.java index 4ffc7b8..c5795b2 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportHelper.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportHelper.java @@ -33,7 +33,7 @@ import java.io.InputStream; import java.util.logging.Logger; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; /** * A helper bean with static methods @@ -44,36 +44,34 @@ public class IMAPImportHelper { private static Logger logger = Logger.getLogger(IMAPImportHelper.class.getName()); - /** - * This method returns true if the mediaType of a file attachment is + * This method returns true if the mediaType of a file attachment is *

* "application/octet-stream" *

- * In some cases we have a situation where the contentType is "application/octet" which is not a valid content type. + * In some cases we have a situation where the contentType is + * "application/octet" which is not a valid content type. * Also in this case we return true! * * @param contentType * @return */ public static boolean isMediaTypeOctet(String contentType, String filename) { - + if (contentType.contains(MediaType.APPLICATION_OCTET_STREAM)) { return true; } - + if (contentType.toLowerCase().startsWith("application/octet")) { // print a warning for later analysis logger.warning("Unknow ContentType: " + contentType + " - in " + filename); // Issue #167 return true; } - + // no octet type return false; } - - /** * Read inputstream into a byte array. diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportService.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportService.java index 1733120..0c70367 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportService.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPImportService.java @@ -37,17 +37,7 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import javax.mail.Address; -import javax.mail.BodyPart; -import javax.mail.Folder; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.Part; -import javax.mail.Store; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeBodyPart; - +import org.eclipse.angus.mail.imap.IMAPFolder; import org.imixs.archive.importer.DocumentImportEvent; import org.imixs.archive.importer.DocumentImportService; import org.imixs.workflow.FileData; @@ -59,14 +49,22 @@ import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.ProcessingErrorException; -import com.sun.mail.imap.IMAPFolder; - import jakarta.ejb.EJB; import jakarta.ejb.Stateless; import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.Any; import jakarta.enterprise.inject.Instance; import jakarta.inject.Inject; +import jakarta.mail.Address; +import jakarta.mail.BodyPart; +import jakarta.mail.Folder; +import jakarta.mail.Message; +import jakarta.mail.MessagingException; +import jakarta.mail.Multipart; +import jakarta.mail.Part; +import jakarta.mail.Store; +import jakarta.mail.internet.InternetAddress; +import jakarta.mail.internet.MimeBodyPart; /** * The EmailImportAdapter scans a IMAP account @@ -176,15 +174,17 @@ public void onEvent(@Observes DocumentImportEvent event) { } try { Store store = null; - // depending on the option "imap.authenticator" we use the corresponding IMAPAuthenticator + // depending on the option "imap.authenticator" we use the corresponding + // IMAPAuthenticator // to open the mail store - IMAPAuthenticator imapAuthenticator=null; - String authenticatorClass = sourceOptions.getProperty(OPTION_IMAP_AUTHENTICATOR, "org.imixs.archive.importer.mail.IMAPBasicAuthenticator"); + IMAPAuthenticator imapAuthenticator = null; + String authenticatorClass = sourceOptions.getProperty(OPTION_IMAP_AUTHENTICATOR, + "org.imixs.archive.importer.mail.IMAPBasicAuthenticator"); for (IMAPAuthenticator _imapAuthenticator : this.imapAuthenticators) { // find the matching authenticator.... - if (authenticatorClass.equals(_imapAuthenticator.getClass().getName() )) { - documentImportService.logMessage("...IMAPAuthenticator = "+authenticatorClass, event); - imapAuthenticator=_imapAuthenticator; + if (authenticatorClass.equals(_imapAuthenticator.getClass().getName())) { + documentImportService.logMessage("...IMAPAuthenticator = " + authenticatorClass, event); + imapAuthenticator = _imapAuthenticator; break; } } @@ -296,7 +296,7 @@ public void onEvent(@Observes DocumentImportEvent event) { logger.info("mimetype=" + contentType); } if (IMAPImportHelper.isMediaTypeOctet(contentType, fileName) - && fileName.toLowerCase().endsWith(".pdf")) { + && fileName.toLowerCase().endsWith(".pdf")) { logger.info("...converting mimetype '" + contentType + "' to application/pdf"); contentType = "application/pdf"; } @@ -370,8 +370,7 @@ public void onEvent(@Observes DocumentImportEvent event) { } } - - + /** * This method opens the IMAP archive folder. If the folder does not exist, the * method creates the folder. The folder name can be configured by the property @@ -428,5 +427,4 @@ public ItemCollection createWorkitem(ItemCollection source) return workitem; } - } diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPOutlookAuthenticator.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPOutlookAuthenticator.java index 22544bf..f58fc40 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPOutlookAuthenticator.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/IMAPOutlookAuthenticator.java @@ -37,18 +37,18 @@ import java.util.Properties; import java.util.logging.Logger; -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Store; import javax.net.ssl.HttpsURLConnection; import org.imixs.archive.importer.DocumentImportService; import org.imixs.workflow.ItemCollection; import jakarta.inject.Named; +import jakarta.json.Json; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; +import jakarta.mail.MessagingException; +import jakarta.mail.Session; +import jakarta.mail.Store; /** * The IMAPOutlookAuthenticator authenticates against Microsoft Outlook using @@ -83,7 +83,7 @@ public Store openMessageStore(ItemCollection sourceConfig, Properties sourceOpti String imapPassword = sourceConfig.getItemValueString(DocumentImportService.SOURCE_ITEM_PASSWORD); boolean debug = Boolean.getBoolean(sourceOptions.getProperty(IMAPImportService.OPTION_DEBUG, "false")); - + // create an empty properties object... // Properties props = System.getProperties(); Properties imapProperties = new Properties(); @@ -152,7 +152,7 @@ public Store openMessageStore(ItemCollection sourceConfig, Properties sourceOpti */ public String getAuthToken(String tenantId, String clientId, String client_secret) throws IOException { String sURL = "https://login.microsoftonline.com/" + tenantId + "/oauth2/v2.0/token"; - logger.finest("...oauth login url="+sURL); + logger.finest("...oauth login url=" + sURL); HttpsURLConnection httpClient = (HttpsURLConnection) new URL(sURL).openConnection(); // add request header diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailConverterService.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailConverterService.java index 555e980..fe706af 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailConverterService.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailConverterService.java @@ -30,17 +30,16 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.mail.BodyPart; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.Part; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeUtility; - import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; +import jakarta.mail.BodyPart; +import jakarta.mail.Message; +import jakarta.mail.MessagingException; +import jakarta.mail.Multipart; +import jakarta.mail.Part; +import jakarta.mail.internet.MimeBodyPart; +import jakarta.mail.internet.MimeMessage; +import jakarta.mail.internet.MimeUtility; /** * The MailConverterService provides methods to convert a Mail Message object diff --git a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailMessageService.java b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailMessageService.java index 50580ab..3c3a313 100644 --- a/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailMessageService.java +++ b/imixs-archive-importer/src/main/java/org/imixs/archive/importer/mail/MailMessageService.java @@ -28,15 +28,14 @@ import java.nio.charset.StandardCharsets; import java.util.logging.Logger; -import javax.mail.Message; -import javax.mail.MessagingException; - import org.imixs.workflow.FileData; import org.imixs.workflow.ItemCollection; import jakarta.ejb.EJB; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; +import jakarta.mail.Message; +import jakarta.mail.MessagingException; /** * The MessageService provides methods attach Message objects as a file to a