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 do...@apache.org on 2013/08/21 16:08:29 UTC

svn commit: r1516164 [13/20] - in /james/hupa/trunk: ./ client/ client/src/main/java/com/ client/src/main/java/com/google/ client/src/main/java/com/google/web/ client/src/main/java/com/google/web/bindery/ client/src/main/java/com/google/web/bindery/req...

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=1516164&r1=1516163&r2=1516164&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 Wed Aug 21 14:08:19 2013
@@ -19,11 +19,13 @@
 
 package org.apache.hupa.server.mock;
 
-import org.apache.hupa.shared.data.Settings;
-import org.apache.hupa.shared.data.User;
-
 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 org.apache.hupa.shared.domain.User;
+
 /**
  * Constants and properties used for mock mode
  */
@@ -31,8 +33,7 @@ public class MockConstants {
     
     public static String SESSION_ID = "MockID";
      
-    public final static Settings mockSettings = new Settings() {
-        private static final long serialVersionUID = 1L;
+    public final static Settings mockSettings = new SettingsImpl() {
         {
             setInboxFolderName(MockIMAPStore.MOCK_INBOX_FOLDER);
             setSentFolderName(MockIMAPStore.MOCK_SENT_FOLDER);
@@ -61,8 +62,7 @@ public class MockConstants {
         }
     };
 
-    public final static Settings mockUserSettings = new Settings() {
-        private static final long serialVersionUID = 1L;
+    public final static Settings mockUserSettings = new SettingsImpl() {
         {
             setInboxFolderName(MockIMAPStore.MOCK_INBOX_FOLDER);
             setSentFolderName(MockIMAPStore.MOCK_SENT_FOLDER);
@@ -71,8 +71,7 @@ public class MockConstants {
         }
     };
     
-    public final static User mockUser = new User() {
-        private static final long serialVersionUID = 1L;
+    public final static User mockUser = new UserImpl() {
         {
             setName(MockIMAPStore.MOCK_LOGIN);
             setPassword(MockIMAPStore.MOCK_LOGIN);

Modified: james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockHttpSession.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockHttpSession.java?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockHttpSession.java (original)
+++ james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockHttpSession.java Wed Aug 21 14:08:19 2013
@@ -50,8 +50,8 @@ public class MockHttpSession implements 
     }
 
     
-    @SuppressWarnings("unchecked")
-    public Enumeration getAttributeNames() {
+    @SuppressWarnings("rawtypes")
+	public Enumeration getAttributeNames() {
         return new Enumeration() {
             Iterator it = attributeMap.keySet().iterator();
             public boolean hasMoreElements() {

Modified: james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPFolder.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPFolder.java?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPFolder.java (original)
+++ james/hupa/trunk/mock/src/main/java/org/apache/hupa/server/mock/MockIMAPFolder.java Wed Aug 21 14:08:19 2013
@@ -306,11 +306,11 @@ public class MockIMAPFolder extends IMAP
         Message[] array = new Message[ints.length];
 
         for (int i = 0; i < ints.length; i++) {
-            int mInt = ints[i] - 1;
-            if (mInt > messages.size() || mInt < messages.size()) {
+            int mInt = ints[i];
+            if (mInt > messages.size() || mInt < 0) {
                 throw new MessagingException();
             }
-            array[i] = messages.get(i);
+            array[i] = messages.get(ints[i]);
         }
         return array;
     }

Modified: james/hupa/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/pom.xml?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/pom.xml (original)
+++ james/hupa/trunk/pom.xml Wed Aug 21 14:08:19 2013
@@ -27,7 +27,7 @@
     </parent>
     <groupId>org.apache.james.hupa</groupId>
     <artifactId>hupa-parent</artifactId>
-    <version>0.0.4-SNAPSHOT</version>
+    <version>0.0.5-SNAPSHOT</version>
     <packaging>pom</packaging>
     <name>Apache James Hupa Parent</name>
     <description>Hupa is a GWT based Webmail</description>
@@ -56,8 +56,8 @@
         </site>
     </distributionManagement>
     <properties>
-        <gwtVersion>2.4.0</gwtVersion>
-        <gwtMavenVersion>2.4.0</gwtMavenVersion>
+        <gwtVersion>2.5.1</gwtVersion>
+        <gwtMavenVersion>2.5.1</gwtMavenVersion>
         <gwt.moduleSuffix />
         <gwt.logLevel>ERROR</gwt.logLevel>
         <jettyVersion>7.3.0.v20110203</jettyVersion>
@@ -73,17 +73,26 @@
           <gwt.disableClassMetadata>true</gwt.disableClassMetadata>
           <gwt.disableCastChecking>true</gwt.disableCastChecking>
           <gwt.logLevel>TRACE</gwt.logLevel>
+          <gwt.compileReport>true</gwt.compileReport>
         </properties>
       </profile>
       <profile>
-        <!-- Deliver Hupa with Demo stuff -->
         <id>demo</id>
         <properties>
           <mock.scope />
         </properties>
       </profile>
       <profile>
-        <!-- Print readable js -->
+        <id>clos</id>
+        <properties>
+          <gwt.enableClosureCompiler>true</gwt.enableClosureCompiler>
+          <gwt.disableRunAsync>true</gwt.disableRunAsync>
+          <gwt.compileReport>false</gwt.compileReport>
+          <gwt.logLevel>ERROR</gwt.logLevel>
+        </properties>
+      </profile>
+      <profile>
+        <!-- Deliver Hupa with Demo stuff -->
         <id>pretty</id>
         <properties>
           <gwt.moduleSuffix>Prod</gwt.moduleSuffix>

Modified: james/hupa/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/pom.xml?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/pom.xml (original)
+++ james/hupa/trunk/server/pom.xml Wed Aug 21 14:08:19 2013
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.james.hupa</groupId>
         <artifactId>hupa-parent</artifactId>
-        <version>0.0.4-SNAPSHOT</version>
+        <version>0.0.5-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>hupa-server</artifactId>
@@ -69,11 +69,6 @@
             <artifactId>mail</artifactId>
         </dependency>
         <dependency>
-            <groupId>net.customware.gwt.dispatch
-        </groupId>
-            <artifactId>gwt-dispatch</artifactId>
-        </dependency>
-        <dependency>
             <groupId>com.googlecode.gwtupload</groupId>
             <artifactId>gwtupload</artifactId>
         </dependency>
@@ -107,6 +102,10 @@
             <scope>runtime</scope>
         </dependency>
         <dependency>
+            <groupId>com.google.gwt</groupId>
+            <artifactId>gwt-dev</artifactId>
+        </dependency>
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>

Added: james/hupa/trunk/server/src/main/java/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java?rev=1516164&view=auto
==============================================================================
--- james/hupa/trunk/server/src/main/java/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java (added)
+++ james/hupa/trunk/server/src/main/java/com/google/web/bindery/requestfactory/server/ResolverServiceLayer.java Wed Aug 21 14:08:19 2013
@@ -0,0 +1,263 @@
+/*
+ * Copyright 2010 Google Inc.
+ * 
+ * Licensed 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.
+ */
+package com.google.web.bindery.requestfactory.server;
+
+import com.google.gwt.dev.asm.Type;
+import com.google.web.bindery.autobean.vm.impl.TypeUtils;
+import com.google.web.bindery.requestfactory.shared.BaseProxy;
+import com.google.web.bindery.requestfactory.shared.ProxyFor;
+import com.google.web.bindery.requestfactory.shared.ProxyForName;
+import com.google.web.bindery.requestfactory.shared.RequestContext;
+import com.google.web.bindery.requestfactory.shared.RequestFactory;
+import com.google.web.bindery.requestfactory.shared.Service;
+import com.google.web.bindery.requestfactory.shared.ServiceName;
+import com.google.web.bindery.requestfactory.vm.impl.Deobfuscator;
+import com.google.web.bindery.requestfactory.vm.impl.OperationKey;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Implements all of the resolution methods in ServiceLayer.
+ */
+final class ResolverServiceLayer extends ServiceLayerDecorator {
+
+  private static Deobfuscator deobfuscator;
+
+  private static synchronized void updateDeobfuscator(Class<? extends RequestFactory> clazz,
+      ClassLoader resolveClassesWith) {
+    Deobfuscator.Builder builder = Deobfuscator.Builder.load(clazz, resolveClassesWith);
+    if (deobfuscator != null) {
+      builder.merge(deobfuscator);
+    }
+    deobfuscator = builder.build();
+  }
+
+  @Override
+  public ClassLoader getDomainClassLoader() {
+    return Thread.currentThread().getContextClassLoader();
+  }
+
+  @Override
+  public Class<? extends BaseProxy> resolveClass(String typeToken) {
+    String deobfuscated = deobfuscator.getTypeFromToken(typeToken);
+    if (deobfuscated == null) {
+      die(null, "No type for token %s", typeToken);
+    }
+
+    return forName(deobfuscated).asSubclass(BaseProxy.class);
+  }
+
+  @Override
+  public <T> Class<? extends T> resolveClientType(Class<?> domainClass, Class<T> clientClass,
+      boolean required) {
+    if (List.class.isAssignableFrom(domainClass)) {
+      return List.class.asSubclass(clientClass);
+    }
+    if (Set.class.isAssignableFrom(domainClass)) {
+      return Set.class.asSubclass(clientClass);
+    }
+    if (TypeUtils.isValueType(domainClass)) {
+      return domainClass.asSubclass(clientClass);
+    }
+    
+    List<Class<?>> classes = new ArrayList<Class<?>>();
+    Class<?> clazz = domainClass;
+    while (clazz != null) {
+      classes.add(clazz);
+      clazz = clazz.getSuperclass();
+    }
+    classes.addAll(Arrays.asList(domainClass.getInterfaces()));
+    
+    for (Class<?> toSearch : classes) {
+      List<String> clientTypes = deobfuscator.getClientProxies(toSearch.getName());
+      if (clientTypes != null) {
+        for (String clientType : clientTypes) {
+          Class<?> proxy = forName(clientType);
+          if (clientClass.isAssignableFrom(proxy)) {
+            return proxy.asSubclass(clientClass);
+          }
+        }
+      }
+    }
+    
+    if (required) {
+      die(null, "The domain type %s cannot be sent to the client", domainClass.getCanonicalName());
+    }
+    return null;
+  }
+
+  @Override
+  public Class<?> resolveDomainClass(Class<?> clazz) {
+    if (List.class.equals(clazz)) {
+      return List.class;
+    } else if (Set.class.equals(clazz)) {
+      return Set.class;
+    } else if (BaseProxy.class.isAssignableFrom(clazz)) {
+      ProxyFor pf = clazz.getAnnotation(ProxyFor.class);
+      if (pf != null) {
+        return pf.value();
+      }
+      ProxyForName pfn = clazz.getAnnotation(ProxyForName.class);
+      if (pfn != null) {
+        Class<?> toReturn = forName(pfn.value());
+        return toReturn;
+      }
+    }
+    return die(null, "Could not resolve a domain type for client type %s", clazz.getCanonicalName());
+  }
+
+  @Override
+  public Method resolveDomainMethod(String operation) {
+    /*
+     * The validator has already determined the mapping from the RequsetContext
+     * method to a domain method signature. We'll reuse this calculation instead
+     * of iterating over all methods.
+     */
+    String domainDescriptor = deobfuscator.getDomainMethodDescriptor(operation);
+
+    if (domainDescriptor == null) {
+      return die(null, "No domain method descriptor is mapped to operation %s", operation);
+    }
+
+    Class<?>[] domainArgs = getArgumentTypes(domainDescriptor);
+    Class<? extends RequestContext> requestContext = getTop().resolveRequestContext(operation);
+    Class<?> serviceImplementation = getTop().resolveServiceClass(requestContext);
+
+    // Request<FooProxy> someMethod(int a, double b, FooProxy c);
+    Method requestContextMethod = getTop().resolveRequestContextMethod(operation);
+
+    Throwable ex;
+    try {
+      return serviceImplementation.getMethod(requestContextMethod.getName(), domainArgs);
+    } catch (SecurityException e) {
+      ex = e;
+    } catch (NoSuchMethodException e) {
+      ex = e;
+    }
+
+    return die(ex,
+        "Could not find method in implementation %s matching descriptor %s for operation %s",
+        serviceImplementation.getCanonicalName(), domainDescriptor, operation);
+  }
+
+  @Override
+  public Class<? extends RequestContext> resolveRequestContext(String operation) {
+    String requestContextClass = deobfuscator.getRequestContext(operation);
+    if (requestContextClass == null) {
+      die(null, "No RequestContext for operation %s", operation);
+    }
+    return forName(requestContextClass).asSubclass(RequestContext.class);
+  }
+
+  @Override
+  public Method resolveRequestContextMethod(String operation) {
+    Class<?> searchIn = getTop().resolveRequestContext(operation);
+    String methodName = deobfuscator.getRequestContextMethodName(operation);
+    String descriptor = deobfuscator.getRequestContextMethodDescriptor(operation);
+    Class<?>[] params = getArgumentTypes(descriptor);
+    try {
+      return searchIn.getMethod(methodName, params);
+    } catch (NoSuchMethodException ex) {
+      return report("Could not locate %s operation %s", RequestContext.class.getSimpleName(),
+          operation);
+    }
+  }
+
+  @Override
+  public Class<? extends RequestFactory> resolveRequestFactory(String binaryName) {
+    Class<? extends RequestFactory> toReturn = forName(binaryName).asSubclass(RequestFactory.class);
+    updateDeobfuscator(toReturn, getTop().getDomainClassLoader());
+    return toReturn;
+  }
+
+  @Override
+  public Class<?> resolveServiceClass(Class<? extends RequestContext> requestContextClass) {
+    Class<?> searchIn = null;
+    Service s = requestContextClass.getAnnotation(Service.class);
+    if (s != null) {
+      searchIn = s.value();
+    }
+    ServiceName sn = requestContextClass.getAnnotation(ServiceName.class);
+    if (sn != null) {
+      searchIn = forName(sn.value());
+    }
+    if (searchIn == null) {
+      die(null, "The %s type %s did not specify a service type", RequestContext.class
+          .getSimpleName(), requestContextClass.getCanonicalName());
+    }
+    return searchIn;
+  }
+
+  @Override
+  public String resolveTypeToken(Class<? extends BaseProxy> clazz) {
+    return OperationKey.hash(clazz.getName());
+  }
+
+  /**
+   * Call {@link Class#forName(String)} and report any errors through
+   * {@link #die()}.
+   */
+  private Class<?> forName(String name) {
+    try {
+      return Class.forName(name, false, getTop().getDomainClassLoader());
+    } catch (ClassNotFoundException e) {
+      return die(e, "Could not locate class %s", name);
+    }
+  }
+
+  private Class<?>[] getArgumentTypes(String descriptor) {
+    Type[] types = Type.getArgumentTypes(descriptor);
+    Class<?>[] params = new Class<?>[types.length];
+    for (int i = 0, j = types.length; i < j; i++) {
+      params[i] = getClass(types[i]);
+    }
+    return params;
+  }
+
+  private Class<?> getClass(Type type) {
+    switch (type.getSort()) {
+      case Type.BOOLEAN:
+        return boolean.class;
+      case Type.BYTE:
+        return byte.class;
+      case Type.CHAR:
+        return char.class;
+      case Type.DOUBLE:
+        return double.class;
+      case Type.FLOAT:
+        return float.class;
+      case Type.INT:
+        return int.class;
+      case Type.LONG:
+        return long.class;
+      case Type.OBJECT:
+        return forName(type.getClassName());
+      case Type.SHORT:
+        return short.class;
+      case Type.VOID:
+        return void.class;
+      case Type.ARRAY:
+        return die(null, "Unsupported Type used in operation descriptor %s", type.getDescriptor());
+      default:
+        // Error in this switch statement
+        return die(null, "Unhandled Type: %s", type.getDescriptor());
+    }
+  }
+}

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=1516164&r1=1516163&r2=1516164&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 Wed Aug 21 14:08:19 2013
@@ -1,3 +1,22 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
 package org.apache.hupa.server;
 
 import javax.mail.MessagingException;

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=1516164&r1=1516163&r2=1516164&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 Wed Aug 21 14:08:19 2013
@@ -24,7 +24,7 @@ import javax.mail.NoSuchProviderExceptio
 import javax.mail.Session;
 import javax.mail.Transport;
 
-import org.apache.hupa.shared.data.User;
+import org.apache.hupa.shared.domain.User;
 
 import com.sun.mail.imap.IMAPStore;
 

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=1516164&r1=1516163&r2=1516164&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 Wed Aug 21 14:08:19 2013
@@ -29,7 +29,7 @@ import javax.mail.Session;
 import javax.mail.Transport;
 
 import org.apache.commons.logging.Log;
-import org.apache.hupa.shared.data.User;
+import org.apache.hupa.shared.domain.User;
 
 import com.google.inject.Inject;
 import com.google.inject.Singleton;

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java Wed Aug 21 14:08:19 2013
@@ -21,7 +21,6 @@ package org.apache.hupa.server.guice;
 
 
 import org.apache.hupa.server.servlet.DownloadAttachmentServlet;
-import org.apache.hupa.server.servlet.HupaDispatchServlet;
 import org.apache.hupa.server.servlet.MessageSourceServlet;
 import org.apache.hupa.server.servlet.UploadAttachmentServlet;
 import org.apache.hupa.shared.SConsts;
@@ -32,7 +31,6 @@ import com.google.inject.servlet.Servlet
 public class DispatchServletModule extends ServletModule{
      @Override
         public void configureServlets() {
-             serve("/" + SConsts.HUPA + SConsts.SERVLET_DISPATCH).with(HupaDispatchServlet.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);

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=1516164&r1=1516163&r2=1516164&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 Wed Aug 21 14:08:19 2013
@@ -19,7 +19,8 @@
 
 package org.apache.hupa.server.guice.providers;
 
-import org.apache.hupa.shared.data.Settings;
+import org.apache.hupa.shared.data.SettingsImpl;
+import org.apache.hupa.shared.domain.Settings;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -46,7 +47,7 @@ public class DefaultUserSettingsProvider
      * @see com.google.inject.Provider#get()
      */
     public Settings get() {
-        Settings settings = new Settings();
+        Settings settings = new SettingsImpl();
         settings.setInboxFolderName(inboxFolder);
         settings.setSentFolderName(sentFolder);
         settings.setTrashFolderName(trashFolder);

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/HttpSessionProvider.java (from r1375909, james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/ReplyMessage.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/HttpSessionProvider.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/HttpSessionProvider.java&p1=james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/ReplyMessage.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/ReplyMessage.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/HttpSessionProvider.java Wed Aug 21 14:08:19 2013
@@ -1,38 +1,35 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-
-
-package org.apache.hupa.shared.rpc;
-
-import org.apache.hupa.shared.data.IMAPFolder;
-import org.apache.hupa.shared.data.SMTPMessage;
-
-public class ReplyMessage extends ForwardMessage {
-
-    private static final long serialVersionUID = -383135476236902779L;
-
-    
-    public ReplyMessage(SMTPMessage msg, IMAPFolder folder, long uid) {
-    	super(msg, folder, uid);
-    }
-
-    protected ReplyMessage() {
-    }
-    
-}
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.guice.providers;
+
+
+import javax.servlet.http.HttpSession;
+
+import com.google.inject.Provider;
+import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
+
+public class HttpSessionProvider implements Provider<HttpSession>{
+
+	@Override
+    public HttpSession get() {
+		return RequestFactoryServlet.getThreadLocalRequest().getSession();
+    }
+
+}

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java Wed Aug 21 14:08:19 2013
@@ -17,7 +17,6 @@
  * under the License.                                           *
  ****************************************************************/
 
-
 package org.apache.hupa.server.guice.providers;
 
 import org.apache.commons.logging.Log;

Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/JavamailUtil.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/JavamailUtil.java?rev=1516164&r1=1516163&r2=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/JavamailUtil.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/JavamailUtil.java Wed Aug 21 14:08:19 2013
@@ -24,7 +24,7 @@ import java.util.ArrayList;
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
-import org.apache.hupa.shared.data.Message.IMAPFlag;
+import org.apache.hupa.shared.data.MessageImpl.IMAPFlag;
 
 /**
  * Util class which helps to convert from hupa internal data representation to javamaill classes

Added: 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=1516164&view=auto
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceListener.java (added)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceListener.java Wed Aug 21 14:08:19 2013
@@ -0,0 +1,118 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.ioc;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.ServletContextEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.hupa.server.ioc.demo.DemoGuiceServerModule;
+import org.apache.hupa.server.utils.ConfigurationProperties;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.servlet.GuiceServletContextListener;
+
+public class GuiceListener extends GuiceServletContextListener {
+
+	public static final String SYS_PROP_CONFIG_FILE = "hupa.config.file";
+	public static final String CONFIG_FILE_NAME = "config.properties";
+	public static final String CONFIG_DIR_IN_WAR = "WEB-INF/conf/";
+
+	private String servletContextRealPath = "";
+
+	private Properties demoProperties = null;
+	private String demoHostName = null;
+
+	@Override
+	public void contextInitialized(ServletContextEvent servletContextEvent) {
+		servletContextRealPath = servletContextEvent.getServletContext().getRealPath("/");
+
+		// We get the mock classes using reflection, so as we can package Hupa
+		// without mock stuff.
+		try {
+			Class<?> mockConstants = Class.forName("org.apache.hupa.server.mock.MockConstants");
+			demoProperties = (Properties) mockConstants.getField("mockProperties").get(null);
+			demoHostName = demoProperties.getProperty("IMAPServerAddress");
+		} catch (Exception noDemoAvailable) {
+		}
+
+		super.contextInitialized(servletContextEvent);
+	}
+
+	@Override
+	protected Injector getInjector() {
+
+		Properties prop = loadProperties();
+		ConfigurationProperties.validateProperties(prop);
+
+		boolean demo = prop.getProperty("IMAPServerAddress").equals(demoHostName);
+		Module module = demo ? new DemoGuiceServerModule(prop) : new GuiceServerModule(prop);
+
+		Injector injector = Guice.createInjector(module, new GuiceWebModule());
+
+		String msg = ">> Started HUPA ";
+		if (demo) {
+			msg += "in DEMO-MODE";
+		} else {
+			msg += "with configuration -> " + prop;
+		}
+		injector.getInstance(Log.class).info(msg);
+		return injector;
+	}
+
+	/**
+	 * 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.
+	 * 
+	 * If the system property "mock-host" has been defined, and Hupa has been
+	 * packaged with the mock stuff, we always return the demo-mode
+	 * configuration.
+	 * 
+	 */
+	public Properties loadProperties() {
+		Properties properties = null;
+		if (demoHostName == null || System.getProperty(demoHostName) == null) {
+			List<String> configurationList = new ArrayList<String>();
+			configurationList.add(System.getProperty(SYS_PROP_CONFIG_FILE));
+			configurationList.add(System.getenv("HOME") + "/.hupa/" + CONFIG_FILE_NAME);
+			configurationList.add("/etc/default/hupa");
+			configurationList.add(servletContextRealPath + "/" + CONFIG_DIR_IN_WAR + CONFIG_FILE_NAME);
+
+			for (String name : configurationList) {
+				properties = ConfigurationProperties.loadProperties(name);
+				if (properties != null) {
+					break;
+				}
+			}
+		}
+		return properties == null ? demoProperties : properties;
+	}
+}

Added: 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=1516164&view=auto
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceServerModule.java (added)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceServerModule.java Wed Aug 21 14:08:19 2013
@@ -0,0 +1,231 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+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.UserPreferencesStorage;
+import org.apache.hupa.server.service.CheckSessionService;
+import org.apache.hupa.server.service.CheckSessionServiceImpl;
+import org.apache.hupa.server.service.CreateFolderService;
+import org.apache.hupa.server.service.CreateFolderServiceImpl;
+import org.apache.hupa.server.service.DeleteFolderService;
+import org.apache.hupa.server.service.DeleteFolderServiceImpl;
+import org.apache.hupa.server.service.DeleteMessageAllService;
+import org.apache.hupa.server.service.DeleteMessageAllServiceImpl;
+import org.apache.hupa.server.service.DeleteMessageByUidService;
+import org.apache.hupa.server.service.DeleteMessageByUidServiceImpl;
+import org.apache.hupa.server.service.FetchFoldersService;
+import org.apache.hupa.server.service.FetchFoldersServiceImpl;
+import org.apache.hupa.server.service.FetchMessagesService;
+import org.apache.hupa.server.service.FetchMessagesServiceImpl;
+import org.apache.hupa.server.service.GetMessageDetailsService;
+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;
+import org.apache.hupa.server.service.LoginUserServiceImpl;
+import org.apache.hupa.server.service.LogoutUserService;
+import org.apache.hupa.server.service.LogoutUserServiceImpl;
+import org.apache.hupa.server.service.MoveMessageService;
+import org.apache.hupa.server.service.MoveMessageServiceImpl;
+import org.apache.hupa.server.service.RenameFolderService;
+import org.apache.hupa.server.service.RenameFolderServiceImpl;
+import org.apache.hupa.server.service.SendForwardMessageService;
+import org.apache.hupa.server.service.SendForwardMessageServiceImpl;
+import org.apache.hupa.server.service.SendMessageBaseServiceImpl;
+import org.apache.hupa.server.service.SendMessageService;
+import org.apache.hupa.server.service.SendReplyMessageService;
+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;
+import org.apache.hupa.shared.data.DeleteMessageByUidActionImpl;
+import org.apache.hupa.shared.data.FetchMessagesActionImpl;
+import org.apache.hupa.shared.data.FetchMessagesResultImpl;
+import org.apache.hupa.shared.data.GenericResultImpl;
+import org.apache.hupa.shared.data.GetMessageDetailsActionImpl;
+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;
+import org.apache.hupa.shared.data.MessageAttachmentImpl;
+import org.apache.hupa.shared.data.MessageDetailsImpl;
+import org.apache.hupa.shared.data.MoveMessageActionImpl;
+import org.apache.hupa.shared.data.RenameFolderActionImpl;
+import org.apache.hupa.shared.data.SendForwardMessageActionImpl;
+import org.apache.hupa.shared.data.SendMessageActionImpl;
+import org.apache.hupa.shared.data.SendReplyMessageActionImpl;
+import org.apache.hupa.shared.data.SetFlagActionImpl;
+import org.apache.hupa.shared.data.SmtpMessageImpl;
+import org.apache.hupa.shared.data.TagImpl;
+import org.apache.hupa.shared.data.UserImpl;
+import org.apache.hupa.shared.domain.CreateFolderAction;
+import org.apache.hupa.shared.domain.DeleteFolderAction;
+import org.apache.hupa.shared.domain.DeleteMessageAllAction;
+import org.apache.hupa.shared.domain.DeleteMessageByUidAction;
+import org.apache.hupa.shared.domain.FetchMessagesAction;
+import org.apache.hupa.shared.domain.FetchMessagesResult;
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.GetMessageDetailsAction;
+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;
+import org.apache.hupa.shared.domain.MessageAttachment;
+import org.apache.hupa.shared.domain.MessageDetails;
+import org.apache.hupa.shared.domain.MoveMessageAction;
+import org.apache.hupa.shared.domain.RenameFolderAction;
+import org.apache.hupa.shared.domain.SendForwardMessageAction;
+import org.apache.hupa.shared.domain.SendMessageAction;
+import org.apache.hupa.shared.domain.SendReplyMessageAction;
+import org.apache.hupa.shared.domain.SetFlagAction;
+import org.apache.hupa.shared.domain.Settings;
+import org.apache.hupa.shared.domain.SmtpMessage;
+import org.apache.hupa.shared.domain.Tag;
+import org.apache.hupa.shared.domain.User;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+import com.google.inject.name.Names;
+import com.google.web.bindery.requestfactory.server.DefaultExceptionHandler;
+import com.google.web.bindery.requestfactory.server.ExceptionHandler;
+import com.google.web.bindery.requestfactory.server.ServiceLayerDecorator;
+
+/**
+ */
+public class GuiceServerModule extends AbstractModule {
+
+	Properties properties;
+
+	public GuiceServerModule(Properties properties) {
+		this.properties = properties;
+	}
+
+	@Override
+	protected void configure() {
+		try {
+			// Bind addresses and ports for imap and smtp
+			Names.bindProperties(binder(), properties);
+		} catch (Exception e) {
+			throw new RuntimeException("Unable to to configure hupa server,"
+			        + "\nmake sure that you have a valid /etc/default/hupa file"
+			        + "\nor the web container has been started with the appropriate parameter:"
+			        + " -Dhupa.config.file=your_hupa_properties_file", e);
+		}
+		bind(ExceptionHandler.class).to(DefaultExceptionHandler.class);
+		bind(ServiceLayerDecorator.class).to(IocRfServiceDecorator.class);
+		bind(IocRfServiceLocator.class);
+		
+		bind(MailHeader.class).to(MailHeaderImpl.class);
+		
+		bind(User.class).to(UserImpl.class);
+		bind(Settings.class).toProvider(DefaultUserSettingsProvider.class).in(Singleton.class);
+		bind(ImapFolder.class).to(ImapFolderImpl.class);
+		bind(Tag.class).to(TagImpl.class);
+		bind(MessageDetails.class).to(MessageDetailsImpl.class);
+		bind(MessageAttachment.class).to(MessageAttachmentImpl.class);
+		bind(SmtpMessage.class).to(SmtpMessageImpl.class);
+		
+		bind(GenericResult.class).to(GenericResultImpl.class);
+		bind(FetchMessagesAction.class).to(FetchMessagesActionImpl.class);
+		bind(FetchMessagesResult.class).to(FetchMessagesResultImpl.class);
+		bind(CreateFolderAction.class).to(CreateFolderActionImpl.class);
+		bind(DeleteFolderAction.class).to(DeleteFolderActionImpl.class);
+		bind(RenameFolderAction.class).to(RenameFolderActionImpl.class);
+		bind(DeleteMessageAllAction.class).to(DeleteMessageAllActionImpl.class);
+		bind(DeleteMessageByUidAction.class).to(DeleteMessageByUidActionImpl.class);
+		bind(GetMessageDetailsAction.class).to(GetMessageDetailsActionImpl.class);
+		bind(GetMessageDetailsResult.class).to(GetMessageDetailsResultImpl.class);
+		bind(SendMessageAction.class).to(SendMessageActionImpl.class);
+		bind(SendForwardMessageAction.class).to(SendForwardMessageActionImpl.class);
+		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(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(Properties.class).toInstance(properties);
+	}
+
+	protected Class<? extends IMAPStoreCache> getIMAPStoreCacheClass() {
+		return InMemoryIMAPStoreCache.class;
+	}
+}

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java (from r1375909, james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java&p1=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/DispatchServletModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/GuiceWebModule.java Wed Aug 21 14:08:19 2013
@@ -17,24 +17,25 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.server.guice;
-
+package org.apache.hupa.server.ioc;
 
 import org.apache.hupa.server.servlet.DownloadAttachmentServlet;
-import org.apache.hupa.server.servlet.HupaDispatchServlet;
 import org.apache.hupa.server.servlet.MessageSourceServlet;
 import org.apache.hupa.server.servlet.UploadAttachmentServlet;
 import org.apache.hupa.shared.SConsts;
 
+import com.google.inject.Singleton;
 import com.google.inject.servlet.ServletModule;
 
-
-public class DispatchServletModule extends ServletModule{
-     @Override
-        public void configureServlets() {
-             serve("/" + SConsts.HUPA + SConsts.SERVLET_DISPATCH).with(HupaDispatchServlet.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);
-        }
+public class GuiceWebModule extends ServletModule {
+  
+  @Override
+  protected void configureServlets() {
+
+    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);
+  }
 }

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java (from r1375909, james/hupa/trunk/client/src/main/java/org/apache/hupa/client/rf/SubjectRequest.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java&p1=james/hupa/trunk/client/src/main/java/org/apache/hupa/client/rf/SubjectRequest.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/rf/SubjectRequest.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceDecorator.java Wed Aug 21 14:08:19 2013
@@ -16,25 +16,42 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.hupa.client.rf;
 
-import org.apache.hupa.server.rf.Subject;
+package org.apache.hupa.server.ioc;
 
-import com.google.web.bindery.requestfactory.shared.InstanceRequest;
-import com.google.web.bindery.requestfactory.shared.Request;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.web.bindery.requestfactory.server.ServiceLayerDecorator;
+import com.google.web.bindery.requestfactory.shared.Locator;
 import com.google.web.bindery.requestfactory.shared.RequestContext;
 import com.google.web.bindery.requestfactory.shared.Service;
+import com.google.web.bindery.requestfactory.shared.ServiceLocator;
 
-@Service(Subject.class)
-public interface SubjectRequest extends RequestContext {
-
-  Request<java.lang.Long> countSubjects();
-
-  Request<SubjectProxy> findSubject(Long id);
-
-  InstanceRequest<SubjectProxy, java.lang.Void> remove();
-
-  InstanceRequest<SubjectProxy, java.lang.Void> persist();
-
-  Request<String> echo(SubjectProxy subject, String from, String to);
-}
+public final class IocRfServiceDecorator extends ServiceLayerDecorator {
+    @Inject
+    private Injector injector;
+
+    @Override
+    public <T extends Locator<?, ?>> T createLocator(Class<T> clazz) {
+        return injector.getInstance(clazz);
+    }
+
+    @Override
+    public Object createServiceInstance(
+            Class<? extends RequestContext> requestContext) {
+        Class<? extends ServiceLocator> serviceLocatorClass;
+        if ((serviceLocatorClass = getTop().resolveServiceLocator(
+                requestContext)) != null) {
+            return injector.getInstance(serviceLocatorClass).getInstance(
+                    requestContext.getAnnotation(Service.class).value());
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public <T> T createDomainObject(Class<T> clazz) {
+        System.out.println("Create domain " + clazz);
+        return injector.getInstance(clazz);
+    }
+}
\ No newline at end of file

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceLocator.java (from r1375909, james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/ContactsPresenterPlace.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceLocator.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceLocator.java&p1=james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/ContactsPresenterPlace.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/place/ContactsPresenterPlace.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServiceLocator.java Wed Aug 21 14:08:19 2013
@@ -17,25 +17,25 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.client.mvp.place;
-
-import net.customware.gwt.presenter.client.gin.ProvidedPresenterPlace;
-
-import org.apache.hupa.client.mvp.ContactsPresenter;
+package org.apache.hupa.server.ioc;
 
 import com.google.inject.Inject;
-import com.google.inject.Provider;
-
-public class ContactsPresenterPlace extends ProvidedPresenterPlace<ContactsPresenter>{
-
-    @Inject
-    public ContactsPresenterPlace(Provider<ContactsPresenter> presenter) {
-        super(presenter);
-    }
+import com.google.inject.Injector;
+import com.google.web.bindery.requestfactory.shared.ServiceLocator;
 
-    @Override
-    public String getName() {
-        return "Contacts";
-    }
+/**
+ * This is Guice-injected ServiceLocator.  Use this class to provide dependency-injected
+ * instances of your RequestFactory services. When defining a new Request interface,
+ * set this in the locator attribute of the @Service annotation.
+ */
+public class IocRfServiceLocator implements ServiceLocator {
+
+  @Inject
+  private Injector injector;
+  
+  @Override
+  public Object getInstance(Class<?> clazz) {
+    return injector.getInstance(clazz);
+  }
 
-}
+}
\ No newline at end of file

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServlet.java (from r1375909, james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServlet.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServlet.java&p1=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/providers/LogProvider.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/IocRfServlet.java Wed Aug 21 14:08:19 2013
@@ -1,36 +1,42 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-
-
-package org.apache.hupa.server.guice.providers;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.Log4JLogger;
-
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-
-@Singleton
-public class LogProvider implements Provider<Log>{
-
-    public Log get() {
-        return new Log4JLogger("HupaLogger");
-    }
-
-}
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.ioc;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.web.bindery.requestfactory.server.ExceptionHandler;
+import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
+import com.google.web.bindery.requestfactory.server.ServiceLayerDecorator;
+
+/**
+ * This is a Guice-injected RequestFactoryServlet. Use this to replace the standard
+ * non-dependency-injected RequestFactory servlet.
+ */
+@Singleton
+public class IocRfServlet extends RequestFactoryServlet {
+
+  private static final long serialVersionUID = 1L;
+
+  @Inject
+  protected IocRfServlet(ExceptionHandler e, ServiceLayerDecorator d) {
+    super(e, d);
+  }
+
+}
\ No newline at end of file

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java (from r1375909, james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/demo/DemoGuiceServerModule.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java&p1=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/demo/DemoGuiceServerModule.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/guice/demo/DemoGuiceServerModule.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/ioc/demo/DemoGuiceServerModule.java Wed Aug 21 14:08:19 2013
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.server.guice.demo;
+package org.apache.hupa.server.ioc.demo;
 
 import java.lang.reflect.Constructor;
 import java.util.Properties;
@@ -30,7 +30,6 @@ 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.server.guice.GuiceServerModule;
 
 import com.google.inject.Inject;
 import com.google.inject.name.Named;
@@ -39,7 +38,7 @@ import com.sun.mail.imap.IMAPStore;
 /**
  * Module which binds the handlers and configurations for demo mode
  */
-public class DemoGuiceServerModule extends GuiceServerModule {
+public class DemoGuiceServerModule extends org.apache.hupa.server.ioc.GuiceServerModule {
 
     public DemoGuiceServerModule(Properties properties) {
         super(properties);

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=1516164&r1=1516163&r2=1516164&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 Wed Aug 21 14:08:19 2013
@@ -48,7 +48,7 @@ import org.apache.commons.io.output.Byte
 import org.apache.commons.logging.Log;
 import org.apache.hupa.server.IMAPStoreCache;
 import org.apache.hupa.server.utils.MessageUtils;
-import org.apache.hupa.shared.data.User;
+import org.apache.hupa.shared.domain.User;
 import org.apache.hupa.shared.rpc.ContactsResult.Contact;
 
 import com.google.inject.Inject;

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java (from r1375909, james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/SendMessageHandler.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java&p1=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/SendMessageHandler.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/handler/SendMessageHandler.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/AbstractService.java Wed Aug 21 14:08:19 2013
@@ -1,54 +1,49 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-
-package org.apache.hupa.server.handler;
-
-import javax.servlet.http.HttpSession;
-
-import org.apache.commons.logging.Log;
-import org.apache.hupa.server.IMAPStoreCache;
-import org.apache.hupa.server.preferences.UserPreferencesStorage;
-import org.apache.hupa.shared.rpc.SendMessage;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.name.Named;
-
-/**
- * Handler which handle sending of new messages
- * 
- *
- */
-public class SendMessageHandler extends AbstractSendMessageHandler<SendMessage> {
-
-    @Inject
-    public SendMessageHandler(Log logger, IMAPStoreCache store, Provider<HttpSession> provider, UserPreferencesStorage preferences,
-            @Named("SMTPServerAddress") String address, @Named("SMTPServerPort") int port, @Named("SMTPAuth") boolean auth, @Named("SMTPS") boolean useSSL) {
-        super(logger, store, provider, preferences, address, port, auth,useSSL);
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see net.customware.gwt.dispatch.server.ActionHandler#getActionType()
-     */
-    public Class<SendMessage> getActionType() {
-        return SendMessage.class;
-    }
-
-}
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.service;
+
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.hupa.server.IMAPStoreCache;
+import org.apache.hupa.shared.SConsts;
+import org.apache.hupa.shared.domain.User;
+import org.apache.hupa.shared.exception.HupaException;
+import org.apache.hupa.shared.exception.InvalidSessionException;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public abstract class AbstractService {
+	
+    @Inject protected IMAPStoreCache cache;
+    @Inject protected Provider<HttpSession> httpSessionProvider;
+    @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());
+        } else {
+            return user;
+        }
+	}
+}

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionService.java (from r1375909, james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/NameAwareWidgetDisplay.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionService.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionService.java&p1=james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/NameAwareWidgetDisplay.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/NameAwareWidgetDisplay.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionService.java Wed Aug 21 14:08:19 2013
@@ -1,30 +1,28 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-
-package org.apache.hupa.client.mvp;
-
-public interface NameAwareWidgetDisplay {
-
-    /**
-     * Return the name for the Display to show
-     * 
-     * @return name
-     */
-    public String getName();
-}
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.service;
+
+import org.apache.hupa.shared.domain.User;
+import org.apache.hupa.shared.exception.HupaException;
+
+public interface CheckSessionService {
+	public User getUser() throws HupaException;
+	public Boolean isValid() throws HupaException;
+}

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionServiceImpl.java (from r1375909, james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/NameAwareWidgetDisplay.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionServiceImpl.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionServiceImpl.java&p1=james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/NameAwareWidgetDisplay.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/client/src/main/java/org/apache/hupa/client/mvp/NameAwareWidgetDisplay.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CheckSessionServiceImpl.java Wed Aug 21 14:08:19 2013
@@ -1,30 +1,36 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-
-package org.apache.hupa.client.mvp;
-
-public interface NameAwareWidgetDisplay {
-
-    /**
-     * Return the name for the Display to show
-     * 
-     * @return name
-     */
-    public String getName();
-}
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.service;
+
+import org.apache.hupa.shared.SConsts;
+import org.apache.hupa.shared.domain.User;
+import org.apache.hupa.shared.exception.HupaException;
+
+public class CheckSessionServiceImpl extends AbstractService implements CheckSessionService {
+	
+	@Override
+	public User getUser() throws HupaException{
+        return (User) httpSessionProvider.get().getAttribute(SConsts.USER_SESS_ATTR);
+	}
+	
+	public Boolean isValid()  throws HupaException{
+		return getUser() != null && getUser().getAuthenticated();
+	}
+}

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderService.java (from r1375909, james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/Contacts.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderService.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderService.java&p1=james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/Contacts.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/Contacts.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderService.java Wed Aug 21 14:08:19 2013
@@ -17,12 +17,11 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.shared.rpc;
+package org.apache.hupa.server.service;
 
-import java.io.Serializable;
+import org.apache.hupa.shared.domain.CreateFolderAction;
+import org.apache.hupa.shared.domain.GenericResult;
 
-import net.customware.gwt.dispatch.shared.Action;
-
-public class Contacts implements Action<ContactsResult>, Serializable{
-    private static final long serialVersionUID = 1l;
+public interface CreateFolderService {
+	GenericResult create(CreateFolderAction action) throws Exception;
 }

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderServiceImpl.java (from r1375909, james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockImapFolderTest.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderServiceImpl.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderServiceImpl.java&p1=james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockImapFolderTest.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/server/src/test/java/org/apache/hupa/server/mock/MockImapFolderTest.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/CreateFolderServiceImpl.java Wed Aug 21 14:08:19 2013
@@ -1,46 +1,50 @@
-/****************************************************************
- * 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.                                           *
- ****************************************************************/
-package org.apache.hupa.server.mock;
-
-import java.net.URL;
-
-import javax.mail.Folder;
-import javax.mail.Message;
-
-import org.apache.hupa.server.HupaGuiceTestCase;
-
-public class MockImapFolderTest extends HupaGuiceTestCase {
-
-    public void testReadMessageFile() throws Exception {
-        URL url = Thread.currentThread().getContextClassLoader().getResource(MockIMAPFolder.MOCK_MESSAGES_LOCATION + "0.msg");
-        assertNotNull("There aren't message files for demo mode, check that the files mime/\\d.msg are in your classpath", url);
-    }
-    
-    public void testLoadMessageFiles() throws Exception {
-        MockIMAPStore store = new MockIMAPStore(session, null);
-        MockIMAPFolder folder = new MockIMAPFolder("WHATEVER", store);
-        folder.create(Folder.HOLDS_MESSAGES);
-        folder.loadDemoMessages(session);
-        assertTrue(folder.getMessages().length > 0);
-        for (Message m: folder.getMessages()) {
-            assertEquals(m, folder.getMessageByUID(folder.getUID(m)));
-        }
-    }
-
-}
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.hupa.server.service;
+
+import javax.mail.Folder;
+
+import org.apache.hupa.shared.data.GenericResultImpl;
+import org.apache.hupa.shared.domain.CreateFolderAction;
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.ImapFolder;
+import org.apache.hupa.shared.domain.User;
+
+import com.sun.mail.imap.IMAPStore;
+
+public class CreateFolderServiceImpl extends AbstractService implements CreateFolderService {
+
+	@Override
+	public GenericResult create(CreateFolderAction action) throws Exception {
+		User user = getUser();
+		ImapFolder folder = action.getFolder();
+		IMAPStore store = cache.get(user);
+		Folder f = store.getFolder(folder.getFullName());
+		if (f.create(Folder.HOLDS_MESSAGES)) {
+			logger.info("Successfully create folder " + folder + " for user " + user);
+			return new GenericResultImpl();
+		} else {
+			logger.info("Unable to create folder " + folder + " for user " + user);
+			throw new Exception("Unable to create folder " + folder + " for user " + user);
+
+		}
+	}
+
+}

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/DeleteFolderService.java (from r1375909, james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/Contacts.java)
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/DeleteFolderService.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/DeleteFolderService.java&p1=james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/Contacts.java&r1=1375909&r2=1516164&rev=1516164&view=diff
==============================================================================
--- james/hupa/trunk/shared/src/main/java/org/apache/hupa/shared/rpc/Contacts.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/DeleteFolderService.java Wed Aug 21 14:08:19 2013
@@ -17,12 +17,14 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.shared.rpc;
+package org.apache.hupa.server.service;
 
-import java.io.Serializable;
+import javax.mail.MessagingException;
 
-import net.customware.gwt.dispatch.shared.Action;
+import org.apache.hupa.shared.domain.DeleteFolderAction;
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.exception.HupaException;
 
-public class Contacts implements Action<ContactsResult>, Serializable{
-    private static final long serialVersionUID = 1l;
+public interface DeleteFolderService {
+	GenericResult delete(DeleteFolderAction action) throws HupaException, MessagingException;
 }

Copied: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/DeleteFolderServiceImpl.java (from r1375909, 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/service/DeleteFolderServiceImpl.java?p2=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/DeleteFolderServiceImpl.java&p1=james/hupa/trunk/server/src/main/java/org/apache/hupa/server/IMAPStoreCache.java&r1=1375909&r2=1516164&rev=1516164&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/service/DeleteFolderServiceImpl.java Wed Aug 21 14:08:19 2013
@@ -17,22 +17,42 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.server;
+package org.apache.hupa.server.service;
 
+import javax.mail.Folder;
 import javax.mail.MessagingException;
-import javax.mail.NoSuchProviderException;
-import javax.mail.Session;
-import javax.mail.Transport;
 
-import org.apache.hupa.shared.data.User;
+import org.apache.hupa.shared.data.GenericResultImpl;
+import org.apache.hupa.shared.domain.DeleteFolderAction;
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.ImapFolder;
+import org.apache.hupa.shared.domain.User;
+import org.apache.hupa.shared.exception.HupaException;
 
 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();
+public class DeleteFolderServiceImpl extends AbstractService implements DeleteFolderService {
+
+	@Override
+	public GenericResult delete(DeleteFolderAction action) throws HupaException, MessagingException {
+		User user = getUser();
+		ImapFolder folder = action.getFolder();
+		IMAPStore store = cache.get(user);
+
+		Folder f = store.getFolder(folder.getFullName());
+
+		// close the folder if its open
+		if (f.isOpen()) {
+			f.close(false);
+		}
+
+		// recursive delete the folder
+		if (f.delete(true)) {
+			logger.info("Successfully delete folder " + folder + " for user " + user);
+			return new GenericResultImpl();
+		} else {
+			throw new HupaException("Unable to delete folder " + folder + " for user " + user);
+		}
+	}
+
 }



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