| 167 |
ashish |
1 |
package in.shop2020.hotspot.dashbaord.server.handler;
|
|
|
2 |
|
| 5110 |
mandeep.dh |
3 |
import in.shop2020.hotspot.dashbaord.server.CatalogUtils;
|
|
|
4 |
import in.shop2020.hotspot.dashbaord.server.LogisticsUtils;
|
| 167 |
ashish |
5 |
import in.shop2020.hotspot.dashbaord.shared.actions.AuthRequest;
|
|
|
6 |
import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse;
|
| 345 |
ashish |
7 |
import in.shop2020.hotspot.dashbaord.shared.actions.AuthResponse.NEXT;
|
| 2843 |
chandransh |
8 |
import in.shop2020.hotspot.dashbaord.shared.actions.BillingType;
|
| 2835 |
chandransh |
9 |
import in.shop2020.hotspot.dashbaord.shared.actions.UserType;
|
| 5945 |
mandeep.dh |
10 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 5948 |
mandeep.dh |
11 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 3132 |
rajveer |
12 |
import in.shop2020.thrift.clients.HelperClient;
|
| 2449 |
chandransh |
13 |
import in.shop2020.utils.DashboardUser;
|
| 493 |
rajveer |
14 |
import in.shop2020.utils.HelperService.Client;
|
|
|
15 |
import in.shop2020.utils.HelperServiceException;
|
| 5110 |
mandeep.dh |
16 |
|
|
|
17 |
import java.util.Map;
|
|
|
18 |
|
| 167 |
ashish |
19 |
import net.customware.gwt.dispatch.server.ActionHandler;
|
|
|
20 |
import net.customware.gwt.dispatch.server.ExecutionContext;
|
|
|
21 |
import net.customware.gwt.dispatch.shared.ActionException;
|
|
|
22 |
|
| 5110 |
mandeep.dh |
23 |
import org.apache.thrift.TException;
|
|
|
24 |
|
| 167 |
ashish |
25 |
public class AuthHandler implements ActionHandler<AuthRequest, AuthResponse>{
|
|
|
26 |
|
|
|
27 |
@Override
|
| 2449 |
chandransh |
28 |
public AuthResponse execute(AuthRequest request, ExecutionContext response) throws ActionException {
|
| 167 |
ashish |
29 |
String userName = request.getUsername();
|
| 493 |
rajveer |
30 |
String password = request.getPassword();
|
|
|
31 |
|
| 2449 |
chandransh |
32 |
boolean status = false;
|
|
|
33 |
long warehouseId = -1;
|
| 8303 |
amar.kumar |
34 |
long sourceId = -1;
|
| 8910 |
amar.kumar |
35 |
UserType userType = UserType.WAREHOUSE_OBSERVER;
|
| 2843 |
chandransh |
36 |
BillingType billingType = BillingType.EXTERNAL;
|
| 5110 |
mandeep.dh |
37 |
Map<Long, String> warehouses = null;
|
| 4603 |
rajveer |
38 |
Map<Long, String> providers = null;
|
| 5769 |
rajveer |
39 |
Map<Long, String> stores = null;
|
| 2449 |
chandransh |
40 |
NEXT nextScreen = null;
|
|
|
41 |
String message = null;
|
| 493 |
rajveer |
42 |
|
|
|
43 |
try {
|
| 3132 |
rajveer |
44 |
HelperClient hsc = new HelperClient();
|
| 2843 |
chandransh |
45 |
Client client = hsc.getClient();
|
|
|
46 |
DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);
|
|
|
47 |
switch (dashboardUser.getRole()) {
|
|
|
48 |
case ADMIN:
|
|
|
49 |
userType = UserType.ADMIN;
|
|
|
50 |
break;
|
| 4361 |
rajveer |
51 |
case WAREHOUSE_MONITOR:
|
|
|
52 |
userType = UserType.WAREHOUSE_MONITOR;
|
|
|
53 |
break;
|
| 8910 |
amar.kumar |
54 |
case WAREHOUSE_EXECUTIVE:
|
|
|
55 |
userType = UserType.WAREHOUSE_EXECUTIVE;
|
|
|
56 |
break;
|
| 2843 |
chandransh |
57 |
default:
|
| 8910 |
amar.kumar |
58 |
userType = UserType.WAREHOUSE_OBSERVER;
|
| 2843 |
chandransh |
59 |
}
|
| 2449 |
chandransh |
60 |
status = true;
|
|
|
61 |
nextScreen = NEXT.INBOX;
|
| 2843 |
chandransh |
62 |
|
| 2449 |
chandransh |
63 |
warehouseId = dashboardUser.getWarehouseId();
|
| 8303 |
amar.kumar |
64 |
sourceId = dashboardUser.getSource();
|
| 5948 |
mandeep.dh |
65 |
InventoryClient csc = new InventoryClient();
|
|
|
66 |
in.shop2020.model.v1.inventory.InventoryService.Client iClient = csc.getClient();
|
| 2843 |
chandransh |
67 |
Warehouse warehouse = iClient.getWarehouse(warehouseId);
|
|
|
68 |
switch(warehouse.getBillingType()){
|
|
|
69 |
case OURS:
|
|
|
70 |
billingType = BillingType.OURS;
|
| 2835 |
chandransh |
71 |
break;
|
| 2843 |
chandransh |
72 |
case EXTERNAL:
|
|
|
73 |
billingType = BillingType.EXTERNAL;
|
| 2835 |
chandransh |
74 |
break;
|
| 6746 |
rajveer |
75 |
case OURS_EXTERNAL:
|
|
|
76 |
billingType = BillingType.OURS_EXTERNAL;
|
|
|
77 |
break;
|
| 2835 |
chandransh |
78 |
default:
|
| 2843 |
chandransh |
79 |
billingType = BillingType.EXTERNAL;
|
| 2835 |
chandransh |
80 |
}
|
| 2843 |
chandransh |
81 |
|
| 5110 |
mandeep.dh |
82 |
warehouses = CatalogUtils.getWarehousesForBillingWarehouse(warehouseId);
|
| 4363 |
rajveer |
83 |
|
| 4603 |
rajveer |
84 |
providers = LogisticsUtils.getAllProviders();
|
|
|
85 |
|
| 5769 |
rajveer |
86 |
stores = LogisticsUtils.getAllStores();
|
|
|
87 |
|
| 2449 |
chandransh |
88 |
message = "You are charming, loving and affectionate";
|
| 493 |
rajveer |
89 |
} catch (HelperServiceException e) {
|
|
|
90 |
e.printStackTrace();
|
|
|
91 |
} catch (TException e) {
|
|
|
92 |
e.printStackTrace();
|
| 2449 |
chandransh |
93 |
} catch (Exception e) {
|
|
|
94 |
e.printStackTrace();
|
| 493 |
rajveer |
95 |
}
|
| 8303 |
amar.kumar |
96 |
return new AuthResponse(userName, status, message, nextScreen, warehouseId, userType, billingType, warehouses, providers, stores, sourceId);
|
| 167 |
ashish |
97 |
}
|
|
|
98 |
|
|
|
99 |
@Override
|
| 2449 |
chandransh |
100 |
public Class<AuthRequest> getActionType() {
|
| 167 |
ashish |
101 |
return AuthRequest.class;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
@Override
|
|
|
105 |
public void rollback(AuthRequest arg0, AuthResponse arg1,
|
|
|
106 |
ExecutionContext arg2) throws ActionException {
|
| 2449 |
chandransh |
107 |
//TODO Auto-generated method stub
|
| 167 |
ashish |
108 |
}
|
|
|
109 |
|
|
|
110 |
}
|