From 3586c9ec80dc642d4c92d98bb3c2602d6125b394 Mon Sep 17 00:00:00 2001 From: Anthony Goubard Date: Thu, 14 Nov 2024 10:47:37 +0100 Subject: [PATCH] Fixed commons-vfs sandbox module not compiling due to missing imports and libraries --- commons-vfs2-sandbox/pom.xml | 9 ++++----- .../commons/vfs2/provider/mime/MimeAttributesMap.java | 9 ++++++--- .../vfs2/provider/mime/MimeFileContentInfoFactory.java | 4 +++- .../commons/vfs2/provider/mime/MimeFileObject.java | 4 +++- .../commons/vfs2/provider/mime/MimeFileSystem.java | 1 + .../apache/commons/vfs2/util/FileObjectDataSource.java | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/commons-vfs2-sandbox/pom.xml b/commons-vfs2-sandbox/pom.xml index 818080da96..b3680cf836 100644 --- a/commons-vfs2-sandbox/pom.xml +++ b/commons-vfs2-sandbox/pom.xml @@ -42,6 +42,10 @@ commons-logging commons-logging + + commons-io + commons-io + jcifs jcifs @@ -79,11 +83,6 @@ junit-vintage-engine test - - commons-io - commons-io - test - diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java index 5914163e28..33a58a1b77 100644 --- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java +++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeAttributesMap.java @@ -33,7 +33,10 @@ import org.apache.commons.logging.LogFactory; import jakarta.mail.Address; +import jakarta.mail.Header; +import jakarta.mail.Message; import jakarta.mail.MessagingException; +import jakarta.mail.Part; import jakarta.mail.internet.MimeMessage; /** @@ -136,19 +139,19 @@ private Map createMap() { if (part instanceof MimeMessage) { final MimeMessage message = (MimeMessage) part; try { - final Address[] address = message.getRecipients(RecipientType.BCC); + final Address[] address = message.getRecipients(Message.RecipientType.BCC); ret.put(OBJECT_PREFIX + "Recipients.BCC", address); } catch (final MessagingException e) { log.debug(e.getLocalizedMessage(), e); } try { - final Address[] address = message.getRecipients(RecipientType.CC); + final Address[] address = message.getRecipients(Message.RecipientType.CC); ret.put(OBJECT_PREFIX + "Recipients.CC", address); } catch (final MessagingException e) { log.debug(e.getLocalizedMessage(), e); } try { - final Address[] address = message.getRecipients(RecipientType.TO); + final Address[] address = message.getRecipients(Message.RecipientType.TO); ret.put(OBJECT_PREFIX + "Recipients.TO", address); } catch (final MessagingException e) { log.debug(e.getLocalizedMessage(), e); diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileContentInfoFactory.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileContentInfoFactory.java index 2c8606e6fe..05cb3e4b7b 100644 --- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileContentInfoFactory.java +++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileContentInfoFactory.java @@ -23,6 +23,8 @@ import org.apache.commons.vfs2.impl.DefaultFileContentInfo; import jakarta.mail.MessagingException; +import jakarta.mail.Part; +import jakarta.mail.internet.ContentType; /** * Gets access to the content info stuff for mime objects. @@ -31,7 +33,7 @@ public class MimeFileContentInfoFactory implements FileContentInfoFactory { @Override public FileContentInfo create(final FileContent fileContent) throws FileSystemException { final MimeFileObject mimeFile = (MimeFileObject) fileContent.getFile(); - final Part part = mimeFile.getPart(); + final Part part = (Part) mimeFile.getPart(); String contentTypeString = null; String charset = null; diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java index c7fde2dedd..083e5ca119 100644 --- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java +++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileObject.java @@ -16,6 +16,7 @@ */ package org.apache.commons.vfs2.provider.mime; +import jakarta.mail.Header; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; @@ -37,6 +38,7 @@ import jakarta.mail.Message; import jakarta.mail.MessagingException; import jakarta.mail.Multipart; +import jakarta.mail.Part; import jakarta.mail.internet.MimeMultipart; /** @@ -64,7 +66,7 @@ protected void doAttach() throws Exception { return; } - setPart(((MimeFileSystem) getFileSystem()).createCommunicationLink()); + setPart((Part) ((MimeFileSystem) getFileSystem()).createCommunicationLink()); } } diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java index a7723a41d2..408146ad83 100644 --- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java +++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/provider/mime/MimeFileSystem.java @@ -33,6 +33,7 @@ import org.apache.commons.vfs2.util.SharedRandomContentInputStream; import jakarta.mail.MessagingException; +import jakarta.mail.Part; import jakarta.mail.internet.MimeMessage; /** diff --git a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java index f8b90fa4a3..200417d90f 100644 --- a/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java +++ b/commons-vfs2-sandbox/src/main/java/org/apache/commons/vfs2/util/FileObjectDataSource.java @@ -20,7 +20,7 @@ import java.io.InputStream; import java.io.OutputStream; -import javax.activation.DataSource; +import jakarta.activation.DataSource; import org.apache.commons.vfs2.FileObject; import org.apache.commons.vfs2.FileSystemException;