Subversion Repositories SmartDukaan

Rev

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

Rev 2835 Rev 2843
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.BillingType;
8
import in.shop2020.hotspot.dashbaord.shared.actions.UserType;
9
import in.shop2020.hotspot.dashbaord.shared.actions.UserType;
-
 
10
import in.shop2020.model.v1.catalog.Warehouse;
-
 
11
import in.shop2020.thrift.clients.CatalogServiceClient;
9
import in.shop2020.thrift.clients.HelperServiceClient;
12
import in.shop2020.thrift.clients.HelperServiceClient;
10
import in.shop2020.utils.DashboardUser;
13
import in.shop2020.utils.DashboardUser;
11
import in.shop2020.utils.HelperService.Client;
14
import in.shop2020.utils.HelperService.Client;
12
import in.shop2020.utils.HelperServiceException;
15
import in.shop2020.utils.HelperServiceException;
13
import net.customware.gwt.dispatch.server.ActionHandler;
16
import net.customware.gwt.dispatch.server.ActionHandler;
Line 21... Line 24...
21
		String userName = request.getUsername();
24
		String userName = request.getUsername();
22
		String password = request.getPassword();
25
		String password = request.getPassword();
23
		
26
		
24
		boolean status = false;
27
		boolean status = false;
25
		long warehouseId = -1;
28
		long warehouseId = -1;
26
		UserType type = UserType.WAREHOUSE_EXECUTIVE;
29
		UserType userType = UserType.WAREHOUSE_EXECUTIVE;
-
 
30
		BillingType billingType = BillingType.EXTERNAL;
27
 
31
 
28
		NEXT nextScreen = null;
32
		NEXT nextScreen = null;
29
		String message = null;
33
		String message = null;
30
		
34
		
31
		try {
35
		try {
32
			HelperServiceClient hsc = new HelperServiceClient();
36
            HelperServiceClient hsc = new HelperServiceClient();
33
			Client client =  hsc.getClient();
37
            Client client = hsc.getClient();
34
			DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);
38
            DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);
-
 
39
            switch (dashboardUser.getRole()) {
-
 
40
            case ADMIN:
-
 
41
                userType = UserType.ADMIN;
-
 
42
                break;
-
 
43
            case CATEGORY_MANAGER:
-
 
44
                userType = UserType.CATEGORY_MANAGER;
-
 
45
                break;
-
 
46
            default:
-
 
47
                userType = UserType.WAREHOUSE_EXECUTIVE;
-
 
48
            }
35
			status = true;
49
			status = true;
36
			nextScreen = NEXT.INBOX;
50
			nextScreen = NEXT.INBOX;
-
 
51
			
37
			warehouseId = dashboardUser.getWarehouseId();
52
			warehouseId = dashboardUser.getWarehouseId();
-
 
53
			CatalogServiceClient csc = new CatalogServiceClient();
-
 
54
			in.shop2020.model.v1.catalog.InventoryService.Client iClient = csc.getClient();
-
 
55
			Warehouse warehouse = iClient.getWarehouse(warehouseId);
38
			switch(dashboardUser.getRole()){
56
			switch(warehouse.getBillingType()){
39
			case ADMIN:
57
			case OURS:
40
			    type = UserType.ADMIN;
58
			    billingType = BillingType.OURS;
41
			    break;
59
			    break;
42
			case CATEGORY_MANAGER:
60
			case EXTERNAL:
43
			    type = UserType.CATEGORY_MANAGER;
61
			    billingType = BillingType.EXTERNAL;
44
			    break;
62
			    break;
45
			default:
63
			default:
46
			    type = UserType.WAREHOUSE_EXECUTIVE;
64
			    billingType = BillingType.EXTERNAL;
47
			}
65
			}
-
 
66
 
48
			message = "You are charming, loving and affectionate";
67
			message = "You are charming, loving and affectionate";
49
		} catch (HelperServiceException e) {
68
		} catch (HelperServiceException e) {
50
			e.printStackTrace();
69
			e.printStackTrace();
51
		} catch (TException e) {
70
		} catch (TException e) {
52
			e.printStackTrace();
71
			e.printStackTrace();
53
		} catch (Exception e) {
72
		} catch (Exception e) {
54
			e.printStackTrace();
73
			e.printStackTrace();
55
		}
74
		}
56
		return new AuthResponse(userName, status, message, nextScreen, warehouseId, type);
75
		return new AuthResponse(userName, status, message, nextScreen, warehouseId, userType, billingType);
57
	}
76
	}
58
 
77
 
59
	@Override
78
	@Override
60
	public Class<AuthRequest> getActionType() {		
79
	public Class<AuthRequest> getActionType() {		
61
		return AuthRequest.class;
80
		return AuthRequest.class;