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