Author: imario
Date: Mon Nov 13 12:24:41 2006
New Revision: 474492
URL: http://svn.apache.org/viewvc?view=rev&rev=474492
Log:
in case of multipart message deliver the preamble instead of a simple
inputstream, in this case the inputStream is the whole multipart content -
which is not what we want in VFS
Modified:
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileContentInfoFactory.java
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileObject.java
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileSystem.java
Modified:
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileContentInfoFactory.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileContentInfoFactory.java?view=diff&rev=474492&r1=474491&r2=474492
==============================================================================
---
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileContentInfoFactory.java
(original)
+++
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileContentInfoFactory.java
Mon Nov 13 12:24:41 2006
@@ -47,6 +47,21 @@
throw new FileSystemException(e);
}
- return new DefaultFileContentInfo(contentType.getBaseType(),
contentType.getParameter("charset"));
+ String charset = contentType.getParameter("charset");
+ try
+ {
+ if (mimeFile.isMultipart())
+ {
+ // if this is a multipart message we deliver
the preamble instead of an inupt string
+ // the preamble will be delivered in UTF-8 -
fixed
+ charset = MimeFileSystem.PREAMBLE_CHARSET;
+ }
+ }
+ catch (MessagingException e)
+ {
+ throw new FileSystemException(e);
+ }
+
+ return new DefaultFileContentInfo(contentType.getBaseType(),
charset);
}
}
Modified:
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileObject.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileObject.java?view=diff&rev=474492&r1=474491&r2=474492
==============================================================================
---
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileObject.java
(original)
+++
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileObject.java
Mon Nov 13 12:24:41 2006
@@ -34,8 +34,11 @@
import javax.mail.Multipart;
import javax.mail.Part;
import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
import java.io.InputStream;
import java.io.IOException;
+import java.io.StringReader;
+import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
@@ -122,7 +125,7 @@
return null;
}
- if (part.getContentType() == null ||
!part.getContentType().startsWith("multipart/"))
+ if (!isMultipart())
{
// not a multipart
return null;
@@ -168,6 +171,13 @@
return FileType.IMAGINARY;
}
+ if (!isMultipart())
+ {
+ // we cant have children ...
+ return FileType.FILE;
+ }
+
+ // we have both
return FileType.FILE_OR_FOLDER;
}
@@ -188,7 +198,7 @@
}
List vfs = Collections.EMPTY_LIST;
- if (part.getContentType() != null &&
part.getContentType().startsWith("multipart/"))
+ if (isMultipart())
{
Object container = part.getContent();
if (container instanceof Multipart)
@@ -270,7 +280,18 @@
*/
protected InputStream doGetInputStream() throws Exception
{
+ if (isMultipart())
+ {
+ String preamble = ((MimeMultipart)
part.getContent()).getPreamble();
+ return new
ByteArrayInputStream(preamble.getBytes(MimeFileSystem.PREAMBLE_CHARSET));
+ }
+
return part.getInputStream();
+ }
+
+ boolean isMultipart() throws MessagingException
+ {
+ return part.getContentType() != null &&
part.getContentType().startsWith("multipart/");
}
protected FileContentInfoFactory getFileContentInfoFactory()
Modified:
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileSystem.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileSystem.java?view=diff&rev=474492&r1=474491&r2=474492
==============================================================================
---
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileSystem.java
(original)
+++
jakarta/commons/proper/vfs/trunk/sandbox/src/main/java/org/apache/commons/vfs/provider/mime/MimeFileSystem.java
Mon Nov 13 12:24:41 2006
@@ -35,6 +35,7 @@
implements FileSystem
{
public final static String NULL_BP_NAME = "_body_part_";
+ public final static String PREAMBLE_CHARSET = "UTF-8";
protected MimeFileSystem(final FileName rootName, final FileObject
parentLayer, final FileSystemOptions fileSystemOptions)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]