Rev 2449 | Rev 2835 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.hotspot.dashbaord.server.handler;import org.apache.thrift.TException;import in.shop2020.hotspot.dashbaord.shared.actions.AuthRequest;import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse;import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse.NEXT;import in.shop2020.thrift.clients.HelperServiceClient;import in.shop2020.utils.DashboardUser;import in.shop2020.utils.Role;import in.shop2020.utils.HelperService.Client;import in.shop2020.utils.HelperServiceException;import net.customware.gwt.dispatch.server.ActionHandler;import net.customware.gwt.dispatch.server.ExecutionContext;import net.customware.gwt.dispatch.shared.ActionException;public class AuthHandler implements ActionHandler<AuthRequest, AuthResponse>{@Overridepublic AuthResponse execute(AuthRequest request, ExecutionContext response) throws ActionException {String userName = request.getUsername();String password = request.getPassword();boolean status = false;long warehouseId = -1;boolean isAdmin = false;boolean isCategoryManager = false;NEXT nextScreen = null;String message = null;try {HelperServiceClient hsc = new HelperServiceClient();Client client = hsc.getClient();DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);status = true;nextScreen = NEXT.INBOX;warehouseId = dashboardUser.getWarehouseId();if(dashboardUser.getRole() == Role.ADMIN)isAdmin = true;else if(dashboardUser.getRole() == Role.CATEGORY_MANAGER)isCategoryManager = true;message = "You are charming, loving and affectionate";} catch (HelperServiceException e) {e.printStackTrace();} catch (TException e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace();}return new AuthResponse(userName, status, message, nextScreen, warehouseId, isAdmin, isCategoryManager);}@Overridepublic Class<AuthRequest> getActionType() {return AuthRequest.class;}@Overridepublic void rollback(AuthRequest arg0, AuthResponse arg1,ExecutionContext arg2) throws ActionException {//TODO Auto-generated method stub}}