Rev 8303 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.hotspot.dashbaord.server.handler;import in.shop2020.hotspot.dashbaord.server.CatalogUtils;import in.shop2020.hotspot.dashbaord.server.LogisticsUtils;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.hotspot.dashbaord.shared.actions.BillingType;import in.shop2020.hotspot.dashbaord.shared.actions.UserType;import in.shop2020.model.v1.inventory.Warehouse;import in.shop2020.thrift.clients.InventoryClient;import in.shop2020.thrift.clients.HelperClient;import in.shop2020.utils.DashboardUser;import in.shop2020.utils.HelperService.Client;import in.shop2020.utils.HelperServiceException;import java.util.Map;import net.customware.gwt.dispatch.server.ActionHandler;import net.customware.gwt.dispatch.server.ExecutionContext;import net.customware.gwt.dispatch.shared.ActionException;import org.apache.thrift.TException;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;long sourceId = -1;UserType userType = UserType.WAREHOUSE_OBSERVER;BillingType billingType = BillingType.EXTERNAL;Map<Long, String> warehouses = null;Map<Long, String> providers = null;Map<Long, String> stores = null;NEXT nextScreen = null;String message = null;try {HelperClient hsc = new HelperClient();Client client = hsc.getClient();DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);switch (dashboardUser.getRole()) {case ADMIN:userType = UserType.ADMIN;break;case WAREHOUSE_MONITOR:userType = UserType.WAREHOUSE_MONITOR;break;case WAREHOUSE_EXECUTIVE:userType = UserType.WAREHOUSE_EXECUTIVE;break;default:userType = UserType.WAREHOUSE_OBSERVER;}status = true;nextScreen = NEXT.INBOX;warehouseId = dashboardUser.getWarehouseId();sourceId = dashboardUser.getSource();InventoryClient csc = new InventoryClient();in.shop2020.model.v1.inventory.InventoryService.Client iClient = csc.getClient();Warehouse warehouse = iClient.getWarehouse(warehouseId);switch(warehouse.getBillingType()){case OURS:billingType = BillingType.OURS;break;case EXTERNAL:billingType = BillingType.EXTERNAL;break;case OURS_EXTERNAL:billingType = BillingType.OURS_EXTERNAL;break;default:billingType = BillingType.EXTERNAL;}warehouses = CatalogUtils.getWarehousesForBillingWarehouse(warehouseId);providers = LogisticsUtils.getAllProviders();stores = LogisticsUtils.getAllStores();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, userType, billingType, warehouses, providers, stores, sourceId);}@Overridepublic Class<AuthRequest> getActionType() {return AuthRequest.class;}@Overridepublic void rollback(AuthRequest arg0, AuthResponse arg1,ExecutionContext arg2) throws ActionException {//TODO Auto-generated method stub}}