james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1152177 - in /james/imap/trunk: ./ processor/ processor/src/main/java/org/apache/james/imap/processor/fetch/
Date Fri, 29 Jul 2011 11:49:28 GMT
Author: norman
Date: Fri Jul 29 11:49:27 2011
New Revision: 1152177

URL: http://svn.apache.org/viewvc?rev=1152177&view=rev
Log:
Use mime4j 0.7. See IMAP-326

Modified:
    james/imap/trunk/pom.xml
    james/imap/trunk/processor/pom.xml
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java

Modified: james/imap/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/imap/trunk/pom.xml?rev=1152177&r1=1152176&r2=1152177&view=diff
==============================================================================
--- james/imap/trunk/pom.xml (original)
+++ james/imap/trunk/pom.xml Fri Jul 29 11:49:27 2011
@@ -426,7 +426,12 @@
       -->
       <dependency>
         <groupId>org.apache.james</groupId>
-        <artifactId>apache-mime4j</artifactId>
+        <artifactId>apache-mime4j-core</artifactId>
+        <version>${version.apache-mime4j}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.james</groupId>
+        <artifactId>apache-mime4j-dom</artifactId>
         <version>${version.apache-mime4j}</version>
       </dependency>
       <!-- Declare javamail as provided to be able to easily switch -->
@@ -583,7 +588,7 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <version.commons-lang>2.4</version.commons-lang>
     <version.commons-collections>3.2.1</version.commons-collections>
-    <version.apache-mime4j>0.6</version.apache-mime4j>
+    <version.apache-mime4j>0.7</version.apache-mime4j>
     <version.javax.mail>1.4.3</version.javax.mail>
     <version.activation>1.1.1</version.activation>
     <version.jmock>2.5.1</version.jmock>

Modified: james/imap/trunk/processor/pom.xml
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/pom.xml?rev=1152177&r1=1152176&r2=1152177&view=diff
==============================================================================
--- james/imap/trunk/processor/pom.xml (original)
+++ james/imap/trunk/processor/pom.xml Fri Jul 29 11:49:27 2011
@@ -32,13 +32,17 @@
       <groupId>org.apache.james</groupId>
       <artifactId>apache-james-imap-message</artifactId>
     </dependency>
-      <dependency>
-        <groupId>commons-codec</groupId>
-        <artifactId>commons-codec</artifactId>
-      </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-mime4j-core</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>apache-mime4j</artifactId>
+      <artifactId>apache-mime4j-dom</artifactId>
     </dependency>
     <dependency>
       <groupId>org.jmock</groupId>

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java?rev=1152177&r1=1152176&r2=1152177&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
Fri Jul 29 11:49:27 2011
@@ -33,13 +33,12 @@ import org.apache.james.mailbox.Headers;
 import org.apache.james.mailbox.MailboxException;
 import org.apache.james.mailbox.MessageResult;
 import org.apache.james.mime4j.codec.EncoderUtil;
-import org.apache.james.mime4j.field.address.Address;
-import org.apache.james.mime4j.field.address.AddressList;
-import org.apache.james.mime4j.field.address.DomainList;
-import org.apache.james.mime4j.field.address.Group;
-import org.apache.james.mime4j.field.address.MailboxList;
-import org.apache.james.mime4j.field.address.parser.ParseException;
-import org.apache.james.mime4j.util.MimeUtil;
+import org.apache.james.mime4j.dom.address.Address;
+import org.apache.james.mime4j.dom.address.AddressList;
+import org.apache.james.mime4j.dom.address.DomainList;
+import org.apache.james.mime4j.dom.address.Group;
+import org.apache.james.mime4j.dom.address.MailboxList;
+import org.apache.james.mime4j.field.address.LenientAddressBuilder;
 import org.slf4j.Logger;
 
 public final class EnvelopeBuilder {
@@ -131,38 +130,34 @@ public final class EnvelopeBuilder {
                 results = null;
             } else {
 
-                try {
-                    AddressList addressList = AddressList.parse(value);
-                    final int size = addressList.size();
-                    final List<FetchResponse.Envelope.Address> addresses = new ArrayList<FetchResponse.Envelope.Address>(size);
-                    for (int i = 0; i < size; i++) {
-                        final Address address = addressList.get(i);
-                        if (address instanceof Group) {
-                            final Group group = (Group) address;
-                            addAddresses(group, addresses);
-
-                        } else if (address instanceof org.apache.james.mime4j.field.address.Mailbox)
{
-                            final org.apache.james.mime4j.field.address.Mailbox mailbox =
(org.apache.james.mime4j.field.address.Mailbox) address;
-                            final FetchResponse.Envelope.Address mailboxAddress = buildMailboxAddress(mailbox);
-                            addresses.add(mailboxAddress);
-
-                        } else {
-                            logger.warn("Unknown address type");
-                        }
-                    }
+                AddressList addressList = LenientAddressBuilder.DEFAULT.parseAddressList(value);
+                final int size = addressList.size();
+                final List<FetchResponse.Envelope.Address> addresses = new ArrayList<FetchResponse.Envelope.Address>(size);
+                for (int i = 0; i < size; i++) {
+                    final Address address = addressList.get(i);
+                    if (address instanceof Group) {
+                        final Group group = (Group) address;
+                        addAddresses(group, addresses);
+
+                    } else if (address instanceof org.apache.james.mime4j.dom.address.Mailbox)
{
+                        final org.apache.james.mime4j.dom.address.Mailbox mailbox = (org.apache.james.mime4j.dom.address.Mailbox)
address;
+                        final FetchResponse.Envelope.Address mailboxAddress = buildMailboxAddress(mailbox);
+                        addresses.add(mailboxAddress);
 
-                    results = (FetchResponse.Envelope.Address[]) addresses.toArray(FetchResponse.Envelope.Address.EMPTY);
-                } catch (ParseException e) {
-                    logger.debug("Unable to parse out address", e);
-                    results = null;
+                    } else {
+                        logger.warn("Unknown address type");
+                    }
                 }
 
+                results = (FetchResponse.Envelope.Address[]) addresses.toArray(FetchResponse.Envelope.Address.EMPTY);
+                
+
             }
         }
         return results;
     }
 
-    private FetchResponse.Envelope.Address buildMailboxAddress(final org.apache.james.mime4j.field.address.Mailbox
mailbox) {
+    private FetchResponse.Envelope.Address buildMailboxAddress(final org.apache.james.mime4j.dom.address.Mailbox
mailbox) {
         // Encode the mailbox name
         // See IMAP-266
         String name = mailbox.getName();
@@ -189,7 +184,7 @@ public final class EnvelopeBuilder {
         addresses.add(start);
         final MailboxList mailboxList = group.getMailboxes();
         for (int i = 0; i < mailboxList.size(); i++) {
-            final org.apache.james.mime4j.field.address.Mailbox mailbox = mailboxList.get(i);
+            final org.apache.james.mime4j.dom.address.Mailbox mailbox = mailboxList.get(i);
             final FetchResponse.Envelope.Address address = buildMailboxAddress(mailbox);
             addresses.add(address);
         }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java?rev=1152177&r1=1152176&r2=1152177&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchProcessor.java
Fri Jul 29 11:49:27 2011
@@ -50,7 +50,6 @@ import org.apache.james.mailbox.MessageR
 import org.apache.james.mailbox.MessageResult;
 import org.apache.james.mailbox.MessageResult.FetchGroup;
 import org.apache.james.mailbox.MessageResult.MimePath;
-import org.apache.james.mime4j.field.address.parser.ParseException;
 
 public class FetchProcessor extends AbstractMailboxProcessor<FetchRequest> {
 
@@ -167,10 +166,6 @@ public class FetchProcessor extends Abst
                 try {
                     final FetchResponse response = builder.build(fetch, result, mailbox,
session, useUids);
                     responder.respond(response);
-                } catch (ParseException e) {
-                    // we can't for whatever reason parse the message so
-                    // just skip it and log it to debug
-                    session.getLog().debug("Unable to parse message with uid " + result.getUid(),
e);
                 } catch (MessageRangeException e) {
                     // we can't for whatever reason find the message so
                     // just skip it and log it to debug

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java?rev=1152177&r1=1152176&r2=1152177&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/FetchResponseBuilder.java
Fri Jul 29 11:49:27 2011
@@ -44,7 +44,6 @@ import org.apache.james.mailbox.MessageR
 import org.apache.james.mailbox.MessageRangeException;
 import org.apache.james.mailbox.MessageResult;
 import org.apache.james.mailbox.MimeDescriptor;
-import org.apache.james.mime4j.field.address.parser.ParseException;
 
 public final class FetchResponseBuilder {
 
@@ -105,7 +104,7 @@ public final class FetchResponseBuilder 
         return result;
     }
 
-    public FetchResponse build(FetchData fetch, MessageResult result, MessageManager mailbox,
ImapSession session, boolean useUids) throws MessageRangeException, ParseException, MailboxException
{
+    public FetchResponse build(FetchData fetch, MessageResult result, MessageManager mailbox,
ImapSession session, boolean useUids) throws MessageRangeException, MailboxException {
         final SelectedMailbox selected = session.getSelected();
         final long resultUid = result.getUid();
         final int resultMsn = selected.msn(resultUid);
@@ -194,7 +193,7 @@ public final class FetchResponseBuilder 
         return build();
     }
 
-    private FetchResponse.Envelope buildEnvelope(final MessageResult result) throws MailboxException,
ParseException {
+    private FetchResponse.Envelope buildEnvelope(final MessageResult result) throws MailboxException
{
         return envelopeBuilder.buildEnvelope(result);
     }
 

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java?rev=1152177&r1=1152176&r2=1152177&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MimeDescriptorStructure.java
Fri Jul 29 11:49:27 2011
@@ -32,7 +32,6 @@ import org.apache.james.imap.message.res
 import org.apache.james.imap.message.response.FetchResponse.Structure;
 import org.apache.james.mailbox.MailboxException;
 import org.apache.james.mailbox.MimeDescriptor;
-import org.apache.james.mime4j.field.address.parser.ParseException;
 
 final class MimeDescriptorStructure implements FetchResponse.Structure {
 
@@ -56,7 +55,7 @@ final class MimeDescriptorStructure impl
 
     private final Envelope envelope;
 
-    public MimeDescriptorStructure(final boolean allowExtensions, MimeDescriptor descriptor,
EnvelopeBuilder builder) throws MailboxException, ParseException {
+    public MimeDescriptorStructure(final boolean allowExtensions, MimeDescriptor descriptor,
EnvelopeBuilder builder) throws MailboxException {
         super();
         this.descriptor = descriptor;
         parameters = createParameters(descriptor);
@@ -79,7 +78,7 @@ final class MimeDescriptorStructure impl
         }
     }
 
-    private static List<Structure> createParts(final boolean allowExtensions, final
MimeDescriptor descriptor, final EnvelopeBuilder builder) throws MailboxException, ParseException
{
+    private static List<Structure> createParts(final boolean allowExtensions, final
MimeDescriptor descriptor, final EnvelopeBuilder builder) throws MailboxException {
         final List<Structure> results = new ArrayList<Structure>();
         for (Iterator<MimeDescriptor> it = descriptor.parts(); it.hasNext();) {
             final MimeDescriptor partDescriptor = it.next();



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message