james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1001230 [2/2] - in /james/server/trunk: ./ mailetcontainer-api/ mailetcontainer-api/src/ mailetcontainer-api/src/main/ mailetcontainer-api/src/main/java/ mailetcontainer-api/src/main/java/org/ mailetcontainer-api/src/main/java/org/apache/ ...
Date Sat, 25 Sep 2010 15:01:22 GMT
Copied: james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherConfigImpl.java
(from r1000973, james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MatcherConfigImpl.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherConfigImpl.java?p2=james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherConfigImpl.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MatcherConfigImpl.java&r1=1000973&r2=1001230&rev=1001230&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/MatcherConfigImpl.java
(original)
+++ james/server/trunk/mailetcontainer-impl/src/main/java/org/apache/james/mailetcontainer/MatcherConfigImpl.java
Sat Sep 25 15:01:19 2010
@@ -19,7 +19,7 @@
 
 
 
-package org.apache.james.transport;
+package org.apache.james.mailetcontainer;
 
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.MatcherConfig;

Modified: james/server/trunk/mailets/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/pom.xml?rev=1001230&r1=1001229&r2=1001230&view=diff
==============================================================================
--- james/server/trunk/mailets/pom.xml (original)
+++ james/server/trunk/mailets/pom.xml Sat Sep 25 15:01:19 2010
@@ -86,6 +86,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-queue-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-dnsservice-api</artifactId>
     </dependency>
     <dependency>
@@ -109,7 +113,10 @@
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-core-library</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-jsieve-mailet</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>apache-mailet</artifactId>

Copied: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
(from r1000973, james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java?p2=james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java&r1=1000973&r2=1001230&rev=1001230&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
(original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
Sat Sep 25 15:01:19 2010
@@ -23,8 +23,8 @@ package org.apache.james.transport.maile
 
 import org.apache.james.api.user.UsersRepository;
 import org.apache.james.api.user.UsersStore;
+import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.services.MailServer;
-import org.apache.jsieve.mailet.Poster;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailetConfig;
@@ -62,7 +62,7 @@ public class LocalDelivery extends Gener
 
     private MailServer mailServer;
 
-	private Poster poster;
+    private MailboxManager mailboxManager;
 
 
     
@@ -83,9 +83,9 @@ public class LocalDelivery extends Gener
     }
     
 
-    @Resource(name="org.apache.jsieve.mailet.Poster")
-    public void setPoster(Poster poster) {
-        this.poster = poster;
+    @Resource(name="mailboxmanager")
+    public void setMailboxManager(MailboxManager mailboxManager) {
+        this.mailboxManager = mailboxManager;
     }
     
     /**
@@ -156,7 +156,7 @@ public class LocalDelivery extends Gener
 
         };
         sieveMailet.setMailSerer(mailServer);
-        sieveMailet.setPoster(poster);
+        sieveMailet.setMailboxManager(mailboxManager);
         sieveMailet.init(m);
 
         sieveMailet.setQuiet(true);

Copied: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
(from r1000973, james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/mailets/SieveMailet.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java?p2=james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/mailets/SieveMailet.java&r1=1000973&r2=1001230&rev=1001230&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
(original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
Sat Sep 25 15:01:19 2010
@@ -19,9 +19,20 @@
 
 package org.apache.james.transport.mailets;
 
+import java.io.IOException;
+import java.util.Date;
+
 import javax.annotation.Resource;
 import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
 
+import org.apache.commons.logging.Log;
+import org.apache.james.core.MimeMessageInputStream;
+import org.apache.james.mailbox.MailboxConstants;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxPath;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
 import org.apache.james.services.MailServer;
 import org.apache.jsieve.mailet.Poster;
 import org.apache.jsieve.mailet.SieveMailboxMailet;
@@ -31,37 +42,34 @@ import org.apache.mailet.MailetConfig;
 /**
  * Contains resource bindings.
  */
-public class SieveMailet extends SieveMailboxMailet {
+public class SieveMailet extends SieveMailboxMailet implements Poster{
 
     private MailServer mailServer;
+    private MailboxManager mailboxManager;
 
     @Resource(name="James")
     public void setMailSerer(MailServer mailServer) {
         this.mailServer = mailServer;
     }
 
+    
+    @Resource(name="mailboxmanager")
+    public void setMailboxManager(MailboxManager mailboxManager) {
+        this.mailboxManager = mailboxManager;
+    }
 
     @Override
     public void init(MailetConfig config) throws MessagingException {
         // ATM Fixed implementation
         setLocator(new ResourceLocatorImpl(mailServer.supportVirtualHosting()));
-        
+        setPoster(this);
         super.init(config);
     }
 
-
-
-
     public SieveMailet() {
         super();
 
     }
-
-    @Resource(name="org.apache.jsieve.mailet.Poster")
-    @Override
-    public void setPoster(Poster poster) {
-        super.setPoster(poster);
-    }
    
     /**
      * Return the username to use for sieve processing for the given MailAddress. If virtualhosting
@@ -77,5 +85,175 @@ public class SieveMailet extends SieveMa
             return super.getUsername(m);
         }
     }
-    
+   
+
+        /**
+     * @see org.apache.jsieve.mailet.Poster#post(java.lang.String,
+     *      javax.mail.internet.MimeMessage)
+     */
+    public void post(String url, MimeMessage mail) throws MessagingException {
+        final int endOfScheme = url.indexOf(':');
+        if (endOfScheme < 0) {
+            throw new MessagingException("Malformed URI");
+        } else {
+            final String scheme = url.substring(0, endOfScheme);
+            if ("mailbox".equals(scheme)) {
+                final int startOfUser = endOfScheme + 3;
+                final int endOfUser = url.indexOf('@', startOfUser);
+                if (endOfUser < 0) {
+                    // TODO: when user missing, append to a default location
+                    throw new MessagingException("Shared mailbox is not supported");
+                } else {
+                    String user = url.substring(startOfUser, endOfUser);
+                    final int startOfHost = endOfUser + 1;
+                    final int endOfHost = url.indexOf('/', startOfHost);
+                    final String host = url.substring(startOfHost, endOfHost);
+                    // if (!"localhost".equals(host)) {
+                    if (mailServer.isLocalServer(host) == false) {
+                        // TODO: possible support for clustering?
+                        throw new MessagingException("Only local mailboxes are supported");
+                    } else {
+                        final String urlPath;
+                        final int length = url.length();
+                        if (endOfHost + 1 == length) {
+                            urlPath = "INBOX";
+                        } else {
+                            urlPath = url.substring(endOfHost, length);
+                        }
+
+                        // check if we should use the full emailaddress as
+                        // username
+                        if (mailServer.supportVirtualHosting()) {
+                            user = user + "@" + host;
+                        }
+
+                        final MailboxSession session = mailboxManager.createSystemSession(user,
new MailetLog());
+
+                        // start processing request
+                        mailboxManager.startProcessingRequest(session);
+
+                        // This allows Sieve scripts to use a standard delimiter
+                        // regardless of mailbox implementation
+                        String destination = urlPath.replace('/', MailboxConstants.DEFAULT_DELIMITER);
+
+                        if (destination == null || "".equals(destination)) {
+                            destination = "INBOX";
+                        }
+                        if (destination.startsWith(MailboxConstants.DEFAULT_DELIMITER_STRING))
+                            destination = destination.substring(1);
+                        final MailboxPath path = new MailboxPath(MailboxConstants.USER_NAMESPACE,
user, destination);
+                        try {
+                            if ("INBOX".equalsIgnoreCase(destination) && !(mailboxManager.mailboxExists(path,
session))) {
+                                mailboxManager.createMailbox(path, session);
+                            }
+                            final MessageManager mailbox = mailboxManager.getMailbox(path,
session);
+
+                            if (mailbox == null) {
+                                final String error = "Mailbox for user " + user + " was not
found on this server.";
+                                throw new MessagingException(error);
+                            }
+
+                            mailbox.appendMessage(new MimeMessageInputStream(mail), new Date(),
session, true, null);
+                        } catch (IOException e) {
+                            throw new MessagingException("Failed to write mail message",
e);
+                        } finally {
+                            session.close();
+                            mailboxManager.logout(session, true);
+
+                            // stop processing request
+                            mailboxManager.endProcessingRequest(session);
+                        }
+                    }
+                }
+            } else {
+                // TODO: add support for more protocols
+                // TODO: for example mailto: for forwarding over SMTP
+                // TODO: for example xmpp: for forwarding over Jabber
+                throw new MessagingException("Unsupported protocol");
+            }
+        }
+    }
+
+    private final class MailetLog implements Log {
+
+        public void debug(Object arg0) {
+
+        }
+
+        public void debug(Object arg0, Throwable arg1) {
+        }
+
+        public void error(Object arg0) {
+            log(arg0.toString());
+        }
+
+        public void error(Object arg0, Throwable arg1) {
+            log(arg0.toString(), arg1);
+
+        }
+
+        public void fatal(Object arg0) {
+            log(arg0.toString());
+
+        }
+
+        public void fatal(Object arg0, Throwable arg1) {
+            log(arg0.toString(), arg1);
+
+        }
+
+        public void info(Object arg0) {
+            log(arg0.toString());
+
+        }
+
+        public void info(Object arg0, Throwable arg1) {
+            log(arg0.toString(), arg1);
+
+        }
+
+        public boolean isDebugEnabled() {
+            return false;
+        }
+
+        public boolean isErrorEnabled() {
+            return true;
+        }
+
+        public boolean isFatalEnabled() {
+            return true;
+        }
+
+        public boolean isInfoEnabled() {
+            return true;
+        }
+
+        public boolean isTraceEnabled() {
+            return false;
+        }
+
+        public boolean isWarnEnabled() {
+            return true;
+        }
+
+        public void trace(Object arg0) {
+
+        }
+
+        public void trace(Object arg0, Throwable arg1) {
+
+        }
+
+        public void warn(Object arg0) {
+            log(arg0.toString());
+
+        }
+
+        public void warn(Object arg0, Throwable arg1) {
+            log(arg0.toString(), arg1);
+
+        }
+
+    }
+
 }

Modified: james/server/trunk/mailets/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java?rev=1001230&r1=1000973&r2=1001230&view=diff
==============================================================================
--- james/server/trunk/mailets/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
(original)
+++ james/server/trunk/mailets/src/test/java/org/apache/james/transport/remotedeliverytester/AbstractRemoteDeliveryTest.java
Sat Sep 25 15:01:19 2010
@@ -34,8 +34,6 @@ import javax.mail.SendFailedException;
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
-import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.james.transport.remotedeliverytester.Tester.TestStatus;
 
 // TODO: FIX tests!

Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=1001230&r1=1001229&r2=1001230&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Sat Sep 25 15:01:19 2010
@@ -56,6 +56,9 @@
     <module>pop3server</module>
     <module>spool-api</module>
     <module>spoolmanager</module>
+    <module>mailetcontainer-api</module>
+    <module>mailetcontainer-impl</module>
+    <module>mailetcontainer-camel</module>
     <module>remotemanager</module>
     <module>mailets</module>
     <module>fetchmail</module>
@@ -333,9 +336,27 @@
       <artifactId>protocols-smtp</artifactId>
       <version>${protocols.version}</version>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-mailetcontainer-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-mailetcontainer-impl</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-mailetcontainer-camel</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+       
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-mailbox-adapter</artifactId>
       <version>${project.version}</version>
     </dependency>

Modified: james/server/trunk/spoolmanager/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/pom.xml?rev=1001230&r1=1001229&r2=1001230&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/pom.xml (original)
+++ james/server/trunk/spoolmanager/pom.xml Sat Sep 25 15:01:19 2010
@@ -28,33 +28,29 @@
   <artifactId>james-server-spoolmanager</artifactId>
   <name>Apache James Server SpoolManager</name>
   <dependencies>
-    <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>james-server-user-library</artifactId>
-    </dependency>
-    <dependency>
+     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-api</artifactId>
+      <artifactId>james-server-mailetcontainer-api</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-dnsservice-api</artifactId>
-    </dependency>
+      <artifactId>james-server-core-library</artifactId>
+    </dependency>  
     <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-user-api</artifactId>
-    </dependency>
+    </dependency>   
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-domain-api</artifactId>
+      <artifactId>james-server-core-api</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-common-util</artifactId>
+      <artifactId>james-server-dnsservice-api</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-library</artifactId>
+      <artifactId>james-server-domain-api</artifactId>
     </dependency>
      <dependency>
       <groupId>org.apache.james</groupId>
@@ -62,18 +58,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>apache-mailet-base</artifactId>
-    </dependency>   
-    <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>apache-jsieve-mailet</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>apache-james-mailbox-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.james</groupId>
       <artifactId>james-server-queue-api</artifactId>
     </dependency>
     <dependency>
@@ -92,14 +76,6 @@
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-annotation_1.0_spec</artifactId>
     </dependency>
-   <dependency>
-     <groupId>org.apache.camel</groupId>
-     <artifactId>camel-core</artifactId>
-   </dependency>
-    <dependency>
-      <groupId>oro</groupId>
-      <artifactId>oro</artifactId>
-    </dependency>
     <!-- Test dependencies -->
     <dependency>
       <groupId>org.apache.james</groupId>

Copied: james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java
(from r1000973, james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java?p2=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java&p1=james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java&r1=1000973&r2=1001230&rev=1001230&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java
(original)
+++ james/server/trunk/spoolmanager/src/main/java/org/apache/james/transport/JamesSpoolManager.java
Sat Sep 25 15:01:19 2010
@@ -36,6 +36,9 @@ import org.apache.commons.logging.Log;
 import org.apache.james.lifecycle.Configurable;
 import org.apache.james.lifecycle.LifecycleUtil;
 import org.apache.james.lifecycle.LogEnabled;
+import org.apache.james.mailetcontainer.MailProcessor;
+import org.apache.james.mailetcontainer.MailProcessorList;
+import org.apache.james.mailetcontainer.MailetContainer;
 import org.apache.james.queue.MailQueue;
 import org.apache.james.queue.MailQueueFactory;
 import org.apache.james.queue.MailQueue.DequeueOperation;

Modified: james/server/trunk/spring-deployment/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/pom.xml?rev=1001230&r1=1001229&r2=1001230&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/pom.xml (original)
+++ james/server/trunk/spring-deployment/pom.xml Sat Sep 25 15:01:19 2010
@@ -404,6 +404,17 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-mailetcontainer-impl</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-mailetcontainer-camel</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-mailbox-adapter</artifactId>
       <scope>runtime</scope>
     </dependency>

Modified: james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml?rev=1001230&r1=1001229&r2=1001230&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml (original)
+++ james/server/trunk/spring-deployment/src/main/config/james/spring-beans.xml Sat Sep 25
15:01:19 2010
@@ -155,7 +155,7 @@
     </bean>
         
     <!-- Build the camelroute from the spoolmanager.xml -->
-    <bean id="mailProcessor" name="processorRoute" class="org.apache.james.transport.camel.CamelMailProcessorList"/>
+    <bean id="mailProcessor" name="processorRoute" class="org.apache.james.mailetcontainer.camel.CamelMailProcessorList"/>
 
     <bean id="spoolmanager" class="org.apache.james.transport.JamesSpoolManager"/>
     
@@ -165,9 +165,9 @@
 
     <bean id="mailetcontext" class="org.apache.james.JamesMailetContext"/>
 
-    <bean id="matcherpackages" class="org.apache.james.transport.JamesMatcherLoader" />
+    <bean id="matcherpackages" class="org.apache.james.mailetcontainer.JamesMatcherLoader"
/>
 
-    <bean id="mailetpackages" class="org.apache.james.transport.JamesMailetLoader" />
+    <bean id="mailetpackages" class="org.apache.james.mailetcontainer.JamesMailetLoader"
/>
 
     <bean id="dnsserver" class="org.apache.james.dnsserver.DNSServer" />
 
@@ -284,9 +284,6 @@
     <bean id="domainlist" class="org.apache.james.domain.JDBCDomainList"/>
     -->
 
-    <!-- Poster -->
-    <bean id="poster" name="org.apache.jsieve.mailet.Poster" class="org.apache.james.MailboxManagerPoster"/>
-
     <!-- IMAP server Beans -->
     <bean id="imapserver" class="org.apache.james.imapserver.netty.NioImapServer">
         <property name="imapDecoder" ref="imapDecoder"/>



---------------------------------------------------------------------
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