Search in sources :

Example 1 with GetPermissionsSuccess

use of com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsSuccess in project blogwt by billy1380.

the class PermissionController method fetchPermissions.

private void fetchPermissions() {
    final GetPermissionsRequest input = ApiHelper.setAccessCode(new GetPermissionsRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getPermissionsRequest != null) {
        getPermissionsRequest.cancel();
    }
    getPermissionsRequest = ApiHelper.createUserClient().getPermissions(input, new AsyncCallback<GetPermissionsResponse>() {

        @Override
        public void onSuccess(GetPermissionsResponse output) {
            getPermissionsRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.permissions != null && output.permissions.size() > 0) {
                    pager = output.pager;
                    updateRowCount(input.pager.count == null ? 0 : input.pager.count.intValue(), input.pager.count == null || input.pager.count.intValue() == 0);
                    updateRowData(input.pager.start.intValue(), output.permissions);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Permission>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetPermissionsSuccess(input, output), PermissionController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getPermissionsRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetPermissionsFailure(input, caught), PermissionController.this);
        }
    });
}
Also used : GetPermissionsRequest(com.willshex.blogwt.shared.api.user.call.GetPermissionsRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPermissionsSuccess(com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsSuccess) GetPermissionsFailure(com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsFailure) GetPermissionsResponse(com.willshex.blogwt.shared.api.user.call.GetPermissionsResponse)

Aggregations

AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetPermissionsFailure (com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsFailure)1 GetPermissionsSuccess (com.willshex.blogwt.client.api.user.event.GetPermissionsEventHandler.GetPermissionsSuccess)1 GetPermissionsRequest (com.willshex.blogwt.shared.api.user.call.GetPermissionsRequest)1 GetPermissionsResponse (com.willshex.blogwt.shared.api.user.call.GetPermissionsResponse)1