Search in sources :

Example 1 with GetRolesAndPermissionsSuccess

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);
            }
        });
    }
}
Also used : GetRolesAndPermissionsRequest(com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetRolesAndPermissionsSuccess(com.willshex.blogwt.client.api.user.event.GetRolesAndPermissionsEventHandler.GetRolesAndPermissionsSuccess) GetRolesAndPermissionsFailure(com.willshex.blogwt.client.api.user.event.GetRolesAndPermissionsEventHandler.GetRolesAndPermissionsFailure) GetRolesAndPermissionsResponse(com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetRolesAndPermissionsFailure (com.willshex.blogwt.client.api.user.event.GetRolesAndPermissionsEventHandler.GetRolesAndPermissionsFailure)1 GetRolesAndPermissionsSuccess (com.willshex.blogwt.client.api.user.event.GetRolesAndPermissionsEventHandler.GetRolesAndPermissionsSuccess)1 GetRolesAndPermissionsRequest (com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsRequest)1 GetRolesAndPermissionsResponse (com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse)1