use of com.willshex.blogwt.client.api.user.event.GetRolesAndPermissionsEventHandler.GetRolesAndPermissionsSuccess in project blogwt by billy1380.
the class UserController method fetchUserRolesAndPremissions.
/**
* @param user
*/
private void fetchUserRolesAndPremissions() {
if (user != null) {
if (getRolesAndPermissionsRequest != null) {
getRolesAndPermissionsRequest.cancel();
getRolesAndPermissionsRequest = null;
}
final GetRolesAndPermissionsRequest input = ApiHelper.setAccessCode(new GetRolesAndPermissionsRequest());
input.session = SessionController.get().sessionForApiCall();
input.user = user;
getRolesAndPermissionsRequest = ApiHelper.createUserClient().getRolesAndPermissions(input, new AsyncCallback<GetRolesAndPermissionsResponse>() {
@Override
public void onSuccess(GetRolesAndPermissionsResponse output) {
getRolesAndPermissionsRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.roles != null) {
USER_ROLES_PROVIDER.updateRowData(0, output.roles);
} else {
USER_ROLES_PROVIDER.updateRowCount(0, true);
}
if (output.permissions != null) {
USER_PERMISSIONS_PROVIDER.updateRowData(0, output.permissions);
} else {
USER_PERMISSIONS_PROVIDER.updateRowCount(0, true);
}
}
DefaultEventBus.get().fireEventFromSource(new GetRolesAndPermissionsSuccess(input, output), UserController.this);
}
@Override
public void onFailure(Throwable caught) {
getRolesAndPermissionsRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetRolesAndPermissionsFailure(input, caught), UserController.this);
}
});
}
}
Aggregations