| 167 |
ashish |
1 |
package in.shop2020.hotspot.dashbaord.server.handler;
|
|
|
2 |
|
| 493 |
rajveer |
3 |
import org.apache.thrift.TException;
|
|
|
4 |
|
| 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;
|
| 2835 |
chandransh |
8 |
import in.shop2020.hotspot.dashbaord.shared.actions.UserType;
|
| 493 |
rajveer |
9 |
import in.shop2020.thrift.clients.HelperServiceClient;
|
| 2449 |
chandransh |
10 |
import in.shop2020.utils.DashboardUser;
|
| 493 |
rajveer |
11 |
import in.shop2020.utils.HelperService.Client;
|
|
|
12 |
import in.shop2020.utils.HelperServiceException;
|
| 167 |
ashish |
13 |
import net.customware.gwt.dispatch.server.ActionHandler;
|
|
|
14 |
import net.customware.gwt.dispatch.server.ExecutionContext;
|
|
|
15 |
import net.customware.gwt.dispatch.shared.ActionException;
|
|
|
16 |
|
|
|
17 |
public class AuthHandler implements ActionHandler<AuthRequest, AuthResponse>{
|
|
|
18 |
|
|
|
19 |
@Override
|
| 2449 |
chandransh |
20 |
public AuthResponse execute(AuthRequest request, ExecutionContext response) throws ActionException {
|
| 167 |
ashish |
21 |
String userName = request.getUsername();
|
| 493 |
rajveer |
22 |
String password = request.getPassword();
|
|
|
23 |
|
| 2449 |
chandransh |
24 |
boolean status = false;
|
|
|
25 |
long warehouseId = -1;
|
| 2835 |
chandransh |
26 |
UserType type = UserType.WAREHOUSE_EXECUTIVE;
|
|
|
27 |
|
| 2449 |
chandransh |
28 |
NEXT nextScreen = null;
|
|
|
29 |
String message = null;
|
| 493 |
rajveer |
30 |
|
|
|
31 |
try {
|
| 2449 |
chandransh |
32 |
HelperServiceClient hsc = new HelperServiceClient();
|
|
|
33 |
Client client = hsc.getClient();
|
|
|
34 |
DashboardUser dashboardUser = client.authenticateDashboardUser(userName, password);
|
|
|
35 |
status = true;
|
|
|
36 |
nextScreen = NEXT.INBOX;
|
|
|
37 |
warehouseId = dashboardUser.getWarehouseId();
|
| 2835 |
chandransh |
38 |
switch(dashboardUser.getRole()){
|
|
|
39 |
case ADMIN:
|
|
|
40 |
type = UserType.ADMIN;
|
|
|
41 |
break;
|
|
|
42 |
case CATEGORY_MANAGER:
|
|
|
43 |
type = UserType.CATEGORY_MANAGER;
|
|
|
44 |
break;
|
|
|
45 |
default:
|
|
|
46 |
type = UserType.WAREHOUSE_EXECUTIVE;
|
|
|
47 |
}
|
| 2449 |
chandransh |
48 |
message = "You are charming, loving and affectionate";
|
| 493 |
rajveer |
49 |
} catch (HelperServiceException e) {
|
|
|
50 |
e.printStackTrace();
|
|
|
51 |
} catch (TException e) {
|
|
|
52 |
e.printStackTrace();
|
| 2449 |
chandransh |
53 |
} catch (Exception e) {
|
|
|
54 |
e.printStackTrace();
|
| 493 |
rajveer |
55 |
}
|
| 2835 |
chandransh |
56 |
return new AuthResponse(userName, status, message, nextScreen, warehouseId, type);
|
| 167 |
ashish |
57 |
}
|
|
|
58 |
|
|
|
59 |
@Override
|
| 2449 |
chandransh |
60 |
public Class<AuthRequest> getActionType() {
|
| 167 |
ashish |
61 |
return AuthRequest.class;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
@Override
|
|
|
65 |
public void rollback(AuthRequest arg0, AuthResponse arg1,
|
|
|
66 |
ExecutionContext arg2) throws ActionException {
|
| 2449 |
chandransh |
67 |
//TODO Auto-generated method stub
|
| 167 |
ashish |
68 |
}
|
|
|
69 |
|
|
|
70 |
}
|