labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r791847 - in /labs/hupa/src/main/java/org/apache/hupa: client/ client/events/ client/gin/ client/mvp/ client/rpc/ server/ server/gin/
Date Tue, 07 Jul 2009 14:43:05 GMT
Author: norman
Date: Tue Jul  7 14:43:04 2009
New Revision: 791847

URL: http://svn.apache.org/viewvc?rev=791847&view=rev
Log:
More MVP refactoring

Added:
    labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEvent.java
    labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEventHandler.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java
    labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUser.java
    labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUserResult.java
    labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java
Modified:
    labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java
    labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java
    labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppView.java
    labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java
    labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java

Modified: labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java Tue Jul  7 14:43:04 2009
@@ -20,6 +20,8 @@
 package org.apache.hupa.client;
 
 import org.apache.hupa.client.gin.MyGinjector;
+import org.apache.hupa.client.mvp.AppPresenter;
+import org.apache.hupa.client.mvp.AppView;
 
 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
@@ -29,7 +31,10 @@
 	private final MyGinjector injector = GWT.create(MyGinjector.class);
 	
 	public void onModuleLoad() {
-        RootPanel.get().add(injector.getAppView());
+		AppView aView = injector.getAppView();
+		AppPresenter aPres = injector.getAppPresenter();
+		aPres.bind(aView);
+        RootPanel.get().add(aView);
     }
 
 }

Added: labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEvent.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEvent.java?rev=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEvent.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEvent.java Tue Jul  7 14:43:04
2009
@@ -0,0 +1,28 @@
+package org.apache.hupa.client.events;
+
+import org.apache.hupa.client.data.IMAPUser;
+
+import com.google.gwt.event.shared.GwtEvent;
+
+public class LogoutEvent extends GwtEvent<LogoutEventHandler>{
+	public static Type<LogoutEventHandler> TYPE = new Type<LogoutEventHandler>();
+	private IMAPUser user;
+	public LogoutEvent(IMAPUser user) {
+		this.user = user;
+	}
+
+	@Override
+	protected void dispatch(LogoutEventHandler handler) {
+		handler.onLogout(this);
+	}
+
+	@Override
+	public com.google.gwt.event.shared.GwtEvent.Type<LogoutEventHandler> getAssociatedType()
{
+		return TYPE;
+	}
+	
+	public IMAPUser getUser() {
+		return user;
+	}
+
+}

Added: labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEventHandler.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEventHandler.java?rev=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEventHandler.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/events/LogoutEventHandler.java Tue Jul
 7 14:43:04 2009
@@ -0,0 +1,8 @@
+package org.apache.hupa.client.events;
+
+import com.google.gwt.event.shared.EventHandler;
+
+public interface LogoutEventHandler extends EventHandler{
+
+	public void onLogout(LogoutEvent logoutEvent);
+}

Modified: labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/gin/MyClientModule.java Tue Jul  7 14:43:04
2009
@@ -20,11 +20,12 @@
 package org.apache.hupa.client.gin;
 
 import org.apache.hupa.client.events.EventBus;
+import org.apache.hupa.client.mvp.AppPresenter;
 import org.apache.hupa.client.mvp.AppView;
-import org.apache.hupa.client.mvp.FolderPresenter;
-import org.apache.hupa.client.mvp.FolderView;
 import org.apache.hupa.client.mvp.LoginPresenter;
 import org.apache.hupa.client.mvp.LoginView;
+import org.apache.hupa.client.mvp.MainPresenter;
+import org.apache.hupa.client.mvp.MainView;
 
 import com.google.gwt.inject.client.AbstractGinModule;
 import com.google.inject.Singleton;
@@ -36,9 +37,10 @@
 		bind(EventBus.class).in(Singleton.class);
 		bind(LoginView.class).in(Singleton.class);
 		bind(LoginPresenter.class).in(Singleton.class);
-		bind(FolderView.class).in(Singleton.class);
-		bind(FolderPresenter.class).in(Singleton.class);
 		bind(AppView.class).in(Singleton.class);
+		bind(AppPresenter.class).in(Singleton.class);
+		bind(MainView.class).in(Singleton.class);
+		bind(MainPresenter.class).in(Singleton.class);
 	}
 
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/gin/MyGinjector.java Tue Jul  7 14:43:04
2009
@@ -20,6 +20,7 @@
 
 import net.customware.gwt.dispatch.client.gin.ClientDispatchModule;
 
+import org.apache.hupa.client.mvp.AppPresenter;
 import org.apache.hupa.client.mvp.AppView;
 
 import com.google.gwt.inject.client.GinModules;
@@ -28,4 +29,5 @@
 @GinModules({ClientDispatchModule.class,MyClientModule.class})
 public interface MyGinjector extends Ginjector {
 	public AppView getAppView();
+	public AppPresenter getAppPresenter();
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppPresenter.java Tue Jul  7 14:43:04
2009
@@ -1,8 +1,44 @@
 package org.apache.hupa.client.mvp;
 
+import net.customware.gwt.dispatch.client.DispatchAsync;
+
+import org.apache.hupa.client.events.EventBus;
+import org.apache.hupa.client.events.LoginEvent;
+import org.apache.hupa.client.events.LoginEventHandler;
+import org.apache.hupa.client.events.LogoutEvent;
+import org.apache.hupa.client.events.LogoutEventHandler;
+
+import com.google.inject.Inject;
+
 public class AppPresenter {
 
 	public interface Display {
 		public void showLogin();
+		public void showMain();
+	}
+
+	private Display display;
+	
+	@Inject
+	public AppPresenter(EventBus bus) {
+		bus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
+
+			public void onLogin(LoginEvent event) {
+				display.showMain();
+			}
+			
+		});
+		bus.addHandler(LogoutEvent.TYPE, new LogoutEventHandler() {
+
+			public void onLogout(LogoutEvent event) {
+				display.showLogin();
+			}
+			
+		});
+	}
+	
+	public void bind(Display display) {
+		this.display = display;
+		display.showLogin();
 	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppView.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppView.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/AppView.java Tue Jul  7 14:43:04 2009
@@ -9,16 +9,22 @@
 	private StackPanel panel = new StackPanel();
 	
 	@Inject
-	public AppView(LoginView view,LoginPresenter pres) {
+	public AppView(LoginView view,LoginPresenter pres, MainView mainView,MainPresenter mainpPres)
{
 		pres.bind(view);
+		mainpPres.bind(mainView);
+		
 		panel.setWidth("100%");
 		panel.setHeight("100%");
 		panel.add(view);
-		showLogin();
+		panel.add(mainView);
 		initWidget(panel);
 	}
 
 	public void showLogin() {
 		panel.showStack(0);
 	}
+	
+	public void showMain() {
+		panel.showStack(1);
+	}
 }

Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/LoginPresenter.java Tue Jul  7 14:43:04
2009
@@ -77,6 +77,7 @@
 
 			public void onSuccess(LoginUserResult result) {
 				bus.fireEvent(new LoginEvent(result.getUser()));
+				doReset();
 			}
 			
 		});

Added: labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java?rev=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainPresenter.java Tue Jul  7 14:43:04
2009
@@ -0,0 +1,152 @@
+package org.apache.hupa.client.mvp;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.hupa.client.data.IMAPFolder;
+import org.apache.hupa.client.data.IMAPUser;
+import org.apache.hupa.client.events.EventBus;
+import org.apache.hupa.client.events.LoginEvent;
+import org.apache.hupa.client.events.LoginEventHandler;
+import org.apache.hupa.client.events.LogoutEvent;
+import org.apache.hupa.client.events.LogoutEventHandler;
+import org.apache.hupa.client.rpc.FetchFolders;
+import org.apache.hupa.client.rpc.FetchFoldersResult;
+import org.apache.hupa.client.rpc.LogoutUser;
+import org.apache.hupa.client.rpc.LogoutUserResult;
+import org.apache.hupa.client.widgets.IMAPTreeItem;
+
+import net.customware.gwt.dispatch.client.DispatchAsync;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.event.logical.shared.HasSelectionHandlers;
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.google.inject.Inject;
+
+public class MainPresenter {
+
+	
+	public interface Display {
+		public HasClickHandlers getLogoutClick();
+		public HasSelectionHandlers<TreeItem> getTree();
+		public void bindTreeItems(List<IMAPTreeItem> treeList);
+	}
+	
+	private DispatchAsync dispatcher;
+	private EventBus bus;
+	private Display display;
+	private IMAPUser user;
+	
+	@Inject
+	public MainPresenter(DispatchAsync dispatcher, EventBus bus) {
+		this.bus = bus;
+		this.dispatcher = dispatcher;
+		bindHandler();
+	}
+	
+	private void bindHandler() {
+		bus.addHandler(LoginEvent.TYPE, new LoginEventHandler() {
+
+			public void onLogin(LoginEvent event) {
+				user = event.getUser();
+				loadTreeItems();
+			}
+			
+		});
+		bus.addHandler(LogoutEvent.TYPE, new LogoutEventHandler() {
+
+			public void onLogout(LogoutEvent logoutEvent) {
+				display.bindTreeItems(new ArrayList<IMAPTreeItem>());
+			}
+			
+		});
+	}
+	protected void loadTreeItems() {
+		dispatcher.execute(new FetchFolders(user), new AsyncCallback<FetchFoldersResult>()
{
+
+			public void onFailure(Throwable caught) {
+				System.err.println("T="+ caught);
+			}
+
+			public void onSuccess(FetchFoldersResult result) {
+				display.bindTreeItems(createTreeNodes(result.getFolders()));
+			}
+			
+		});
+	}
+	
+	/**
+	 * Create recursive the TreeNodes with all childs
+	 * 
+	 * @param list
+	 * @return
+	 */
+	private List<IMAPTreeItem> createTreeNodes(List<IMAPFolder> list) {
+		List<IMAPTreeItem> tList = new ArrayList<IMAPTreeItem>();
+
+		for (int i = 0; i < list.size(); i++) {
+			IMAPFolder iFolder = list.get(i);
+			IMAPTreeItem record = new IMAPTreeItem(iFolder.getName() + " ("
+					+ iFolder.getUnseeMessageCount() + ")");
+			
+			record.setUserObject(iFolder);
+
+			List<IMAPFolder> childFolders = iFolder.getChildIMAPFolders();
+			if (childFolders != null && childFolders.isEmpty() == false) {
+				List<IMAPTreeItem> items = createTreeNodes(childFolders);
+				for (int a = 0; a < items.size(); a++) {
+					record.addItem(items.get(a));
+				}
+			}
+
+			tList.add(record);
+		}
+
+		// Sort tree
+		Collections.sort(tList, new Comparator<TreeItem>() {
+
+			public int compare(TreeItem o1, TreeItem o2) {
+				return o1.getText().compareTo(o2.getText());
+			}
+
+		});
+		return tList;
+	}
+	public void bind(Display display) {
+		this.display = display;
+		display.getLogoutClick().addClickHandler(new ClickHandler() {
+
+			public void onClick(ClickEvent event) {
+				dispatcher.execute(new LogoutUser(user), new AsyncCallback<LogoutUserResult>()
{
+
+					public void onFailure(Throwable caught) {
+						// TODO Auto-generated method stub
+						
+					}
+
+					public void onSuccess(LogoutUserResult result) {
+						bus.fireEvent(new LogoutEvent(result.getUser()));
+					}
+					
+				});
+			}
+			
+		});
+		
+		display.getTree().addSelectionHandler(new SelectionHandler<TreeItem>() {
+
+			public void onSelection(SelectionEvent<TreeItem> event) {
+				TreeItem item = event.getSelectedItem();
+				IMAPFolder folder = (IMAPFolder) item.getUserObject();
+			}
+			
+		});
+	}
+}

Added: labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java?rev=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/MainView.java Tue Jul  7 14:43:04 2009
@@ -0,0 +1,152 @@
+package org.apache.hupa.client.mvp;
+
+import java.util.List;
+
+import org.apache.hupa.client.HupaConstants;
+import org.apache.hupa.client.bundles.IMAPTreeImages;
+import org.apache.hupa.client.widgets.IMAPTreeItem;
+import org.cobogw.gwt.user.client.ui.Button;
+import org.cobogw.gwt.user.client.ui.RoundedPanel;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
+import com.google.gwt.event.logical.shared.HasSelectionHandlers;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.DockPanel;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
+import com.google.gwt.user.client.ui.SuggestBox;
+import com.google.gwt.user.client.ui.Tree;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class MainView extends Composite implements MainPresenter.Display{
+	
+	private DockPanel dockPanel;
+	private VerticalPanel north;
+	private HupaConstants constants = GWT.create(HupaConstants.class);
+	private RoundedPanel west;
+	private IMAPTreeImages tImages = GWT.create(IMAPTreeImages.class);
+	private Tree folderTree = new Tree(tImages,true);
+	
+	private MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(" ,@");  
+	private SuggestBox searchBox = new SuggestBox(oracle);
+	private Button searchButton = new Button(constants.searchButton());
+	private Button logoutButton = new Button(constants.logoutButton());
+
+	public MainView() {
+		dockPanel = new DockPanel();
+		
+		dockPanel.setSpacing(10);
+		dockPanel.setWidth("100%");
+
+		createNorth();
+		createWest();
+		//createCenter();
+
+		dockPanel.add(north, DockPanel.NORTH);
+		dockPanel.add(west, DockPanel.WEST);
+		//dockPanel.add(center, DockPanel.CENTER);
+		dockPanel.setCellHorizontalAlignment(north, DockPanel.ALIGN_RIGHT);
+		//dockPanel.setCellHorizontalAlignment(center, DockPanel.ALIGN_LEFT);
+		
+		initWidget(dockPanel);
+	}
+
+	private void createWest() {
+		
+		
+			west = new RoundedPanel(RoundedPanel.ALL);
+			west.add(folderTree);
+			west.setWidth("30%");	
+			folderTree.setAnimationEnabled(true);
+		
+	}
+	private void createNorth() {
+		north = new VerticalPanel();
+		north.setWidth("100%");
+		HorizontalPanel northTop = new HorizontalPanel();
+		northTop.setSpacing(5);
+		northTop.setStyleName("hupa-Northpanel");
+		northTop.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
+
+		northTop.setWidth("100%");
+		northTop.add(new Label(constants.productName()));
+
+		
+		logoutButton.addClickHandler(new ClickHandler() {
+
+			public void onClick(ClickEvent event) {
+				
+			}
+			
+		});
+		northTop.add(logoutButton);
+		northTop.setCellHorizontalAlignment(logoutButton,
+				VerticalPanel.ALIGN_RIGHT);
+		north.add(northTop);
+		
+		HorizontalPanel hPanel = new HorizontalPanel();
+		hPanel.setSpacing(5);
+		hPanel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
+		
+		searchBox.setWidth("150px");
+		searchBox.setLimit(20);
+		searchBox.addKeyUpHandler(new KeyUpHandler() {
+
+			public void onKeyUp(KeyUpEvent event) {
+				if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
+					searchButton.click();
+				}
+			}
+			
+		});
+		hPanel.add(searchBox);
+		
+		
+		searchButton.addClickHandler(new ClickHandler() {
+
+			public void onClick(ClickEvent event) {
+				String searchValue = null;
+				if (searchBox.getValue().trim().length() >0) {
+					searchValue = searchBox.getValue().trim();
+				}
+				
+				/*
+				controller.call(new Event<MessageListModelData, HupaAction>(
+						HupaAction.FETCH_MESSAGES,
+						new MessageListModelData(user, folder,
+								0, rowsPerPage,searchValue), masker));
+				//searchBox.setValue("");
+				*/
+			}
+			
+		});
+		hPanel.add(searchButton);
+		
+		north.add(hPanel);
+		
+	}
+
+	public HasClickHandlers getLogoutClick() {
+		return logoutButton;
+	}
+	public HasSelectionHandlers<TreeItem> getTree() {
+		return folderTree;
+	}
+
+	public void bindTreeItems(List<IMAPTreeItem> treeList) {
+		folderTree.clear();
+		
+		for (int i = 0; i < treeList.size(); i++) {
+			folderTree.addItem(treeList.get(i));
+		
+		}
+	}
+}

Added: labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUser.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUser.java?rev=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUser.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUser.java Tue Jul  7 14:43:04
2009
@@ -0,0 +1,27 @@
+package org.apache.hupa.client.rpc;
+
+import org.apache.hupa.client.data.IMAPUser;
+
+import net.customware.gwt.dispatch.shared.Action;
+
+public class LogoutUser implements Action<LogoutUserResult>{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 2255166545722718094L;
+	private IMAPUser user;
+
+	@SuppressWarnings("unused")
+	private LogoutUser() {
+		
+	}
+	
+	public LogoutUser(IMAPUser user) {
+		this.user = user;
+	}
+	
+	public IMAPUser getUser() {
+		return user;
+	}
+}

Added: labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUserResult.java
URL: http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUserResult.java?rev=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUserResult.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/client/rpc/LogoutUserResult.java Tue Jul  7 14:43:04
2009
@@ -0,0 +1,26 @@
+package org.apache.hupa.client.rpc;
+
+import org.apache.hupa.client.data.IMAPUser;
+
+import net.customware.gwt.dispatch.shared.Result;
+
+public class LogoutUserResult implements Result {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -1788523843461596092L;
+	private IMAPUser user;
+
+	public LogoutUserResult(IMAPUser user) {
+		this.user = user;
+	}
+	
+	@SuppressWarnings("unused")
+	private LogoutUserResult() {
+	}
+	
+	public IMAPUser getUser() {
+		return user;
+	}
+}

Added: 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=791847&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/server/LogoutUserHandler.java Tue Jul  7 14:43:04
2009
@@ -0,0 +1,29 @@
+package org.apache.hupa.server;
+
+import net.customware.gwt.dispatch.server.ExecutionContext;
+import net.customware.gwt.dispatch.shared.ActionException;
+
+import org.apache.hupa.client.data.IMAPUser;
+import org.apache.hupa.client.rpc.LogoutUser;
+import org.apache.hupa.client.rpc.LogoutUserResult;
+
+public class LogoutUserHandler extends AbstractIMAPActionHandler<LogoutUser, LogoutUserResult>
{
+
+	public LogoutUserResult execute(LogoutUser action, ExecutionContext arg1)
+			throws ActionException {
+		IMAPUser user = action.getUser();
+		user.setAuthenticated(false);
+		return new LogoutUserResult(user);
+	}
+
+	public Class<LogoutUser> getActionType() {
+		return LogoutUser.class;
+	}
+
+	public void rollback(LogoutUser arg0, LogoutUserResult arg1,
+			ExecutionContext arg2) throws ActionException {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

Modified: 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/gin/ServerModul.java?rev=791847&r1=791846&r2=791847&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/gin/ServerModul.java Tue Jul  7 14:43:04
2009
@@ -23,6 +23,7 @@
 
 import org.apache.hupa.server.FetchFoldersHandler;
 import org.apache.hupa.server.LoginUserHandler;
+import org.apache.hupa.server.LogoutUserHandler;
 
 /**
  * Module which binds the handlers
@@ -36,5 +37,6 @@
 	protected void configureHandlers() {
 		bindHandler(LoginUserHandler.class);
 		bindHandler(FetchFoldersHandler.class);
+		bindHandler(LogoutUserHandler.class);
 	}
 }



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


Mime
View raw message