labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r795712 - in /labs/hupa: ./ .settings/ src/main/java/org/apache/hupa/server/ src/main/java/org/apache/hupa/server/gin/ src/main/java/org/apache/hupa/server/guice/ war/ war/WEB-INF/classes/
Date Mon, 20 Jul 2009 07:50:47 GMT
Author: norman
Date: Mon Jul 20 07:50:46 2009
New Revision: 795712

URL: http://svn.apache.org/viewvc?rev=795712&view=rev
Log:
Add Logging (log4j/commons-logging)
Some refactoring for using protocol caching

Added:
    labs/hupa/src/main/java/org/apache/hupa/server/IMAPProtocolCache.java
    labs/hupa/src/main/java/org/apache/hupa/server/guice/LogProvider.java
    labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java
      - copied, changed from r795426, labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java
    labs/hupa/war/WEB-INF/classes/log4j.properties
Removed:
    labs/hupa/src/main/java/org/apache/hupa/server/AbstractIMAPActionHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/gin/
Modified:
    labs/hupa/.settings/com.google.gwt.eclipse.core.prefs
    labs/hupa/pom.xml
    labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/ExposeMessageHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/FetchFoldersHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/FetchMessagesHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/LoginUserHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/NoopHandler.java
    labs/hupa/src/main/java/org/apache/hupa/server/guice/MyGuiceServletConfig.java
    labs/hupa/war/Hupa.css

Modified: labs/hupa/.settings/com.google.gwt.eclipse.core.prefs
URL: http://svn.apache.org/viewvc/labs/hupa/.settings/com.google.gwt.eclipse.core.prefs?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/.settings/com.google.gwt.eclipse.core.prefs (original)
+++ labs/hupa/.settings/com.google.gwt.eclipse.core.prefs Mon Jul 20 07:50:46 2009
@@ -1,3 +1,3 @@
-#Sat Jun 06 15:54:29 CEST 2009
-eclipse.preferences.version=1
-filesCopiedToWebInfLib=gwt-servlet.jar
+#Fri Jul 17 09:21:22 CEST 2009
+eclipse.preferences.version=1
+filesCopiedToWebInfLib=gwt-servlet.jar

Modified: labs/hupa/pom.xml
URL: http://svn.apache.org/viewvc/labs/hupa/pom.xml?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/pom.xml (original)
+++ labs/hupa/pom.xml Mon Jul 20 07:50:46 2009
@@ -238,6 +238,30 @@
 	</profiles>
 
 	<dependencies>
+	    <dependency>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+          <version>1.1.1</version>
+          <exclusions>
+            <exclusion>
+              <groupId>logkit</groupId>
+              <artifactId>logkit</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>avalon-framework</groupId>
+              <artifactId>avalon-framework</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>javax.servlet</groupId>
+              <artifactId>servlet-api</artifactId>
+            </exclusion>
+          </exclusions>
+        </dependency>
+        <dependency>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+          <version>1.2.13</version>
+        </dependency>
 		<dependency>
 			<groupId>commons-lang</groupId>
 			<artifactId>commons-lang</artifactId>

Modified: labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java Mon Jul 20 07:50:46
2009
@@ -19,9 +19,11 @@
 
 package org.apache.hupa.server;
 
+import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
 import net.customware.gwt.dispatch.shared.ActionException;
 
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.rpc.DeleteMessage;
 import org.apache.hupa.shared.rpc.DeleteMessageResult;
@@ -29,12 +31,23 @@
 import org.columba.ristretto.imap.IMAPProtocol;
 import org.columba.ristretto.imap.SequenceSet;
 
-public class DeleteMessageHandler extends AbstractIMAPActionHandler<DeleteMessage, DeleteMessageResult>{
+import com.google.inject.Inject;
+
+public class DeleteMessageHandler implements ActionHandler<DeleteMessage, DeleteMessageResult>{
+
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public DeleteMessageHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
 
 	public DeleteMessageResult execute(DeleteMessage action, ExecutionContext context)
 			throws ActionException {
 		try {
-			IMAPProtocol protocol = getProtocol(action.getUser());
+			IMAPProtocol protocol = cache.getProtocol(action.getUser());
 			IMAPFolder folder = action.getFolder();
 			protocol.select(folder.getFullName());
 			
@@ -44,6 +57,7 @@
 			protocol.store(new SequenceSet(action.getMessageUids()), true, new IMAPFlags(IMAPFlags.DELETED));
 			protocol.expunge();
 		} catch (Exception e) {
+			logger.error("Error while deleting messages with uids + "+ action.getMessageUids() + "
for user " + action.getUser() + " in" + action.getFolder());
 			throw new ActionException("Error while deleting messages",e);
 		}
 		return new DeleteMessageResult();

Modified: labs/hupa/src/main/java/org/apache/hupa/server/ExposeMessageHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/ExposeMessageHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/ExposeMessageHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/ExposeMessageHandler.java Mon Jul 20 07:50:46
2009
@@ -19,15 +19,16 @@
 
 package org.apache.hupa.server;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
 import java.util.List;
 
+import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
 import net.customware.gwt.dispatch.shared.ActionException;
 
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPMessage;
 import org.apache.hupa.shared.data.IMAPMessageContent;
@@ -38,7 +39,6 @@
 import org.columba.ristretto.coder.Base64DecoderInputStream;
 import org.columba.ristretto.coder.CharsetDecoderInputStream;
 import org.columba.ristretto.coder.QuotedPrintableDecoderInputStream;
-import org.columba.ristretto.imap.IMAPException;
 import org.columba.ristretto.imap.IMAPFlags;
 import org.columba.ristretto.imap.IMAPProtocol;
 import org.columba.ristretto.imap.SequenceSet;
@@ -47,8 +47,18 @@
 import org.columba.ristretto.message.MimePart;
 import org.columba.ristretto.message.MimeTree;
 
-public class ExposeMessageHandler extends AbstractIMAPActionHandler<ExposeMessage, ExposeMessageResult>{
+import com.google.inject.Inject;
 
+public class ExposeMessageHandler implements ActionHandler<ExposeMessage, ExposeMessageResult>{
+
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public ExposeMessageHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
 	public ExposeMessageResult execute(ExposeMessage action, ExecutionContext arg1)
 			throws ActionException {
 			return new ExposeMessageResult(exposeMessage(action.getUser(), action.getFolder(), action.getMessage()));
@@ -71,15 +81,13 @@
 		}
 		IMAPProtocol proto = null;
 		try {
-			proto = getProtocol(user);
+			proto = cache.getProtocol(user);
 
 
 			proto.select(folder.getName());
 
 			IMAPMessageContent content = new IMAPMessageContent();
 
-			
-
 			MimeTree mTree = proto.uidFetchBodystructure(msg.getUid());
 
 			MimePart textPart = mTree.getFirstTextPart("plain");
@@ -142,13 +150,9 @@
 			}
 
 			return msg;
-		} catch (IOException e) {
-			e.printStackTrace();
-			throw new ActionException("Unable to expose msg for uid "
-					+ msg.getUid());
-		} catch (IMAPException e) {
-			e.printStackTrace();
-			throw new ActionException("Unable to expose msg for uid "
+		} catch (Exception e) {
+			logger.error("Unable to expose msg for user " + user + " in folder "+ folder + " with
uid "+ msg.getUid(),e);
+			throw new ActionException("Unable to expose msg for user " + user + " in folder "+ folder
+ " with uid "
 					+ msg.getUid());
 
 		} 

Modified: labs/hupa/src/main/java/org/apache/hupa/server/FetchFoldersHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/FetchFoldersHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/FetchFoldersHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/FetchFoldersHandler.java Mon Jul 20 07:50:46
2009
@@ -19,24 +19,35 @@
 
 package org.apache.hupa.server;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import net.customware.gwt.dispatch.server.ActionHandler;
+import net.customware.gwt.dispatch.server.ExecutionContext;
+import net.customware.gwt.dispatch.shared.ActionException;
+
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPUser;
 import org.apache.hupa.shared.rpc.FetchFolders;
 import org.apache.hupa.shared.rpc.FetchFoldersResult;
-import org.columba.ristretto.imap.IMAPException;
 import org.columba.ristretto.imap.IMAPProtocol;
 import org.columba.ristretto.imap.ListInfo;
 import org.columba.ristretto.imap.SearchKey;
 import org.columba.ristretto.message.MailboxInfo;
 
-import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
+import com.google.inject.Inject;
 
-public class FetchFoldersHandler extends AbstractIMAPActionHandler<FetchFolders, FetchFoldersResult>{
+public class FetchFoldersHandler implements  ActionHandler<FetchFolders, FetchFoldersResult>{
+	
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public FetchFoldersHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
 
 	public FetchFoldersResult execute(FetchFolders action, ExecutionContext arg1)
 	throws ActionException {
@@ -59,7 +70,7 @@
 		ArrayList<IMAPFolder> fList = new ArrayList<IMAPFolder>();
 		IMAPProtocol protocol = null;
 		try {
-			protocol = getProtocol(user);
+			protocol = cache.getProtocol(user);
 			ListInfo[] infos = protocol.list("", "*");
 
 			for (int i = 0; i < infos.length; i++) {
@@ -87,15 +98,11 @@
 				}
 			}
 			return fList;
-		} catch (IOException e) {
-			e.printStackTrace();
+		} catch (Exception e) {
+			logger.error("Unable to get folders for User " + user,e);
 			throw new ActionException("Unable to get folders for User "
 					+ user);
-		} catch (IMAPException e) {
-			e.printStackTrace();
-			throw new ActionException("Unable to get folders for User "
-					+ user);
-		} 
+		}
 	}
 	
 	private void handleIMAPFolderTree(List<IMAPFolder> fList,

Modified: labs/hupa/src/main/java/org/apache/hupa/server/FetchMessagesHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/FetchMessagesHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/FetchMessagesHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/FetchMessagesHandler.java Mon Jul 20 07:50:46
2009
@@ -19,15 +19,16 @@
 
 package org.apache.hupa.server;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
+import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
 import net.customware.gwt.dispatch.shared.ActionException;
 
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.data.IMAPFolder;
 import org.apache.hupa.shared.data.IMAPHeader;
 import org.apache.hupa.shared.data.IMAPMessage;
@@ -35,7 +36,6 @@
 import org.apache.hupa.shared.data.IMAPMessage.IMAPFlag;
 import org.apache.hupa.shared.rpc.FetchMessages;
 import org.apache.hupa.shared.rpc.FetchMessagesResult;
-import org.columba.ristretto.imap.IMAPException;
 import org.columba.ristretto.imap.IMAPFlags;
 import org.columba.ristretto.imap.IMAPProtocol;
 import org.columba.ristretto.imap.SearchKey;
@@ -44,8 +44,19 @@
 import org.columba.ristretto.message.BasicHeader;
 import org.columba.ristretto.message.MailboxInfo;
 
-public class FetchMessagesHandler extends AbstractIMAPActionHandler<FetchMessages, FetchMessagesResult>{
+import com.google.inject.Inject;
 
+public class FetchMessagesHandler implements ActionHandler<FetchMessages, FetchMessagesResult>{
+
+	
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public FetchMessagesHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
 	public FetchMessagesResult execute(FetchMessages action, ExecutionContext arg1)
 			throws ActionException {
 		return getMessages(action.getUser(), action.getFolder(), action.getStart(), action.getOffset(),
action.getSearchString());
@@ -67,7 +78,7 @@
 		int end = start + offset;
 		IMAPProtocol proto = null;
 		try {
-			proto = getProtocol(user);
+			proto = cache.getProtocol(user);
 			MailboxInfo mInfo = proto.select(folder.getFullName());
 
 			int exists = mInfo.getExists();
@@ -150,14 +161,10 @@
 				mList.add(0, msg);
 			}
 			return new FetchMessagesResult(mList,start,offset,exists);
-		} catch (IOException e) {
-			throw new ActionException(
-					"Error while fetching headers for user " + user.getName()
-							+ ": " + e.getMessage());
-		} catch (IMAPException e) {
+		} catch (Exception e) {
+			logger.error("Error while fetching headers for user " + user.getName() + " in folder "
+ folder,e);
 			throw new ActionException(
-					"Error while fetching headers for user " + user.getName()
-							+ ": " + e.getMessage());
+					"Error while fetching headers for user " + user.getName() + " in folder " + folder);
 		}
 	}
 }

Added: labs/hupa/src/main/java/org/apache/hupa/server/IMAPProtocolCache.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/IMAPProtocolCache.java?rev=795712&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/IMAPProtocolCache.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/server/IMAPProtocolCache.java Mon Jul 20 07:50:46
2009
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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 java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.hupa.shared.data.IMAPUser;
+import org.columba.ristretto.imap.IMAPException;
+import org.columba.ristretto.imap.IMAPProtocol;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class IMAPProtocolCache {
+
+	protected Log logger;
+	private final Map<String,IMAPProtocol> pool = new HashMap<String ,IMAPProtocol>();
+	
+	@Inject
+	public IMAPProtocolCache(Log logger) {
+		this.logger = logger;
+	}
+	
+	public synchronized IMAPProtocol getProtocol(IMAPUser user) throws IOException,
+			IMAPException {
+		IMAPProtocol protocol = pool.get(user.getName());
+		if (protocol == null) {
+			logger.debug("No cached protocol found for user " +user);
+			protocol = new IMAPProtocol("myblog.kicks-ass.org",
+					IMAPProtocol.DEFAULT_PORT);
+		} 
+		if (protocol.getState() == IMAPProtocol.NOT_CONNECTED) {
+			logger.debug("Protocol is not connected for user " +user);
+			protocol.openPort();	
+		}
+		if (protocol.getState() == IMAPProtocol.NON_AUTHENTICATED) {
+			logger.debug("Authenticate user " +user);
+			protocol.login(user.getName(), user.getPassword().toCharArray());
+		}
+		pool.put(user.getName(),protocol);
+		return protocol;
+	}
+	
+	public synchronized void deleteProcotol(IMAPUser user) {
+		IMAPProtocol protocol = pool.get(user.getName());
+		if (protocol.getState() == IMAPProtocol.AUTHENTICATED) {
+			try {
+				protocol.logout();
+			} catch (Exception e) {
+				logger.error("Error while logout user "+ user);
+			} 
+		}
+		pool.remove(user.getName());
+	}
+}

Modified: labs/hupa/src/main/java/org/apache/hupa/server/LoginUserHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/LoginUserHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/LoginUserHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/LoginUserHandler.java Mon Jul 20 07:50:46
2009
@@ -19,19 +19,30 @@
 
 package org.apache.hupa.server;
 
-import java.io.IOException;
 import java.util.Date;
 
+import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
 import net.customware.gwt.dispatch.shared.ActionException;
 
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.data.IMAPUser;
 import org.apache.hupa.shared.rpc.LoginUser;
 import org.apache.hupa.shared.rpc.LoginUserResult;
-import org.columba.ristretto.imap.IMAPException;
 
-public class LoginUserHandler extends
-		AbstractIMAPActionHandler<LoginUser, LoginUserResult> {
+import com.google.inject.Inject;
+
+public class LoginUserHandler implements
+		ActionHandler<LoginUser, LoginUserResult> {
+
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public LoginUserHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
 
 	public LoginUserResult execute(LoginUser action, ExecutionContext context)
 			throws ActionException {
@@ -56,15 +67,14 @@
 			IMAPUser user = new IMAPUser();
 			user.setName(username);
 			user.setPassword(password);
-			getProtocol(user);
+			cache.getProtocol(user);
 			
 			user.setLoginDate(new Date());
 			user.setAuthenticated(true);
 			return user;
 
-		} catch (IOException e) {
-			throw new ActionException(e);
-		} catch (IMAPException e) {
+		} catch (Exception e) {
+			logger.error("Unable to authenticate user " + username,e);
 			throw new ActionException(e);
 		}
 	}

Modified: labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java Mon Jul 20 07:50:46
2009
@@ -20,18 +20,28 @@
 
 package org.apache.hupa.server;
 
-import java.io.IOException;
-
+import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
 import net.customware.gwt.dispatch.shared.ActionException;
 
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.data.IMAPUser;
 import org.apache.hupa.shared.rpc.LogoutUser;
 import org.apache.hupa.shared.rpc.LogoutUserResult;
-import org.columba.ristretto.imap.IMAPException;
-import org.columba.ristretto.imap.IMAPProtocol;
 
-public class LogoutUserHandler extends AbstractIMAPActionHandler<LogoutUser, LogoutUserResult>
{
+import com.google.inject.Inject;
+
+public class LogoutUserHandler implements ActionHandler<LogoutUser, LogoutUserResult>
{
+	
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public LogoutUserHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
+
 
 	public LogoutUserResult execute(LogoutUser action, ExecutionContext arg1)
 			throws ActionException {
@@ -53,21 +63,7 @@
 	}
 	
 	protected void disconnect(IMAPUser user) {
-		try {
-			IMAPProtocol proto = getProtocol(user);
-			if (proto.getState() != IMAPProtocol.NOT_CONNECTED) {
-				proto.logout();
-			}
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} catch (IMAPException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-		synchronized (pool) {
-			pool.remove(user);
-		}
+		cache.deleteProcotol(user);
 	}
 
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/server/NoopHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/NoopHandler.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/NoopHandler.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/NoopHandler.java Mon Jul 20 07:50:46 2009
@@ -19,21 +19,35 @@
 
 package org.apache.hupa.server;
 
+import net.customware.gwt.dispatch.server.ActionHandler;
 import net.customware.gwt.dispatch.server.ExecutionContext;
 import net.customware.gwt.dispatch.shared.ActionException;
 
+import org.apache.commons.logging.Log;
 import org.apache.hupa.shared.rpc.Noop;
 import org.apache.hupa.shared.rpc.NoopResult;
 
-public class NoopHandler extends AbstractIMAPActionHandler<Noop, NoopResult>{
+import com.google.inject.Inject;
 
+public class NoopHandler implements ActionHandler<Noop, NoopResult>{
+
+	
+	private IMAPProtocolCache cache;
+	private Log logger;
+
+	@Inject
+	public NoopHandler(IMAPProtocolCache cache, Log logger) {
+		this.cache = cache;
+		this.logger = logger;
+	}
 	public NoopResult execute(Noop action, ExecutionContext context)
 			throws ActionException {
 		try {
-			getProtocol(action.getUser()).noop();
+			cache.getProtocol(action.getUser()).noop();
 			return new NoopResult();
 		} catch (Exception e) {
-			throw new ActionException("Unable to send NOOP",e);
+			logger.error("Error while sending NOOP for user " + action.getUser(),e);
+			throw new ActionException("Unable to send NOOP");
 		}
 		
 	}

Added: labs/hupa/src/main/java/org/apache/hupa/server/guice/LogProvider.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/guice/LogProvider.java?rev=795712&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/guice/LogProvider.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/server/guice/LogProvider.java Mon Jul 20 07:50:46
2009
@@ -0,0 +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.server.guice;
+
+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");
+	}
+
+}

Modified: labs/hupa/src/main/java/org/apache/hupa/server/guice/MyGuiceServletConfig.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/guice/MyGuiceServletConfig.java?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/guice/MyGuiceServletConfig.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/guice/MyGuiceServletConfig.java Mon Jul
20 07:50:46 2009
@@ -19,7 +19,6 @@
 
 package org.apache.hupa.server.guice;
 
-import org.apache.hupa.server.gin.ServerModul;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;

Copied: labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java (from r795426,
labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java)
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java?p2=labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java&p1=labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java&r1=795426&r2=795712&rev=795712&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java Mon Jul 20 07:50:46
2009
@@ -17,17 +17,21 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.hupa.server.gin;
+package org.apache.hupa.server.guice;
 
 import net.customware.gwt.dispatch.server.guice.ActionHandlerModule;
 
+import org.apache.commons.logging.Log;
 import org.apache.hupa.server.ExposeMessageHandler;
 import org.apache.hupa.server.FetchFoldersHandler;
 import org.apache.hupa.server.FetchMessagesHandler;
+import org.apache.hupa.server.IMAPProtocolCache;
 import org.apache.hupa.server.LoginUserHandler;
 import org.apache.hupa.server.LogoutUserHandler;
 import org.apache.hupa.server.NoopHandler;
 
+import com.google.inject.Singleton;
+
 /**
  * Module which binds the handlers
  * 
@@ -45,5 +49,8 @@
 		bindHandler(LogoutUserHandler.class);
 		bindHandler(ExposeMessageHandler.class);
 		bindHandler(NoopHandler.class);
+		
+		bind(IMAPProtocolCache.class).in(Singleton.class);
+		bind(Log.class).toProvider(LogProvider.class).in(Singleton.class);
 	}
 }

Modified: labs/hupa/war/Hupa.css
URL: http://svn.apache.org/viewvc/labs/hupa/war/Hupa.css?rev=795712&r1=795711&r2=795712&view=diff
==============================================================================
--- labs/hupa/war/Hupa.css (original)
+++ labs/hupa/war/Hupa.css Mon Jul 20 07:50:46 2009
@@ -7,7 +7,7 @@
     border-color:	#E0ECFF;
 }
 
-.cbg-Button, .gwt-HTML, .gwt-Tree .gwt-TreeItem, .gwt-SuggestBoxPopup .item, hupa-LoginForm,
.hupa-IMAPMessageWidget-Header-Content, .hupa-ToolTip, .hupa-IMAPFolder {
+.cbg-Button, .gwt-HTML, .gwt-Tree .gwt-TreeItem, .gwt-SuggestBoxPopup .item, hupa-LoginForm,
.hupa-IMAPMessageWidget-Header-Content, .hupa-ToolTip, .hupa-IMAPFolder, .gwt-ListBox {
     font-size:			12px;
 	font-family: 		Arial, Helvetica, sans-serif;
 }

Added: labs/hupa/war/WEB-INF/classes/log4j.properties
URL: http://svn.apache.org/viewvc/labs/hupa/war/WEB-INF/classes/log4j.properties?rev=795712&view=auto
==============================================================================
--- labs/hupa/war/WEB-INF/classes/log4j.properties (added)
+++ labs/hupa/war/WEB-INF/classes/log4j.properties Mon Jul 20 07:50:46 2009
@@ -0,0 +1,9 @@
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=DEBUG, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message