Subversion Repositories SmartDukaan

Rev

Rev 2781 | Rev 2843 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2781 Rev 2835
Line 3... Line 3...
3
import org.apache.thrift.TException;
3
import org.apache.thrift.TException;
4
 
4
 
5
import in.shop2020.hotspot.dashbaord.shared.actions.AuthRequest;
5
import in.shop2020.hotspot.dashbaord.shared.actions.AuthRequest;
6
import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse;
6
import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse;
7
import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse.NEXT;
7
import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse.NEXT;
-
 
8
import in.shop2020.hotspot.dashbaord.shared.actions.UserType;
8
import in.shop2020.thrift.clients.HelperServiceClient;
9
import in.shop2020.thrift.clients.HelperServiceClient;
9
import in.shop2020.utils.DashboardUser;
10
import in.shop2020.utils.DashboardUser;
10
import in.shop2020.utils.Role;
-
 
11
import in.shop2020.utils.HelperService.Client;
11
import in.shop2020.utils.HelperService.Client;
12
import in.shop2020.utils.HelperServiceException;
12
import in.shop2020.utils.HelperServiceException;
13
import net.customware.gwt.dispatch.server.ActionHandler;
13
import net.customware.gwt.dispatch.server.ActionHandler;
14
import net.customware.gwt.dispatch.server.ExecutionContext;
14
import net.customware.gwt.dispatch.server.ExecutionContext;
15
import net.customware.gwt.dispatch.shared.ActionException;
15
import net.customware.gwt.dispatch.shared.ActionException;
Line 21... Line 21...
21
		String userName = request.getUsername();
21
		String userName = request.getUsername();
22
		String password = request.getPassword();
22
		String password = request.getPassword();
23
		
23
		
24
		boolean status = false;
24
		boolean status = false;
25
		long warehouseId = -1;
25
		long warehouseId = -1;
26
		boolean isAdmin = false;
-
 
27
		boolean isCategoryManager = false;
26
		UserType type = UserType.WAREHOUSE_EXECUTIVE;
-
 
27
 
28
		NEXT nextScreen = null;
28
		NEXT nextScreen = null;
29
		String message = null;
29
		String message = null;
30
		
30
		
31
		try {
31
		try {
32
			HelperServiceClient hsc = new HelperServiceClient();
32
			HelperServiceClient hsc = new HelperServiceClient();
33
			Client client =  hsc.getClient();
33
			Client client =  hsc.getClient();
34
			DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);
34
			DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);
35
			status = true;
35
			status = true;
36
			nextScreen = NEXT.INBOX;
36
			nextScreen = NEXT.INBOX;
37
			warehouseId = dashboardUser.getWarehouseId();
37
			warehouseId = dashboardUser.getWarehouseId();
38
			if(dashboardUser.getRole() == Role.ADMIN)
38
			switch(dashboardUser.getRole()){
-
 
39
			case ADMIN:
39
			    isAdmin = true;
40
			    type = UserType.ADMIN;
-
 
41
			    break;
-
 
42
			case CATEGORY_MANAGER:
40
			else if(dashboardUser.getRole() == Role.CATEGORY_MANAGER)
43
			    type = UserType.CATEGORY_MANAGER;
-
 
44
			    break;
-
 
45
			default:
41
			    isCategoryManager = true;
46
			    type = UserType.WAREHOUSE_EXECUTIVE;
-
 
47
			}
42
			message = "You are charming, loving and affectionate";
48
			message = "You are charming, loving and affectionate";
43
		} catch (HelperServiceException e) {
49
		} catch (HelperServiceException e) {
44
			e.printStackTrace();
50
			e.printStackTrace();
45
		} catch (TException e) {
51
		} catch (TException e) {
46
			e.printStackTrace();
52
			e.printStackTrace();
47
		} catch (Exception e) {
53
		} catch (Exception e) {
48
			e.printStackTrace();
54
			e.printStackTrace();
49
		}
55
		}
50
		return new AuthResponse(userName, status, message, nextScreen, warehouseId, isAdmin, isCategoryManager);
56
		return new AuthResponse(userName, status, message, nextScreen, warehouseId, type);
51
	}
57
	}
52
 
58
 
53
	@Override
59
	@Override
54
	public Class<AuthRequest> getActionType() {		
60
	public Class<AuthRequest> getActionType() {		
55
		return AuthRequest.class;
61
		return AuthRequest.class;