Search in sources :

Example 1 with GetRolesAndPermissionsResponse

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;
}
Also used : GetPermissionsResponse(com.willshex.blogwt.shared.api.user.call.GetPermissionsResponse) GetUsersResponse(com.willshex.blogwt.shared.api.user.call.GetUsersResponse) Response(com.google.gwt.http.client.Response) ChangeUserAccessResponse(com.willshex.blogwt.shared.api.user.call.ChangeUserAccessResponse) ResetPasswordResponse(com.willshex.blogwt.shared.api.user.call.ResetPasswordResponse) LogoutResponse(com.willshex.blogwt.shared.api.user.call.LogoutResponse) GetUserDetailsResponse(com.willshex.blogwt.shared.api.user.call.GetUserDetailsResponse) RegisterUserResponse(com.willshex.blogwt.shared.api.user.call.RegisterUserResponse) VerifyAccountResponse(com.willshex.blogwt.shared.api.user.call.VerifyAccountResponse) FollowUsersResponse(com.willshex.blogwt.shared.api.user.call.FollowUsersResponse) GetRolesResponse(com.willshex.blogwt.shared.api.user.call.GetRolesResponse) GetEmailAvatarResponse(com.willshex.blogwt.shared.api.user.call.GetEmailAvatarResponse) GetRolesAndPermissionsResponse(com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse) ChangeUserDetailsResponse(com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsResponse) IsAuthorisedResponse(com.willshex.blogwt.shared.api.user.call.IsAuthorisedResponse) ChangePasswordResponse(com.willshex.blogwt.shared.api.user.call.ChangePasswordResponse) CheckUsernameResponse(com.willshex.blogwt.shared.api.user.call.CheckUsernameResponse) LoginResponse(com.willshex.blogwt.shared.api.user.call.LoginResponse) BlockUsersResponse(com.willshex.blogwt.shared.api.user.call.BlockUsersResponse) ForgotPasswordResponse(com.willshex.blogwt.shared.api.user.call.ForgotPasswordResponse) RequestCallback(com.google.gwt.http.client.RequestCallback) ForgotPasswordRequest(com.willshex.blogwt.shared.api.user.call.ForgotPasswordRequest) ChangeUserAccessRequest(com.willshex.blogwt.shared.api.user.call.ChangeUserAccessRequest) GetUserDetailsRequest(com.willshex.blogwt.shared.api.user.call.GetUserDetailsRequest) ChangePasswordRequest(com.willshex.blogwt.shared.api.user.call.ChangePasswordRequest) GetEmailAvatarRequest(com.willshex.blogwt.shared.api.user.call.GetEmailAvatarRequest) IsAuthorisedRequest(com.willshex.blogwt.shared.api.user.call.IsAuthorisedRequest) RegisterUserRequest(com.willshex.blogwt.shared.api.user.call.RegisterUserRequest) GetRolesRequest(com.willshex.blogwt.shared.api.user.call.GetRolesRequest) LogoutRequest(com.willshex.blogwt.shared.api.user.call.LogoutRequest) ChangeUserDetailsRequest(com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsRequest) GetRolesAndPermissionsRequest(com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsRequest) VerifyAccountRequest(com.willshex.blogwt.shared.api.user.call.VerifyAccountRequest) ResetPasswordRequest(com.willshex.blogwt.shared.api.user.call.ResetPasswordRequest) GetUsersRequest(com.willshex.blogwt.shared.api.user.call.GetUsersRequest) FollowUsersRequest(com.willshex.blogwt.shared.api.user.call.FollowUsersRequest) BlockUsersRequest(com.willshex.blogwt.shared.api.user.call.BlockUsersRequest) CheckUsernameRequest(com.willshex.blogwt.shared.api.user.call.CheckUsernameRequest) LoginRequest(com.willshex.blogwt.shared.api.user.call.LoginRequest) GetPermissionsRequest(com.willshex.blogwt.shared.api.user.call.GetPermissionsRequest) Request(com.google.gwt.http.client.Request) JSONException(com.google.gwt.json.client.JSONException) HttpException(com.willshex.gson.web.service.client.HttpException) RequestException(com.google.gwt.http.client.RequestException) GetRolesAndPermissionsResponse(com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse)

Example 2 with GetRolesAndPermissionsResponse

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);
            }
        });
    }
}
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

GetRolesAndPermissionsRequest (com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsRequest)2 GetRolesAndPermissionsResponse (com.willshex.blogwt.shared.api.user.call.GetRolesAndPermissionsResponse)2 Request (com.google.gwt.http.client.Request)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 JSONException (com.google.gwt.json.client.JSONException)1 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 BlockUsersRequest (com.willshex.blogwt.shared.api.user.call.BlockUsersRequest)1 BlockUsersResponse (com.willshex.blogwt.shared.api.user.call.BlockUsersResponse)1 ChangePasswordRequest (com.willshex.blogwt.shared.api.user.call.ChangePasswordRequest)1 ChangePasswordResponse (com.willshex.blogwt.shared.api.user.call.ChangePasswordResponse)1 ChangeUserAccessRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessRequest)1 ChangeUserAccessResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessResponse)1 ChangeUserDetailsRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsRequest)1 ChangeUserDetailsResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsResponse)1 CheckUsernameRequest (com.willshex.blogwt.shared.api.user.call.CheckUsernameRequest)1 CheckUsernameResponse (com.willshex.blogwt.shared.api.user.call.CheckUsernameResponse)1