You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2014/03/02 13:12:27 UTC

svn commit: r1573291 [6/8] - in /james/hupa/trunk: ./ client/ client/src/main/java/org/apache/hupa/ client/src/main/java/org/apache/hupa/client/ client/src/main/java/org/apache/hupa/client/activity/ client/src/main/java/org/apache/hupa/client/ioc/ clie...

Added: james/hupa/trunk/hupa/src/main/webapp/WEB-INF/conf/config.properties
URL: http://svn.apache.org/viewvc/james/hupa/trunk/hupa/src/main/webapp/WEB-INF/conf/config.properties?rev=1573291&view=auto
==============================================================================
--- james/hupa/trunk/hupa/src/main/webapp/WEB-INF/conf/config.properties (added)
+++ james/hupa/trunk/hupa/src/main/webapp/WEB-INF/conf/config.properties Sun Mar  2 12:12:22 2014
@@ -0,0 +1,64 @@
+#############################################################################
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#############################################################################
+
+# The demo mode should make two lines different
+# 1. IMAPServerAddress=hupa.demo
+# 2. DefaultInboxFolder=Mock-Inbox
+# and then use the credential: demo/demo to login to the webmail through the browser
+
+# The IP or domainname of the IMAP server
+IMAPServerAddress=imap.gmail.com
+# The port of the IMAP server
+IMAPServerPort=993
+# Set the connections amount which will get maximal opened per user for processing requests
+# Setting it higher can improve performance, but be sure that the IMAPServer will maybe have some limit
+IMAPConnectionPoolSize=2
+# Set the timeout for connections in milliseconds
+IMAPConnectionPoolTimeout=300000
+# Use SSL/TLS to connect to the IMAP server
+IMAPS=true
+
+# The Truststore when using self-signed certificates on the server
+# TrustStore=my-truststore
+# The Truststore's password
+# TrustStorePassword=changeit
+
+DefaultSentFolder=[Gmail]/Sent
+DefaultTrashFolder=[Gmail]/Trash
+DefaultDraftsFolder=[Gmail]/Drafts
+DefaultInboxFolder=INBOX
+
+# Number of Messages to post fetch
+PostFetchMessageCount=0
+
+# Log IMAP and SMTP dialog, Logger has to be in debug mode
+SessionDebug=true
+
+# The IP or domainname of the SMTP server
+SMTPServerAddress=smtp.gmail.com
+# The port of the SMTP server
+SMTPServerPort=465
+# Use AUTH for SMTP
+SMTPAuth=true
+# Use SSL/TLS to connect to the SMTP server
+SMTPS=true
+
+## Uncomment this line to use Demo mode
+# IMAPServerAddress=hupa.demo
+
+TrustSSL=false
+

Added: james/hupa/trunk/hupa/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/hupa/src/main/webapp/WEB-INF/web.xml?rev=1573291&view=auto
==============================================================================
--- james/hupa/trunk/hupa/src/main/webapp/WEB-INF/web.xml (added)
+++ james/hupa/trunk/hupa/src/main/webapp/WEB-INF/web.xml Sun Mar  2 12:12:22 2014
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to you under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied. See the License for
+    the specific language governing permissions and limitations under the
+    License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
+              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         version="2.5"
+         xmlns="http://java.sun.com/xml/ns/javaee">
+
+	<!-- Max size of the upload request (10MB) -->
+	<context-param>
+		<param-name>maxSize</param-name>
+		<param-value>10485760</param-value>
+	</context-param>
+	
+	
+    <!-- Tell guice which injector to use -->
+    <listener>
+      <listener-class>org.apache.hupa.server.ioc.GuiceListener</listener-class>
+    </listener>
+
+    <!-- Use guice as a request handler instead of mapping in web-app -->
+    <filter>
+      <filter-name>guiceFilter</filter-name>
+      <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
+    </filter>
+    <filter-mapping>
+      <filter-name>guiceFilter</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+   <!-- Default page to serve -->
+    <welcome-file-list>
+        <welcome-file>index.jsp</welcome-file>
+        <welcome-file>index.html</welcome-file>
+        <welcome-file>Hupa.html</welcome-file>
+        <welcome-file>hupa/Hupa.html</welcome-file>
+    </welcome-file-list>
+    
+</web-app>

Added: james/hupa/trunk/hupa/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/james/hupa/trunk/hupa/src/main/webapp/index.html?rev=1573291&view=auto
==============================================================================
--- james/hupa/trunk/hupa/src/main/webapp/index.html (added)
+++ james/hupa/trunk/hupa/src/main/webapp/index.html Sun Mar  2 12:12:22 2014
@@ -0,0 +1,30 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to you under the Apache License, Version
+    2.0 (the "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied. See the License for
+    the specific language governing permissions and limitations under the
+    License.
+-->
+<!DOCTYPE HTML>
+
+<html>
+  <head>
+  </head>
+  <body>
+     <script type="text/javascript">
+       function goTo(location) {
+         window.location = location + window.location.search +  window.location.hash;
+       }
+       goTo('hupa/Hupa.html');
+     </script>
+     <h2>Loading ...</h2>
+  </body>
+</html>
\ No newline at end of file

Modified: james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/guice/AbstractGuiceTestModule.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/guice/AbstractGuiceTestModule.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/guice/AbstractGuiceTestModule.java (original)
+++ james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/guice/AbstractGuiceTestModule.java Sun Mar  2 12:12:22 2014
@@ -21,8 +21,8 @@ package org.apache.hupa.server.guice;
 
 import java.util.Properties;
 
-import org.apache.hupa.shared.data.SettingsImpl;
 import org.apache.hupa.shared.data.UserImpl;
+import org.apache.hupa.shared.domain.Settings;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
@@ -79,21 +79,11 @@ public abstract class AbstractGuiceTestM
     	
         @Inject
         public TestUser(@Named("Username") String username, 
-                        @Named("Password") String password, 
-                        @Named("DefaultInboxFolder") final String inbox, 
-                        @Named("DefaultSentFolder") final String sent,
-                        @Named("DefaultTrashFolder") final String trash, 
-                        @Named("DefaultDraftsFolder") final String draft) {
+                        @Named("Password") String password,
+                        Settings settings) {
             setName(username);
             setPassword(password);
-            setSettings(new SettingsImpl() {
-                {
-                    setInboxFolderName(inbox);
-                    setSentFolderName(sent);
-                    setTrashFolderName(trash);
-                    setDraftsFolderName(draft);
-                }
-            });
+            setSettings(settings);
         }
     }
     
@@ -125,6 +115,7 @@ public abstract class AbstractGuiceTestM
             put("SMTPAuth", "true");
             
             put("SessionDebug", "true");
+            put("TrustSSL", "false");
         }
     };
     
@@ -155,6 +146,7 @@ public abstract class AbstractGuiceTestM
             put("SMTPAuth", "true");
             
             put("SessionDebug", "true");
+            put("TrustSSL", "false");
         }
     };
     
@@ -187,6 +179,7 @@ public abstract class AbstractGuiceTestM
             put("SMTPAuth", "true");
             
             put("SessionDebug", "true");
+            put("TrustSSL", "false");
         }
     };
 

Modified: james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockConstants.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockConstants.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockConstants.java (original)
+++ james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockConstants.java Sun Mar  2 12:12:22 2014
@@ -39,6 +39,13 @@ public class MockConstants {
             setSentFolderName(MockIMAPStore.MOCK_SENT_FOLDER);
             setTrashFolderName(MockIMAPStore.MOCK_TRASH_FOLDER);
             setDraftsFolderName(MockIMAPStore.MOCK_DRAFTS_FOLDER);
+            setImapServer("localhost");
+            setImapPort(143);
+            setImapSecure(false);
+            setSmtpServer("localhost");
+            setSmtpPort(25);
+            setSmtpSecure(false);
+            setSmtpAuth(false);
         }
     };
     
@@ -62,20 +69,11 @@ public class MockConstants {
         }
     };
 
-    public final static Settings mockUserSettings = new SettingsImpl() {
-        {
-            setInboxFolderName(MockIMAPStore.MOCK_INBOX_FOLDER);
-            setSentFolderName(MockIMAPStore.MOCK_SENT_FOLDER);
-            setTrashFolderName(MockIMAPStore.MOCK_TRASH_FOLDER);
-            setDraftsFolderName(MockIMAPStore.MOCK_DRAFTS_FOLDER);
-        }
-    };
-    
     public final static User mockUser = new UserImpl() {
         {
             setName(MockIMAPStore.MOCK_LOGIN);
             setPassword(MockIMAPStore.MOCK_LOGIN);
-            setSettings(mockUserSettings);
+            setSettings(mockSettings);
         }
     };
 }

Modified: james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPStore.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPStore.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPStore.java (original)
+++ james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPStore.java Sun Mar  2 12:12:22 2014
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import javax.mail.AuthenticationFailedException;
 import javax.mail.Folder;
@@ -40,7 +41,7 @@ public class MockIMAPStore extends IMAPS
     public final static String MOCK_TRASH_FOLDER = "Mock-Trash";
     public final static String MOCK_DRAFTS_FOLDER = "Mock-Drafts";
     public static final String MOCK_HOST = "hupa.demo";
-    public final static String MOCK_LOGIN = "demo";
+	public final static String MOCK_LOGIN = "demo";
     private Map<String, String> validLogins = new HashMap<String, String>();
     private boolean connected = false;
     private List<MockIMAPFolder> folders = new ArrayList<MockIMAPFolder>();
@@ -51,10 +52,13 @@ public class MockIMAPStore extends IMAPS
      * Default constructor, it creates the folder structure and loads messages for demo
      */
     @Inject
-    public MockIMAPStore(Session session) {
-        this(session, demoUrl);
+    public MockIMAPStore(Properties prop) {
+        this(Session.getInstance(prop), demoUrl);
+    }
+    
+    public MockIMAPStore(Session ses) {
+        this(ses, demoUrl);
     }
-
     /**
      * Customized constructor
      */
@@ -62,6 +66,7 @@ public class MockIMAPStore extends IMAPS
         super(session, url);
         if (url != null && MOCK_HOST.equals(url.getHost())) {
             validLogins.put(MOCK_LOGIN, MOCK_LOGIN);
+            validLogins.put("hupa4ecs@gmail.com", "HupaForEcs");
             try {
                 new MockIMAPFolder(MOCK_INBOX_FOLDER, this).create(Folder.HOLDS_FOLDERS | Folder.HOLDS_MESSAGES);
                 new MockIMAPFolder(MOCK_SENT_FOLDER, this).create(Folder.HOLDS_FOLDERS | Folder.HOLDS_MESSAGES);
@@ -196,7 +201,7 @@ public class MockIMAPStore extends IMAPS
             connect();
             return;
         } 
-        throw new AuthenticationFailedException("Invalid login");
+        throw new AuthenticationFailedException("Invalid login, remember user demo/demo");
     }
 
     @Override

Modified: james/hupa/trunk/mock/src/main/resources/mime/11.msg
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/resources/mime/11.msg?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/resources/mime/11.msg (original)
+++ james/hupa/trunk/mock/src/main/resources/mime/11.msg Sun Mar  2 12:12:22 2014
@@ -1,51 +1,46 @@
-Delivered-To: mcdodot@gmail.com
-Received: by 10.60.131.212 with SMTP id oo20csp72677oeb;
-        Mon, 10 Jun 2013 08:20:07 -0700 (PDT)
-X-Received: by 10.205.24.6 with SMTP id rc6mr1584559bkb.141.1370877606962;
-        Mon, 10 Jun 2013 08:20:06 -0700 (PDT)
-Return-Path: <ec...@gmail.com>
-Received: from mail-bk0-x233.google.com (mail-bk0-x233.google.com [2a00:1450:4008:c01::233])
-        by mx.google.com with ESMTPS id kf6si1566340bkb.107.2013.06.10.08.20.06
-        for <mc...@gmail.com>
+Delivered-To: hupa4ecs@gmail.com
+Received: by 10.194.20.5 with SMTP id j5csp57020wje;
+        Thu, 15 Aug 2013 23:38:54 -0700 (PDT)
+X-Received: by 10.180.74.235 with SMTP id x11mr7549wiv.26.1376635134488;
+        Thu, 15 Aug 2013 23:38:54 -0700 (PDT)
+Return-Path: <mc...@gmail.com>
+Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176])
+        by mx.google.com with ESMTPS id p14si19626wie.14.1969.12.31.16.00.00
         (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
-        Mon, 10 Jun 2013 08:20:06 -0700 (PDT)
-Received-SPF: pass (google.com: domain of echowdx@gmail.com designates 2a00:1450:4008:c01::233 as permitted sender) client-ip=2a00:1450:4008:c01::233;
+        Thu, 15 Aug 2013 23:38:54 -0700 (PDT)
+Received-SPF: pass (google.com: domain of mcdodot@gmail.com designates 74.125.82.176 as permitted sender) client-ip=74.125.82.176;
 Authentication-Results: mx.google.com;
-       spf=pass (google.com: domain of echowdx@gmail.com designates 2a00:1450:4008:c01::233 as permitted sender) smtp.mail=echowdx@gmail.com;
-       dkim=pass header.i=@gmail.com
-Received: by mail-bk0-x233.google.com with SMTP id ji1so2631218bkc.24
-        for <mc...@gmail.com>; Mon, 10 Jun 2013 08:20:06 -0700 (PDT)
+       spf=pass (google.com: domain of mcdodot@gmail.com designates 74.125.82.176 as permitted sender) smtp.mail=mcdodot@gmail.com;
+       dkim=pass header.i=@gmail.com;
+       dmarc=pass (p=NONE dis=NONE) d=gmail.com
+Received: by mail-we0-f176.google.com with SMTP id t59so1160383wes.35
+        for <hu...@gmail.com>; Thu, 15 Aug 2013 23:38:54 -0700 (PDT)
 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
         d=gmail.com; s=20120113;
-        h=message-id:date:from:user-agent:mime-version:to:subject:references
-         :in-reply-to:x-chiaramail-content-pointer
-         :x-chiaramail-content-server-name:x-chiaramail-content-server-port
+        h=message-id:date:from:user-agent:mime-version:to:subject
          :content-type:content-transfer-encoding;
         bh=40fimkYYpXaLiVIKuTv2tLgUPaqUGA1DOkoRGdypt/8=;
-        b=AzWWH4udXhYp8dNi1IdLVpDKDZVeNA2363k1/NhOHYucX/tPZSBWdpT9tNPBjxDEiV
-         O/8nINUhZfC8ClQy4ZPvd/VklvH6jLZG3+uzkUVX5lXDVokWwtz6DhSgb6k7nFwFkNeL
-         ImHWZcROVkYbghoGhIvuW/2EElAvOOKCw9mPLuh3jLv2ymFAX3Qo/Gdkq17tGaxdk1Bx
-         BrZ4DaAoK1Tnb0CCRNqUWX8UWToYzgXED22PUtSD6FjWHT9hOFBlgWFAdcK6bIOOKHec
-         XFuhLrB7bvKUSooMUG3vrWQmgzo8e0uEWyLez1blwYn7maOpuNO4P3937dm4JkE4yxGB
-         wSLQ==
-X-Received: by 10.204.187.209 with SMTP id cx17mr1609776bkb.143.1370877606450;
-        Mon, 10 Jun 2013 08:20:06 -0700 (PDT)
-Return-Path: <ec...@gmail.com>
-Received: from [10.20.0.2] ([69.85.95.7])
-        by mx.google.com with ESMTPSA id tl1sm4088263bkb.7.2013.06.10.08.20.04
-        for <mc...@gmail.com>
+        b=q4n+7j2eKc61jOeUFMjq3uCS/2YXcJ71677MsbyMFWxcC4BhUU6G7NQ0T86ekKJb0E
+         kWlC78owAIdL5xwws9nGpwGJeGUslG5AFaElrX8fdzAW5z/DJQ3BcPfZ458vKLZ5d/nN
+         YJ2II57GgEqBZDetRglJdpbhZbKUiMLm1N0WdKMYbl4PaBSXgiQvu4mPiyGf2NS8rmrv
+         c9k8OQlnWcZ/p38UcWAy2pNlrxCfg0JK68w0HuYPhPV3DcwW/JDrFvNWdmBV5sywYJuW
+         7/e+bwMGoX0cYr3um1YXbI2boaerHTYYkjPYkDmNrTKPE/032oFXknFtSE6QI7VZZMAE
+         gvMQ==
+X-Received: by 10.180.77.193 with SMTP id u1mr4164827wiw.34.1376635134412;
+        Thu, 15 Aug 2013 23:38:54 -0700 (PDT)
+Return-Path: <mc...@gmail.com>
+Received: from [192.168.1.35] (25.Red-88-22-232.staticIP.rima-tde.net. [88.22.232.25])
+        by mx.google.com with ESMTPSA id a4sm6110885wik.11.1969.12.31.16.00.00
         (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
-        Mon, 10 Jun 2013 08:20:05 -0700 (PDT)
-Message-ID: <51...@gmail.com>
-Date: Mon, 10 Jun 2013 23:20:00 +0800
-From: dongxu <ec...@gmail.com>
-User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
+        Thu, 15 Aug 2013 23:38:53 -0700 (PDT)
+Message-ID: <52...@gmail.com>
+Date: Fri, 16 Aug 2013 08:38:42 +0200
+From: Manuel Carrasco <mc...@gmail.com>
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8
 MIME-Version: 1.0
-To: Manuel Carrasco <mc...@gmail.com>
-Subject: Re: Test 1
-References: <51...@gmail.com>
-In-Reply-To: <51...@gmail.com>
-X-ChiaraMail-Content-Pointer: 8
+To: hupa4ecs@gmail.com
+Subject: Clear message
+X-ChiaraMail-Content-Pointer: 32
 X-ChiaraMail-Content-Server-Name: www.chiaramail.com
 X-ChiaraMail-Content-Server-Port: 443
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Modified: james/hupa/trunk/mock/src/main/resources/mime/12.msg
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/resources/mime/12.msg?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/resources/mime/12.msg (original)
+++ james/hupa/trunk/mock/src/main/resources/mime/12.msg Sun Mar  2 12:12:22 2014
@@ -1,50 +1,47 @@
-Delivered-To: mcdodot@gmail.com
-Received: by 10.60.131.212 with SMTP id oo20csp73659oeb;
-        Mon, 10 Jun 2013 08:49:12 -0700 (PDT)
-X-Received: by 10.205.22.196 with SMTP id qx4mr1610488bkb.57.1370879351744;
-        Mon, 10 Jun 2013 08:49:11 -0700 (PDT)
-Return-Path: <ec...@gmail.com>
-Received: from mail-bk0-x22a.google.com (mail-bk0-x22a.google.com [2a00:1450:4008:c01::22a])
-        by mx.google.com with ESMTPS id t2si950481bkh.191.2013.06.10.08.49.11
-        for <mc...@gmail.com>
+Delivered-To: hupa4ecs@gmail.com
+Received: by 10.194.20.5 with SMTP id j5csp57047wje;
+        Thu, 15 Aug 2013 23:40:10 -0700 (PDT)
+X-Received: by 10.180.188.49 with SMTP id fx17mr4168116wic.49.1376635210470;
+        Thu, 15 Aug 2013 23:40:10 -0700 (PDT)
+Return-Path: <mc...@gmail.com>
+Received: from mail-wi0-x236.google.com (mail-wi0-x236.google.com [2a00:1450:400c:c05::236])
+        by mx.google.com with ESMTPS id hm1si12839wib.51.1969.12.31.16.00.00
         (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
-        Mon, 10 Jun 2013 08:49:11 -0700 (PDT)
-Received-SPF: pass (google.com: domain of echowdx@gmail.com designates 2a00:1450:4008:c01::22a as permitted sender) client-ip=2a00:1450:4008:c01::22a;
+        Thu, 15 Aug 2013 23:40:10 -0700 (PDT)
+Received-SPF: pass (google.com: domain of mcdodot@gmail.com designates 2a00:1450:400c:c05::236 as permitted sender) client-ip=2a00:1450:400c:c05::236;
 Authentication-Results: mx.google.com;
-       spf=pass (google.com: domain of echowdx@gmail.com designates 2a00:1450:4008:c01::22a as permitted sender) smtp.mail=echowdx@gmail.com;
-       dkim=pass header.i=@gmail.com
-Received: by mail-bk0-x22a.google.com with SMTP id jk13so3448363bkc.1
-        for <mc...@gmail.com>; Mon, 10 Jun 2013 08:49:11 -0700 (PDT)
+       spf=pass (google.com: domain of mcdodot@gmail.com designates 2a00:1450:400c:c05::236 as permitted sender) smtp.mail=mcdodot@gmail.com;
+       dkim=pass header.i=@gmail.com;
+       dmarc=pass (p=NONE dis=NONE) d=gmail.com
+Received: by mail-wi0-x236.google.com with SMTP id hi8so465149wib.9
+        for <hu...@gmail.com>; Thu, 15 Aug 2013 23:40:10 -0700 (PDT)
 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
         d=gmail.com; s=20120113;
         h=message-id:date:from:user-agent:mime-version:to:subject
-         :x-chiaramail-content-pointer:x-chiaramail-content-key2
-         :x-chiaramail-content-server-name:x-chiaramail-content-server-port
          :content-type:content-transfer-encoding;
         bh=40fimkYYpXaLiVIKuTv2tLgUPaqUGA1DOkoRGdypt/8=;
-        b=vvOKuDgFhW7lhslsd+p1zFzCgGsB1q+Nz/VX94yvOzYNgzK+ztjWuRXqhxInvKB/6A
-         KULfTqxc6eCGaOwQe2jfzcCnE9NqbqNyqWdrKGtcYo/kC3cmSM+vPiVVwin4Ocib+tZk
-         gLRThq7wglPAniM9+y0MEtXWU2C0PRWCKM/keEZloAJrL9x3RR/5vQ3Cn8oVyI5yg328
-         sFIUYa2UvKJ+3rb3I/XCoqaDu26+A2wDiemzPMXUP3p3rTawvt/Bmg8SsxuzCo5zi8vf
-         oUsbFJWM9wPxCW53BBKQXNJ8yIPh+MD76ymg6bGuKHkSilqfTQk1NCr8QbFdO/FaeAba
-         Ad5g==
-X-Received: by 10.204.74.138 with SMTP id u10mr1617410bkj.113.1370879351096;
-        Mon, 10 Jun 2013 08:49:11 -0700 (PDT)
-Return-Path: <ec...@gmail.com>
-Received: from [10.20.0.2] ([69.85.95.7])
-        by mx.google.com with ESMTPSA id jm15sm4132474bkb.13.2013.06.10.08.49.08
-        for <multiple recipients>
+        b=mqMNAF+icS8do7uoVHHtaYRrxh7Yh50ZAV3ZXuDQLQIUjf+3spMQn37P2p+xhDsH/3
+         fpOiFi5OzF6ufmUTd8kXe5E/jYmO0wxAvzSZ/Rzgif40EVAJ/1XEoW5ISspHL4tIJtwc
+         JYCwmCoViYf/O453zXAAAf7HeA63WqkxOnbD2C0MyF4ucOkmW9XJJDnRVn154vt7IIZa
+         7ZzXQyQjZ6Huf8fX6iNUM7VR5mPW8NYU5qfho6VmgpagBLGApWKC2CMo8Om9qg1KvQ9s
+         n9pbSlgHwUcSZNJt1RE/xSItkEhjM0Imkutr/x5J/Qk/G/Ny+HH5OpjFa1kgB3/K0gND
+         eXzQ==
+X-Received: by 10.180.72.140 with SMTP id d12mr32810wiv.11.1376635210416;
+        Thu, 15 Aug 2013 23:40:10 -0700 (PDT)
+Return-Path: <mc...@gmail.com>
+Received: from [192.168.1.35] (25.Red-88-22-232.staticIP.rima-tde.net. [88.22.232.25])
+        by mx.google.com with ESMTPSA id hb2sm937458wib.0.1969.12.31.16.00.00
         (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
-        Mon, 10 Jun 2013 08:49:10 -0700 (PDT)
-Message-ID: <51...@gmail.com>
-Date: Mon, 10 Jun 2013 23:49:05 +0800
-From: dongxu <ec...@gmail.com>
-User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130509 Thunderbird/17.0.6
+        Thu, 15 Aug 2013 23:40:09 -0700 (PDT)
+Message-ID: <52...@gmail.com>
+Date: Fri, 16 Aug 2013 08:40:08 +0200
+From: Manuel Carrasco <mc...@gmail.com>
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8
 MIME-Version: 1.0
-To: Manuel Carrasco <mc...@gmail.com>
-Subject: Test with bcc without content inside
-X-ChiaraMail-Content-Pointer: 72
-X-ChiaraMail-Content-Key2: 98333074730306711837946622793808
+To: hupa4ecs@gmail.com
+Subject: Encrypted message
+X-ChiaraMail-Content-Pointer: 40
+X-ChiaraMail-Content-Key2: 02192564530017260336297834796621
 X-ChiaraMail-Content-Server-Name: www.chiaramail.com
 X-ChiaraMail-Content-Server-Port: 443
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Modified: james/hupa/trunk/mock/src/main/resources/mime/13.msg
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/resources/mime/13.msg?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/resources/mime/13.msg (original)
+++ james/hupa/trunk/mock/src/main/resources/mime/13.msg Sun Mar  2 12:12:22 2014
@@ -1,43 +1,49 @@
+Delivered-To: hupa4ecs@gmail.com
+Received: by 10.194.20.5 with SMTP id j5csp57070wje;
+        Thu, 15 Aug 2013 23:41:07 -0700 (PDT)
+X-Received: by 10.194.235.138 with SMTP id um10mr21673wjc.30.1376635267019;
+        Thu, 15 Aug 2013 23:41:07 -0700 (PDT)
 Return-Path: <mc...@gmail.com>
-Received: from [192.168.1.35] (239.Red-79-148-67.dynamicIP.rima-tde.net. [79.148.67.239])
-        by mx.google.com with ESMTPSA id l7sm2877195wiw.4.1969.12.31.16.00.00
+Received: from mail-wi0-x235.google.com (mail-wi0-x235.google.com [2a00:1450:400c:c05::235])
+        by mx.google.com with ESMTPS id ff5si2193677wic.83.1969.12.31.16.00.00
         (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
-        Thu, 15 Aug 2013 06:08:16 -0700 (PDT)
-Message-ID: <52...@gmail.com>
-Date: Thu, 15 Aug 2013 15:08:07 +0200
+        Thu, 15 Aug 2013 23:41:07 -0700 (PDT)
+Received-SPF: pass (google.com: domain of mcdodot@gmail.com designates 2a00:1450:400c:c05::235 as permitted sender) client-ip=2a00:1450:400c:c05::235;
+Authentication-Results: mx.google.com;
+       spf=pass (google.com: domain of mcdodot@gmail.com designates 2a00:1450:400c:c05::235 as permitted sender) smtp.mail=mcdodot@gmail.com;
+       dkim=pass header.i=@gmail.com;
+       dmarc=pass (p=NONE dis=NONE) d=gmail.com
+Received: by mail-wi0-x235.google.com with SMTP id en1so467825wid.8
+        for <hu...@gmail.com>; Thu, 15 Aug 2013 23:41:07 -0700 (PDT)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+        d=gmail.com; s=20120113;
+        h=message-id:date:from:user-agent:mime-version:to:subject
+         :content-type:content-transfer-encoding;
+        bh=OiU/cI/pNcRDAxIN/CmIVMY9Lg6v96jdy3UtbyOMeWw=;
+        b=FH3VQ+LDscPE/Nk4fm95BbibuXTDDmB4XqgkNqKvp+ruX7GChJQZHuyzc7DxpUT7Je
+         8L8d0TBx42JPu+6UdY8pd1bULBz5cnDC/aWeEaWb+rzogRAen1pQIvXAy2bzSBb1fyQY
+         E1TZX7oziypusGC5TK6sm1W794h+Jb+zun760vYPqMQLK8MhKQi3uay20g0o8GArgsbV
+         BBVjvb1i8DhziXpQ001YRxVUXwJ8/faeq4H1Q3FvaSJ9JxQ6YRmUw/SzIAfryi5TZ8IN
+         adI4MgvaXzAW1W1E8oPwCI8fwJQclw5MbFeZHFBpHpG5JDQstd1AmcPHcrcZ7Jnqi2x8
+         bufw==
+X-Received: by 10.194.104.170 with SMTP id gf10mr53382wjb.90.1376635266968;
+        Thu, 15 Aug 2013 23:41:06 -0700 (PDT)
+Return-Path: <mc...@gmail.com>
+Received: from [192.168.1.35] (25.Red-88-22-232.staticIP.rima-tde.net. [88.22.232.25])
+        by mx.google.com with ESMTPSA id eb3sm6129872wic.10.1969.12.31.16.00.00
+        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
+        Thu, 15 Aug 2013 23:41:06 -0700 (PDT)
+Message-ID: <52...@gmail.com>
+Date: Fri, 16 Aug 2013 08:41:04 +0200
 From: Manuel Carrasco <mc...@gmail.com>
 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8
 MIME-Version: 1.0
-To: mcdodot@gmail.com
-Subject: ECS unencripted attachment
-X-ChiaraMail-Content-Pointer: 16 24
+To: hupa4ecs@gmail.com
+Subject: Include content
+X-ChiaraMail-Content-Pointer: 48
 X-ChiaraMail-Content-Server-Name: www.chiaramail.com
 X-ChiaraMail-Content-Server-Port: 443
-Content-Type: multipart/mixed;
- boundary="------------020706090302030909010608"
-
-This is a multi-part message in MIME format.
---------------020706090302030909010608
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
-This message was sent using ECS technology 
-(http://en.wikipedia.org/wiki/Envelope-content_splitting), but your mail 
-client does not support ECS. Please download and install the appropriate 
-ECS-enabling software for your mail client 
-(http://www.chiaramail.com/download_extension.html) to read this message.
-
---------------020706090302030909010608
-Content-Type: application/pdf;
- name="TRATAMIENTOS TERMAEUROPA 2013.pdf"
-Content-Transfer-Encoding: base64
-Content-Disposition: attachment;
- filename="TRATAMIENTOS TERMAEUROPA 2013.pdf"
-
-VGhpcyBtZXNzYWdlIHdhcyBzZW50IHVzaW5nIEVDUyB0ZWNobm9sb2d5IChodHRwOi8vZW4u
-d2lraXBlZGlhLm9yZy93aWtpL0VudmVsb3BlLWNvbnRlbnRfc3BsaXR0aW5nKSwgYnV0IHlv
-dXIgbWFpbCBjbGllbnQgZG9lcyBub3Qgc3VwcG9ydCBFQ1MuIFBsZWFzZSBkb3dubG9hZCBh
-bmQgaW5zdGFsbCB0aGUgYXBwcm9wcmlhdGUgRUNTLWVuYWJsaW5nIHNvZnR3YXJlIGZvciB5
-b3VyIG1haWwgY2xpZW50IChodHRwOi8vd3d3LmNoaWFyYW1haWwuY29tL2Rvd25sb2FkX2V4
-dGVuc2lvbi5odG1sKSB0byByZWFkIHRoaXMgbWVzc2FnZS4=
---------------020706090302030909010608--
+Hello world included

Modified: james/hupa/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/pom.xml?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/pom.xml (original)
+++ james/hupa/trunk/pom.xml Sun Mar  2 12:12:22 2014
@@ -39,6 +39,7 @@
         <module>server</module>
         <module>widgets</module>
         <module>client</module>
+        <module>hupa</module>
     </modules>
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/james/hupa/trunk</connection>
@@ -59,9 +60,11 @@
         <gwtVersion>2.5.1</gwtVersion>
         <gwtMavenVersion>2.5.1</gwtMavenVersion>
         <gwt.moduleSuffix />
-        <gwt.logLevel>ERROR</gwt.logLevel>
+        <gwt.logLevel>INFO</gwt.logLevel>
         <jettyVersion>7.3.0.v20110203</jettyVersion>
         <mock.scope>test</mock.scope>
+        <skipTests>true</skipTests>
+        <gwt.disableRunAsync>true</gwt.disableRunAsync>
     </properties>
 
     <profiles>
@@ -83,6 +86,12 @@
         </properties>
       </profile>
       <profile>
+        <id>test</id>
+        <properties>
+          <skipTests>false</skipTests>
+        </properties>
+      </profile>
+      <profile>
         <id>clos</id>
         <properties>
           <gwt.enableClosureCompiler>true</gwt.enableClosureCompiler>
@@ -92,10 +101,8 @@
         </properties>
       </profile>
       <profile>
-        <!-- Deliver Hupa with Demo stuff -->
         <id>pretty</id>
         <properties>
-          <gwt.moduleSuffix>Prod</gwt.moduleSuffix>
           <gwt.style>PRETTY</gwt.style>
           <mock.scope />
           <gwt.logLevel>TRACE</gwt.logLevel>
@@ -113,6 +120,11 @@
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
+                <artifactId>hupa-client</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
                 <artifactId>hupa-server</artifactId>
                 <version>${project.version}</version>
             </dependency>
@@ -128,6 +140,11 @@
                 <scope>provided</scope>
             </dependency>
             <dependency>
+                <groupId>commons-lang</groupId>
+                <artifactId>commons-lang</artifactId>
+                <version>2.6</version>
+            </dependency>
+            <dependency>
                 <groupId>commons-logging</groupId>
                 <artifactId>commons-logging</artifactId>
                 <version>1.1.1</version>
@@ -311,6 +328,12 @@
                 <version>${jettyVersion}</version>
                 <scope>provided</scope>
             </dependency>
+            <dependency>
+                <groupId>com.googlecode.gwtquery</groupId>
+                <artifactId>gwtquery</artifactId>
+                <version>1.4.1-SNAPSHOT</version>
+                <scope>provided</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -333,6 +356,12 @@
             <name>Cobogw repository at googlecode</name>
             <url>http://cobogw.googlecode.com/svn/maven2</url>
         </repository>
+        <repository>
+           <id>sonatype</id>
+           <url>http://oss.sonatype.org/content/repositories/snapshots</url>
+           <snapshots><enabled>true</enabled></snapshots>
+           <releases><enabled>false</enabled></releases>
+        </repository>
     </repositories>
     <build>
         <pluginManagement>
@@ -369,21 +398,5 @@
                 </plugin>
             </plugins>
         </pluginManagement>
-        <plugins>
-<!--         See https://issues.apache.org/jira/browse/HUPA-81 -->
-<!--             <plugin>       -->
-<!--                 <groupId>org.codehaus.mojo</groupId> -->
-<!--                 <artifactId>emma-maven-plugin</artifactId> -->
-<!--                 <inherited>true</inherited>           -->
-<!--                 <executions> -->
-<!--                     <execution> -->
-<!--                         <phase>process-classes</phase>                -->
-<!--                         <goals> -->
-<!--                             <goal>instrument</goal> -->
-<!--                         </goals> -->
-<!--                     </execution> -->
-<!--                 </executions> -->
-<!--             </plugin> -->
-        </plugins>
     </build>
 </project>

Modified: james/hupa/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/pom.xml?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/pom.xml (original)
+++ james/hupa/trunk/server/pom.xml Sun Mar  2 12:12:22 2014
@@ -80,6 +80,12 @@
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
+        <!-- needed for ECS -->
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.6</version>
+        </dependency>
         <dependency>
             <groupId>com.google.code.guice</groupId>
             <artifactId>guice</artifactId>
@@ -110,6 +116,20 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <!-- ECS specific stuff
+            ECS encryption needs oracle crypto extension to work
+                http://www.oracle.com/technetwork/es/java/javase/downloads/jce-6-download-429243.html
+                http://www.oracle.com/technetwork/es/java/javase/downloads/jce-7-download-432124.html
+         -->
+        <dependency>
+             <groupId>org.bouncycastle</groupId>
+             <artifactId>bcprov-ext-jdk14</artifactId>
+             <version>1.49</version>
+        </dependency>
+        <dependency>
+             <groupId>commons-lang</groupId>
+             <artifactId>commons-lang</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <outputDirectory>war/WEB-INF/classes</outputDirectory>
@@ -130,6 +150,18 @@
                     <warName>${project.name}</warName>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.2</version>
+                <executions>
+                    <execution>
+                    <goals>
+                        <goal>test-jar</goal>
+                    </goals>
+                    </execution>
+                </executions>
+            </plugin>            
         </plugins>
     </build>
 </project>

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/CachedIMAPStore.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/CachedIMAPStore.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/CachedIMAPStore.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/CachedIMAPStore.java Sun Mar  2 12:12:22 2014
@@ -20,6 +20,7 @@
 package org.apache.hupa.server;
 
 import javax.mail.MessagingException;
+import javax.mail.Session;
 
 import com.sun.mail.imap.IMAPStore;
 
@@ -27,7 +28,8 @@ public class CachedIMAPStore {
     private long validUntil;
     private int validForMillis;
     private IMAPStore store;
-    
+    private Session session;
+
     private CachedIMAPStore() {
     }
     
@@ -55,4 +57,12 @@ public class CachedIMAPStore {
     public IMAPStore getStore() {
         return store;
     }
+    
+    public Session getSession() {
+        return session;
+    }
+
+    public void setSession(Session session) {
+        this.session = session;
+    }    
 }
\ No newline at end of file

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/IMAPStoreCache.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/IMAPStoreCache.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/IMAPStoreCache.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/IMAPStoreCache.java Sun Mar  2 12:12:22 2014
@@ -19,20 +19,18 @@
 
 package org.apache.hupa.server;
 
+import javax.mail.Message;
 import javax.mail.MessagingException;
-import javax.mail.NoSuchProviderException;
 import javax.mail.Session;
-import javax.mail.Transport;
 
 import org.apache.hupa.shared.domain.User;
 
 import com.sun.mail.imap.IMAPStore;
 
 public interface IMAPStoreCache {
-    public void delete(String username);
-    public void delete(User user);
-    public IMAPStore get(String username,String password) throws MessagingException;
-    public IMAPStore get(User user) throws MessagingException;
-    public Transport getMailTransport(boolean useSSL) throws NoSuchProviderException;
-    public Session getMailSession();
+    void delete(String username);
+    void delete(User user);
+    IMAPStore get(User user) throws MessagingException;
+    Session getMailSession(User user);
+    void sendMessage(Message msg) throws MessagingException;
 }

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/InMemoryIMAPStoreCache.java Sun Mar  2 12:12:22 2014
@@ -23,68 +23,61 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+import javax.mail.Authenticator;
+import javax.mail.Message;
 import javax.mail.MessagingException;
 import javax.mail.NoSuchProviderException;
+import javax.mail.PasswordAuthentication;
 import javax.mail.Session;
 import javax.mail.Transport;
 
 import org.apache.commons.logging.Log;
+import org.apache.hupa.shared.domain.Settings;
 import org.apache.hupa.shared.domain.User;
 
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.google.inject.name.Named;
+import com.sun.mail.iap.ProtocolException;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPFolder.ProtocolCommand;
 import com.sun.mail.imap.IMAPStore;
+import com.sun.mail.imap.protocol.IMAPProtocol;
+import com.sun.mail.imap.protocol.ListInfo;
 
 @Singleton
 public class InMemoryIMAPStoreCache implements IMAPStoreCache {
 
-    protected Session session;
-    protected Log logger;
-    private final Map<String, CachedIMAPStore> pool = new HashMap<String ,CachedIMAPStore>();
-    private String address;
-    private int port;
-    private boolean useSSL = false;
+    private final Map<String, CachedIMAPStore> pool = new HashMap<String, CachedIMAPStore>();
+    
+    private Log logger;
+    private int connectionPoolSize;
+    private int timeout;
+    private boolean debug;
+    private boolean trustSSL;
     
     @Inject
-    public InMemoryIMAPStoreCache(Log logger,
-            @Named("IMAPServerAddress") String address,
-            @Named("IMAPServerPort") int port, 
-            @Named("IMAPS") boolean useSSL,
-            @Named("IMAPConnectionPoolSize") int connectionPoolSize,
-            @Named("IMAPConnectionPoolTimeout") int timeout,
-            @Named("SessionDebug") boolean debug,
-            @Named("TrustStore") String truststore,
+    public InMemoryIMAPStoreCache(
+            Log logger, 
+            @Named("IMAPConnectionPoolSize") int connectionPoolSize, 
+            @Named("IMAPConnectionPoolTimeout") int timeout, 
+            @Named("SessionDebug") boolean debug, 
+            @Named("TrustStore") String truststore, 
             @Named("TrustStorePassword") String truststorePassword,
-            Session session) {
+            @Named("TrustSSL") boolean trustSSL)
+    {
         this.logger = logger;
-        this.address = address;
-        this.port = port;
-        this.useSSL = useSSL;
-        this.session = session;
-        if (debug && logger.isDebugEnabled()) {
-            this.session.setDebug(true);
+        this.connectionPoolSize = connectionPoolSize;
+        this.timeout = timeout;
+        this.debug = debug;
+        this.trustSSL = trustSSL;
+        if (!truststore.isEmpty()) {
+            System.setProperty("javax.net.ssl.trustStore", truststore);
         }
-        
-        Properties props = session.getProperties();
-        
-        props.setProperty("mail.mime.decodetext.strict", "false");
-        if (useSSL) {
-            props.setProperty("mail.store.protocol", "imaps");
-            props.setProperty("mail.imaps.connectionpoolsize", connectionPoolSize +"");
-            props.setProperty("mail.imaps.connectionpooltimeout", timeout + "");
-            if (!truststore.isEmpty()) {
-                System.setProperty("javax.net.ssl.trustStore", truststore);
-            }
-            if (!truststorePassword.isEmpty()) {
-                System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
-            }
-        } else {
-            props.setProperty("mail.imap.connectionpoolsize", connectionPoolSize + "");
-            props.setProperty("mail.imap.connectionpooltimeout", timeout + "");
+        if (!truststorePassword.isEmpty()) {
+            System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
         }
         System.setProperty("mail.mime.decodetext.strict", "false");
-      
     }
     
     /*
@@ -92,57 +85,91 @@ public class InMemoryIMAPStoreCache impl
      * @see org.apache.hupa.server.IMAPStoreCache#get(org.apache.hupa.shared.data.User)
      */
     public IMAPStore get(User user) throws MessagingException {
-    	IMAPStore ret =  get(user.getName(),user.getPassword());
+        // FIXME, there will be a NullPointerException thrown here when user session expired
     	
-    	// TODO: this is a hack, we should have a default domain suffix in configuration files
-    	if (address.contains("gmail.com") && !user.getName().contains("@")) {
-    		user.setName(user.getName() + "@gmail.com");
-    	}
-    	return ret;
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.apache.hupa.server.IMAPStoreCache#get(java.lang.String, java.lang.String)
-     */
-    public IMAPStore get(String username, String password) throws MessagingException {
-
-        CachedIMAPStore cstore = pool.get(username);
+        String id = user.getId();
+    	String username = user.getName();
+    	String password = user.getPassword();
+    	Settings settings = user.getSettings();
 
+    	CachedIMAPStore cstore = pool.get(username);
         if (cstore == null) {
             logger.debug("No cached store found for user " +username);
-            cstore = createCachedIMAPStore();
         } else {
             if (cstore.isExpired() == false) {
                 try {
                     cstore.validate();
                 } catch (MessagingException e) {
-                    cstore = createCachedIMAPStore();
                 }
             } else {
                 pool.remove(username);
                 try {
-                    if (cstore != null) cstore.getStore().close();
+                    cstore.getStore().close();
+                    cstore = null;
                 } catch (MessagingException e) {
-                    // ignore on close
                 }
-                cstore = createCachedIMAPStore();
             }
         }
         
+        if (cstore == null) {
+            cstore = createCachedIMAPStore(user);
+        }
+        
         if (cstore.getStore().isConnected() == false) {
-            try {
-                cstore.getStore().connect(address, port, username, password);
-            } catch (MessagingException e) {
-                    throw (e);
-            }
+            cstore.getStore().connect(settings.getImapServer(), settings.getImapPort(), id, password);
         }
+
         pool.put(username, cstore);
-        return cstore.getStore();
+        IMAPStore ret = cstore.getStore();
+
+    	// TODO: this is a hack for gmail
+    	if (settings.getImapServer().contains("gmail.com")) {
+    	    internationalizeGmailFolders(user, ret); 
+    	}
+    	
+    	return ret;
+    }
+    
+    public void internationalizeGmailFolders(User user, IMAPStore store) {
+        // TODO: this is a hack, we should have a default domain suffix in configuration files
+        if (!user.getName().contains("@")) {
+            user.setName(user.getName() + "@gmail.com");
+        }
+        try {
+            final IMAPFolder folder = (IMAPFolder) store.getDefaultFolder();
+            final char c = folder.getSeparator();
+
+            ListInfo[] li = (ListInfo[])folder.doCommandIgnoreFailure(new ProtocolCommand() {
+                                public Object doCommand(IMAPProtocol p) throws ProtocolException {
+                                    String arg = folder.getFullName() + c + "*";
+                                    return p.lsub("", arg);
+                                }
+                            });
+            
+            for (ListInfo l : li) {
+                if (l.attrs != null && l.attrs.length > 1) {
+                    // * LIST (\HasNoChildren \Drafts) "/" "[Gmail]/Borradores"
+                    String n = l.attrs[1];
+                    if ("\\Drafts".equals(n)) {
+                        user.getSettings().setDraftsFolderName(l.name);
+                    } else if ("\\Sent".equals(n)) {
+                        user.getSettings().setSentFolderName(l.name);
+                    } else if ("\\Trash".equals(n)) {
+                        user.getSettings().setTrashFolderName(l.name);
+                    } else if ("\\Junk".equals(n)) {
+                    }
+                }
+            }
+        } catch (Exception e) {
+        }
     }
     
-    public CachedIMAPStore createCachedIMAPStore() throws NoSuchProviderException {
-        return new CachedIMAPStore((IMAPStore)session.getStore(useSSL ? "imaps" : "imap"),300);
+    public CachedIMAPStore createCachedIMAPStore(User user) throws NoSuchProviderException {
+        Session ses = createSession(user);
+        IMAPStore store = (IMAPStore)ses.getStore(user.getSettings().getImapSecure() ? "imaps" : "imap");
+        CachedIMAPStore ret = new CachedIMAPStore(store, 300);
+        ret.setSession(ses);
+        return ret;
     }
     
     /*
@@ -169,12 +196,80 @@ public class InMemoryIMAPStoreCache impl
         pool.remove(username);
     }
 
-    public Transport getMailTransport(boolean useSSL) throws NoSuchProviderException {
-        return session.getTransport(useSSL ? "smtps" : "smtp");
+    public void sendMessage(Message msg) throws MessagingException {
+        Transport.send(msg);
     }
 
-    public Session getMailSession() {
-        return session;
+    public Session getMailSession(User user) {
+        CachedIMAPStore cstore = pool.get(user.getName());
+        return cstore.getSession();
     }
+    
+    private Session createSession(final User user) {
+        Properties props = new Properties();
+        Settings settings = user.getSettings();
+
+        props.setProperty("mail.mime.decodetext.strict", "false");
+        if (settings.getImapSecure()) {
+            props.setProperty("mail.store.protocol", "imaps");
+            props.setProperty("mail.imaps.connectionpoolsize", connectionPoolSize + "");
+            props.setProperty("mail.imaps.connectionpooltimeout", timeout + "");
+            if (trustSSL) {
+                props.setProperty("mail.imaps.ssl.trust", settings.getImapServer());
+            }
+        } else {
+            props.setProperty("mail.imap.connectionpoolsize", connectionPoolSize + "");
+            props.setProperty("mail.imap.connectionpooltimeout", timeout + "");
+        }
+        
+        if (settings.getSmtpSecure()) {
+            if (settings.getSmtpPort() == 587) {
+                props.setProperty("mail.smtp.starttls.enable", "true");
+                props.setProperty("mail.transport.protocol.rfc822", "smtp");
+            } else {
+                props.setProperty("mail.transport.protocol.rfc822", "smtps");
+                props.setProperty("mail.smtps.ssl.enable", "true");
+                if (trustSSL) {
+                    props.setProperty("mail.smtps.ssl.trust", settings.getSmtpServer());
+                }
+            }
+        } else {
+            props.setProperty("mail.transport.protocol.rfc822", "smtp");
+        }
 
+        props.setProperty("mail.smtp.host", settings.getSmtpServer());
+        props.setProperty("mail.smtps.host", settings.getSmtpServer());
+        props.setProperty("mail.smtp.port", settings.getSmtpPort() + "");
+        props.setProperty("mail.smtps.port", settings.getSmtpPort() + "");
+
+        Authenticator auth = null;
+        if (settings.getSmtpAuth() && user.getPassword() != null && user.getName() != null) {
+            props.setProperty("mail.smtp.auth", "true");
+            props.setProperty("mail.smtps.auth", "true");
+            auth = new javax.mail.Authenticator() {
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    String userId = user.getId();
+                    StackTraceElement[] sElms = Thread.currentThread().getStackTrace();
+                    for (StackTraceElement e : sElms) {
+                        if (e.getClassName().equals(InMemoryIMAPStoreCache.class.getName()) && e.getMethodName().equals("get")) {
+                            // We try with the id part the second time (unix imap/smtp auth compatible)
+                            if (userId.matches(".*@.*")) {
+                                userId = userId.replaceFirst("@.*", "");
+                                user.setId(userId);
+                                break;
+                            } else {
+                                return null;
+                            }
+                        }
+                    }
+                    return new PasswordAuthentication(userId, user.getPassword());
+                }
+            };
+        }
+        
+        Session ses = Session.getInstance(props, auth);
+        ses.setDebug(debug && logger.isDebugEnabled());
+        logger.debug("Created session " + user.getName() + "\n" + settings + "\n"+ props.toString().replaceAll(",", ",\n "));
+        return ses;
+    }
 }

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/DefaultUserSettingsProvider.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/DefaultUserSettingsProvider.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/DefaultUserSettingsProvider.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/DefaultUserSettingsProvider.java Sun Mar  2 12:12:22 2014
@@ -27,20 +27,19 @@ import com.google.inject.Provider;
 import com.google.inject.name.Named;
 
 public class DefaultUserSettingsProvider implements Provider<Settings> {
-    private String inboxFolder;
-    private String sentFolder;
-    private String trashFolder;
-    private String draftFolder;
-    private int postCount;
-
-    @Inject
-    public DefaultUserSettingsProvider(@Named("DefaultInboxFolder") String inboxFolder, @Named("DefaultSentFolder") String sentFolder, @Named("DefaultTrashFolder") String trashFolder, @Named("DefaultDraftsFolder") String draftFolder, @Named("PostFetchMessageCount") int postCount) {
-        this.inboxFolder = inboxFolder;
-        this.sentFolder = sentFolder;
-        this.trashFolder = trashFolder;
-        this.draftFolder = draftFolder;
-        this.postCount = postCount;
-    }
+    
+    @Inject @Named("DefaultInboxFolder") private String inboxFolder; 
+    @Inject @Named("DefaultSentFolder") private String sentFolder; 
+    @Inject @Named("DefaultTrashFolder") private String trashFolder; 
+    @Inject @Named("DefaultDraftsFolder") private String draftFolder; 
+    @Inject @Named("PostFetchMessageCount") private int postCount; 
+    @Inject @Named("IMAPServerAddress") private String imapAddress;
+    @Inject @Named("IMAPServerPort") private int imapPort; 
+    @Inject @Named("IMAPS") private boolean imapSSL;
+    @Inject @Named("SMTPServerAddress") private String smtpAddress;
+    @Inject @Named("SMTPServerPort") private int smtpPort;
+    @Inject @Named("SMTPS") private boolean smtpSSL;            
+    @Inject @Named("SMTPAuth") private boolean smtpAuth;
     
     /*
      * (non-Javadoc)
@@ -53,6 +52,13 @@ public class DefaultUserSettingsProvider
         settings.setTrashFolderName(trashFolder);
         settings.setDraftsFolderName(draftFolder);
         settings.setPostFetchMessageCount(postCount);
+        settings.setSmtpServer(smtpAddress);
+        settings.setSmtpPort(smtpPort);
+        settings.setSmtpSecure(smtpSSL);
+        settings.setImapServer(imapAddress);
+        settings.setImapPort(imapPort);
+        settings.setImapSecure(imapSSL);
+        settings.setSmtpAuth(smtpAuth);
         return settings;
     }
 

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceListener.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceListener.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceListener.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceListener.java Sun Mar  2 12:12:22 2014
@@ -42,8 +42,8 @@ public class GuiceListener extends Guice
 
 	private String servletContextRealPath = "";
 
-	private Properties demoProperties = null;
-	private String demoHostName = null;
+	protected Properties demoProperties = null;
+	protected String demoHostName = null;
 
 	@Override
 	public void contextInitialized(ServletContextEvent servletContextEvent) {
@@ -85,12 +85,12 @@ public class GuiceListener extends Guice
 	/**
 	 * Loads the first available configuration file.
 	 * 
-	 * The preference order for the file is: 1.- file specified in a system
-	 * property (-Dhupa.config.file=full_path_to_file) 2.- file in the user's
-	 * home: $HOME/.hupa/config.properties 3.- global configuration in the os:
-	 * /etc/default/hupa 4.- file provided in the .war distribution:
-	 * "WEB-INF/conf/config.properties 5.- mock properties file which makes the
-	 * Hupa work in demo mode.
+	 * The preference order for the file is: 
+	 * 1.- file specified in a system property (-Dhupa.config.file=full_path_to_file).
+	 * 2.- file in the user's home: $HOME/.hupa/config.properties.
+	 * 3.- global configuration in the os: /etc/default/hupa.
+	 * 4.- file provided in the .war distribution: "WEB-INF/conf/config.properties.
+	 * 5.- mock properties file which makes the Hupa work in demo mode.
 	 * 
 	 * If the system property "mock-host" has been defined, and Hupa has been
 	 * packaged with the mock stuff, we always return the demo-mode
@@ -107,12 +107,14 @@ public class GuiceListener extends Guice
 			configurationList.add(servletContextRealPath + "/" + CONFIG_DIR_IN_WAR + CONFIG_FILE_NAME);
 
 			for (String name : configurationList) {
+			    System.out.println(name);
 				properties = ConfigurationProperties.loadProperties(name);
 				if (properties != null) {
 					break;
 				}
 			}
 		}
+
 		return properties == null ? demoProperties : properties;
 	}
 }

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceServerModule.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceServerModule.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceServerModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceServerModule.java Sun Mar  2 12:12:22 2014
@@ -21,15 +21,11 @@ package org.apache.hupa.server.ioc;
 
 import java.util.Properties;
 
-import javax.mail.Session;
-
 import org.apache.commons.logging.Log;
 import org.apache.hupa.server.IMAPStoreCache;
 import org.apache.hupa.server.InMemoryIMAPStoreCache;
 import org.apache.hupa.server.guice.providers.DefaultUserSettingsProvider;
-import org.apache.hupa.server.guice.providers.JavaMailSessionProvider;
 import org.apache.hupa.server.guice.providers.LogProvider;
-import org.apache.hupa.server.preferences.InImapUserPreferencesStorage;
 import org.apache.hupa.server.preferences.InSessionUserPreferencesStorage;
 import org.apache.hupa.server.preferences.UserPreferencesStorage;
 import org.apache.hupa.server.service.CheckSessionService;
@@ -50,8 +46,6 @@ import org.apache.hupa.server.service.Ge
 import org.apache.hupa.server.service.GetMessageDetailsServiceImpl;
 import org.apache.hupa.server.service.GetMessageRawService;
 import org.apache.hupa.server.service.GetMessageRawServiceImpl;
-import org.apache.hupa.server.service.IdleService;
-import org.apache.hupa.server.service.IdleServiceImpl;
 import org.apache.hupa.server.service.ImapFolderService;
 import org.apache.hupa.server.service.ImapFolderServiceImpl;
 import org.apache.hupa.server.service.LoginUserService;
@@ -70,9 +64,6 @@ import org.apache.hupa.server.service.Se
 import org.apache.hupa.server.service.SendReplyMessageServiceImpl;
 import org.apache.hupa.server.service.SetFlagService;
 import org.apache.hupa.server.service.SetFlagServiceImpl;
-import org.apache.hupa.server.servlet.DownloadAttachmentServlet;
-import org.apache.hupa.server.servlet.MessageSourceServlet;
-import org.apache.hupa.server.servlet.UploadAttachmentServlet;
 import org.apache.hupa.shared.data.CreateFolderActionImpl;
 import org.apache.hupa.shared.data.DeleteFolderActionImpl;
 import org.apache.hupa.shared.data.DeleteMessageAllActionImpl;
@@ -84,8 +75,6 @@ import org.apache.hupa.shared.data.GetMe
 import org.apache.hupa.shared.data.GetMessageDetailsResultImpl;
 import org.apache.hupa.shared.data.GetMessageRawActionImpl;
 import org.apache.hupa.shared.data.GetMessageRawResultImpl;
-import org.apache.hupa.shared.data.IdleActionImpl;
-import org.apache.hupa.shared.data.IdleResultImpl;
 import org.apache.hupa.shared.data.ImapFolderImpl;
 import org.apache.hupa.shared.data.LogoutUserActionImpl;
 import org.apache.hupa.shared.data.MailHeaderImpl;
@@ -111,8 +100,6 @@ import org.apache.hupa.shared.domain.Get
 import org.apache.hupa.shared.domain.GetMessageDetailsResult;
 import org.apache.hupa.shared.domain.GetMessageRawAction;
 import org.apache.hupa.shared.domain.GetMessageRawResult;
-import org.apache.hupa.shared.domain.IdleAction;
-import org.apache.hupa.shared.domain.IdleResult;
 import org.apache.hupa.shared.domain.ImapFolder;
 import org.apache.hupa.shared.domain.LogoutUserAction;
 import org.apache.hupa.shared.domain.MailHeader;
@@ -148,6 +135,8 @@ public class GuiceServerModule extends A
 
 	@Override
 	protected void configure() {
+	    System.err.println("GuiceServerModule configuring beans.");
+	    
 		try {
 			// Bind addresses and ports for imap and smtp
 			Names.bindProperties(binder(), properties);
@@ -164,7 +153,7 @@ public class GuiceServerModule extends A
 		bind(MailHeader.class).to(MailHeaderImpl.class);
 		
 		bind(User.class).to(UserImpl.class);
-		bind(Settings.class).toProvider(DefaultUserSettingsProvider.class).in(Singleton.class);
+		bind(Settings.class).toProvider(DefaultUserSettingsProvider.class);
 		bind(ImapFolder.class).to(ImapFolderImpl.class);
 		bind(Tag.class).to(TagImpl.class);
 		bind(MessageDetails.class).to(MessageDetailsImpl.class);
@@ -186,43 +175,34 @@ public class GuiceServerModule extends A
 		bind(SendReplyMessageAction.class).to(SendReplyMessageActionImpl.class);
 		bind(GetMessageRawAction.class).to(GetMessageRawActionImpl.class);
 		bind(GetMessageRawResult.class).to(GetMessageRawResultImpl.class);
-		bind(IdleAction.class).to(IdleActionImpl.class);
-		bind(IdleResult.class).to(IdleResultImpl.class);
 		bind(LogoutUserAction.class).to(LogoutUserActionImpl.class);
 		bind(MoveMessageAction.class).to(MoveMessageActionImpl.class);
 		bind(SetFlagAction.class).to(SetFlagActionImpl.class);
 		
-		
+        bind(FetchMessagesService.class).to(FetchMessagesServiceImpl.class);
+		bind(SendMessageService.class).to(SendMessageBaseServiceImpl.class);
+		bind(SendForwardMessageService.class).to(SendForwardMessageServiceImpl.class);
+		bind(SendReplyMessageService.class).to(SendReplyMessageServiceImpl.class);
+        bind(GetMessageDetailsService.class).to(GetMessageDetailsServiceImpl.class);
+
 		
 		bind(CheckSessionService.class).to(CheckSessionServiceImpl.class);
 		bind(LoginUserService.class).to(LoginUserServiceImpl.class);
 		bind(ImapFolderService.class).to(ImapFolderServiceImpl.class);
 		bind(FetchFoldersService.class).to(FetchFoldersServiceImpl.class);
-		bind(FetchMessagesService.class).to(FetchMessagesServiceImpl.class);
 		bind(CreateFolderService.class).to(CreateFolderServiceImpl.class);
 		bind(DeleteFolderService.class).to(DeleteFolderServiceImpl.class);
 		bind(RenameFolderService.class).to(RenameFolderServiceImpl.class);
 		bind(DeleteMessageAllService.class).to(DeleteMessageAllServiceImpl.class);
 		bind(DeleteMessageByUidService.class).to(DeleteMessageByUidServiceImpl.class);
-		bind(GetMessageDetailsService.class).to(GetMessageDetailsServiceImpl.class);
-		bind(SendMessageService.class).to(SendMessageBaseServiceImpl.class);
-		bind(SendForwardMessageService.class).to(SendForwardMessageServiceImpl.class);
-		bind(SendReplyMessageService.class).to(SendReplyMessageServiceImpl.class);
 		bind(GetMessageRawService.class).to(GetMessageRawServiceImpl.class);
-		bind(IdleService.class).to(IdleServiceImpl.class);
 		bind(LogoutUserService.class).to(LogoutUserServiceImpl.class);
 		bind(MoveMessageService.class).to(MoveMessageServiceImpl.class);
 		bind(SetFlagService.class).to(SetFlagServiceImpl.class);
 		
 		bind(IMAPStoreCache.class).to(getIMAPStoreCacheClass()).in(Singleton.class);
 
-        bind(DownloadAttachmentServlet.class).in(Singleton.class);
-        bind(UploadAttachmentServlet.class).in(Singleton.class);
-        bind(MessageSourceServlet.class).in(Singleton.class);
-        
 		bind(Log.class).toProvider(LogProvider.class).in(Singleton.class);
-		bind(Session.class).toProvider(JavaMailSessionProvider.class);
-//        bind(UserPreferencesStorage.class).to(InImapUserPreferencesStorage.class);
         bind(UserPreferencesStorage.class).to(InSessionUserPreferencesStorage.class);
 		bind(Properties.class).toInstance(properties);
 	}

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java Sun Mar  2 12:12:22 2014
@@ -31,11 +31,18 @@ public class GuiceWebModule extends Serv
   
   @Override
   protected void configureServlets() {
+    System.err.println("GuiceWebModule configuring servlets.");
 
     bind(IocRfServlet.class).in(Singleton.class);
-    serve("/gwtRequest").with(IocRfServlet.class);
-    serve("/" + SConsts.HUPA + SConsts.SERVLET_DOWNLOAD).with(DownloadAttachmentServlet.class);
-    serve("/" + SConsts.HUPA + SConsts.SERVLET_UPLOAD).with(UploadAttachmentServlet.class);
-    serve("/" + SConsts.HUPA + SConsts.SERVLET_SOURCE).with(MessageSourceServlet.class);
+    serveRegex(".*/gwtRequest").with(IocRfServlet.class);
+    
+    bind(DownloadAttachmentServlet.class).in(Singleton.class);
+    serveRegex(".*/" + SConsts.HUPA + SConsts.SERVLET_DOWNLOAD).with(DownloadAttachmentServlet.class);
+    
+    bind(UploadAttachmentServlet.class).in(Singleton.class);
+    serveRegex(".*/" + SConsts.HUPA + SConsts.SERVLET_UPLOAD).with(UploadAttachmentServlet.class);
+    
+    bind(MessageSourceServlet.class).in(Singleton.class);
+    serveRegex(".*/" + SConsts.HUPA + SConsts.SERVLET_SOURCE).with(MessageSourceServlet.class);
   }
 }

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java Sun Mar  2 12:12:22 2014
@@ -19,6 +19,10 @@
 
 package org.apache.hupa.server.ioc;
 
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.web.bindery.requestfactory.server.ServiceLayerDecorator;
@@ -51,7 +55,28 @@ public final class IocRfServiceDecorator
 
     @Override
     public <T> T createDomainObject(Class<T> clazz) {
-        System.out.println("Create domain " + clazz);
         return injector.getInstance(clazz);
     }
+    
+    static int count = 0;
+    @Override
+    public Object invoke(Method domainMethod, Object... args) {
+        int n = count ++;
+        long start = System.currentTimeMillis();
+        boolean doLog = !"login".equals(domainMethod.getName());
+        if (doLog) System.out.println(n + " >>>>>>>>> Invoking  RF "  + domainMethod.getDeclaringClass() + " >>" + domainMethod.getName() + " " + new ArrayList<Object>(Arrays.asList(args)));
+        Object ret = null;
+        try {
+            ret =  super.invoke(domainMethod, args);
+        } catch (Throwable e) {
+            long l = System.currentTimeMillis() - start;
+            e.printStackTrace();
+            if (doLog) System.out.println(n + " << " + String.format("%6d", l) +" Returning RF ERROR "  + domainMethod.getDeclaringClass().getSimpleName() + " <<" + domainMethod.getName() + " " + new ArrayList<Object>(Arrays.asList(args)));
+            throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
+        } finally {
+            long l = System.currentTimeMillis() - start;
+            if (doLog) System.out.println(n + " << " + String.format("%6d", l) +" Returning RF "  + domainMethod.getDeclaringClass().getSimpleName() + " <<" + domainMethod.getName() + " " + new ArrayList<Object>(Arrays.asList(args)));
+        }
+        return ret;
+    }
 }
\ No newline at end of file

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java Sun Mar  2 12:12:22 2014
@@ -22,14 +22,16 @@ package org.apache.hupa.server.ioc.demo;
 import java.lang.reflect.Constructor;
 import java.util.Properties;
 
+import javax.mail.Message;
+import javax.mail.MessagingException;
 import javax.mail.NoSuchProviderException;
 import javax.mail.Session;
-import javax.mail.Transport;
 
 import org.apache.commons.logging.Log;
 import org.apache.hupa.server.CachedIMAPStore;
 import org.apache.hupa.server.IMAPStoreCache;
 import org.apache.hupa.server.InMemoryIMAPStoreCache;
+import org.apache.hupa.shared.domain.User;
 
 import com.google.inject.Inject;
 import com.google.inject.name.Named;
@@ -42,6 +44,7 @@ public class DemoGuiceServerModule exten
 
     public DemoGuiceServerModule(Properties properties) {
         super(properties);
+        new RuntimeException().printStackTrace();
     }
     
     protected Class<? extends IMAPStoreCache> getIMAPStoreCacheClass() {
@@ -59,46 +62,41 @@ public class DemoGuiceServerModule exten
      */
     public static class DemoIMAPStoreCache extends InMemoryIMAPStoreCache {
         @Inject
-        public DemoIMAPStoreCache(Log logger,
-                @Named("IMAPServerAddress") String address,
-                @Named("IMAPServerPort") int port, 
-                @Named("IMAPS") boolean useSSL,
-                @Named("IMAPConnectionPoolSize") int connectionPoolSize,
-                @Named("IMAPConnectionPoolTimeout") int timeout,
-                @Named("SessionDebug") boolean debug,
-                @Named("TrustStore") String truststore,
+        public DemoIMAPStoreCache(Log logger, 
+                @Named("IMAPConnectionPoolSize") int connectionPoolSize, 
+                @Named("IMAPConnectionPoolTimeout") int timeout, 
+                @Named("SessionDebug") boolean debug, 
+                @Named("TrustStore") String truststore, 
                 @Named("TrustStorePassword") String truststorePassword,
-                Session session) {
-            super(logger, address, port, useSSL, connectionPoolSize, timeout,
-                    debug, truststore, truststorePassword, session);
+                @Named("TrustSSL") boolean trustSSL) {
+            super(logger, connectionPoolSize, timeout, debug, truststore, truststorePassword, trustSSL);
         }
 
         @Override
-        public CachedIMAPStore createCachedIMAPStore()
+        public CachedIMAPStore createCachedIMAPStore(User user)
                 throws NoSuchProviderException {
             try {
-                Class<?> clz = 
-                    Class.forName("org.apache.hupa.server.mock.MockIMAPStore");
-                Constructor<?> cons = clz.getConstructors()[0];
-                IMAPStore store = (IMAPStore) cons
-                        .newInstance(new Object[] { session });
+                Class<?> clz = Class.forName("org.apache.hupa.server.mock.MockIMAPStore");
+                Constructor<?> cons = clz.getConstructors()[1];
+                IMAPStore store = (IMAPStore) cons.newInstance(new Object[] { Session.getInstance(new Properties()) });
                 return new CachedIMAPStore(store, 300);
+            } catch (ClassNotFoundException e) {
             } catch (Exception e) {
+                e.printStackTrace();
             }
-            return super.createCachedIMAPStore();
+            return super.createCachedIMAPStore(user);
         }
-
+        
         @Override
-        public Transport getMailTransport(boolean useSSL)
-                throws NoSuchProviderException {
+        public void sendMessage(Message msg) throws MessagingException {
             try {
-                Class<?> clz = 
-                    Class.forName("org.apache.hupa.server.mock.MockSMTPTransport");
-                Constructor<?> cons = clz.getConstructors()[0];
-                return (Transport) cons.newInstance(new Object[] { session });
+                Class.forName("org.apache.hupa.server.mock.MockIMAPStore");
+                return;
+            } catch (ClassNotFoundException e) {
             } catch (Exception e) {
+                e.printStackTrace();
             }
-            return super.getMailTransport(useSSL);
+            super.sendMessage(msg);
         }
     }
 

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorage.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorage.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorage.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/InImapUserPreferencesStorage.java Sun Mar  2 12:12:22 2014
@@ -183,8 +183,6 @@ public class InImapUserPreferencesStorag
     
     private Log logger;
     
-    private Session session;
-
     private final IMAPStoreCache cache;
 
     private final Provider<HttpSession> sessionProvider;
@@ -197,7 +195,6 @@ public class InImapUserPreferencesStorag
         this.sessionProvider = sessionProvider;
         this.cache = cache;
         this.logger = logger;
-        this.session = cache.getMailSession();
     }
 
     /* (non-Javadoc)
@@ -282,7 +279,7 @@ public class InImapUserPreferencesStorag
         public void run(){
             try {
                 sleep(IMAP_SAVE_DELAY);
-                saveUserPreferencesInIMAP(logger, user, session, cache.get(user), folderName, subject, object);
+                saveUserPreferencesInIMAP(logger, user, cache.getMailSession(user), cache.get(user), folderName, subject, object);
             } catch (Exception e) {
                 logger.error("Error saving user's preferences: ", e);
             }

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java Sun Mar  2 12:12:22 2014
@@ -38,10 +38,11 @@ public abstract class AbstractService {
     @Inject protected Log logger;
 
 	protected User getUser() throws HupaException{
-
         User user = (User) httpSessionProvider.get().getAttribute(SConsts.USER_SESS_ATTR);
         if (user == null) {
-            throw new InvalidSessionException(getClass()+"User not found in session with id " + httpSessionProvider.get().getId());
+            throw new InvalidSessionException(getClass().getSimpleName()
+                    + User.NOT_FOUND
+                    + httpSessionProvider.get().getId());
         } else {
             return user;
         }

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/FetchFoldersServiceImpl.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/FetchFoldersServiceImpl.java?rev=1573291&r1=1573290&r2=1573291&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/FetchFoldersServiceImpl.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/FetchFoldersServiceImpl.java Sun Mar  2 12:12:22 2014
@@ -149,6 +149,7 @@ public class FetchFoldersServiceImpl ext
 		String delimiter;
 		ImapFolder iFolder = null;
 		try {
+		    new RuntimeException().printStackTrace();
 			System.out.println("Creating folder2: " + fullName + " for user: " + this.getUser());
 			delimiter = String.valueOf(folder.getSeparator());
 			iFolder = new ImapFolderImpl(fullName);



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