use of com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse in project blogwt by billy1380.
the class UserService method getRolesAndPermissions.
public Request getRolesAndPermissions(GetRolesAndPermissionsRequest input, AsyncSuccess<GetRolesAndPermissionsRequest, GetRolesAndPermissionsResponse> onSuccess, AsyncFailure<GetRolesAndPermissionsRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(UserMethodGetRolesAndPermissions, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetRolesAndPermissionsResponse outputParameter = new GetRolesAndPermissionsResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(UserService.this, UserMethodGetRolesAndPermissions, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRolesAndPermissions, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRolesAndPermissions, input, exception);
}
});
onCallStart(UserService.this, UserMethodGetRolesAndPermissions, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(UserService.this, UserMethodGetRolesAndPermissions, input, exception);
}
return handle;
}
use of com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse 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