Package net.relatedwork.server.action

Source Code of net.relatedwork.server.action.LoginActionActionHandler

package net.relatedwork.server.action;

import javax.servlet.ServletContext;

import com.gwtplatform.dispatch.server.actionhandler.ActionHandler;
import net.relatedwork.client.tools.session.SessionInformation;
import net.relatedwork.server.userHelper.LoginException;
import net.relatedwork.server.userHelper.UserInformation;
import net.relatedwork.shared.dto.LoginAction;
import net.relatedwork.shared.dto.LoginActionResult;

import com.google.inject.Inject;
import com.gwtplatform.dispatch.server.ExecutionContext;
import com.gwtplatform.dispatch.shared.ActionException;

public class LoginActionActionHandler implements
    ActionHandler<LoginAction, LoginActionResult> {

  @Inject ServletContext servletContext;
 
  @Inject
  public LoginActionActionHandler() {
  }

  @Override
  public LoginActionResult execute(LoginAction loginAction, ExecutionContext context)
      throws ActionException {
    //TODO: Implement Serverside user handling
    // Check login
    String email = loginAction.getEmail();
    String password = loginAction.getPassword();
    SessionInformation SIO = loginAction.getSession();
   
    UserInformation UIO = new UserInformation(servletContext);
   
    try {
      UIO.loginUser(loginAction);
    } catch (LoginException e) {
      throw new ActionException(e.getMessage());
    }
       
    // return LoginResult object with userdata
    SIO = UIO.updateSIO(SIO);
   
        return new LoginActionResult(SIO);
  }

  @Override
  public void undo(LoginAction action, LoginActionResult result,
      ExecutionContext context) throws ActionException {
  }

  @Override
  public Class<LoginAction> getActionType() {
    return LoginAction.class;
  }
}
TOP

Related Classes of net.relatedwork.server.action.LoginActionActionHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.