Search in sources :

Example 1 with GetRolesResponse

use of com.willshex.blogwt.shared.api.user.call.GetRolesResponse in project blogwt by billy1380.

the class RoleOracle method lookup.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.blogwt.client.oracle.SuggestOracle#lookup(com.google.gwt
	 * .user.client.ui.SuggestOracle.Request,
	 * com.google.gwt.user.client.ui.SuggestOracle.Callback) */
@Override
protected void lookup(final Request request, final Callback callback) {
    final GetRolesRequest input = ApiHelper.setAccessCode(new GetRolesRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.query = request.getQuery();
    input.pager = PagerHelper.createDefaultPager();
    input.pager.count = Integer.valueOf(request.getLimit());
    if (getRolesRequest != null) {
        getRolesRequest.cancel();
    }
    getRolesRequest = ApiHelper.createUserClient().getRoles(input, new AsyncCallback<GetRolesResponse>() {

        @Override
        public void onSuccess(GetRolesResponse output) {
            if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
                foundItems(request, callback, output.roles);
            } else {
                foundItems(request, callback, Collections.<Role>emptyList());
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            GWT.log("Error getting roles with query " + input.query, caught);
            foundItems(request, callback, Collections.<Role>emptyList());
        }
    });
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetRolesRequest(com.willshex.blogwt.shared.api.user.call.GetRolesRequest) GetRolesResponse(com.willshex.blogwt.shared.api.user.call.GetRolesResponse)

Example 2 with GetRolesResponse

use of com.willshex.blogwt.shared.api.user.call.GetRolesResponse in project blogwt by billy1380.

the class RoleController method fetchRoles.

private void fetchRoles() {
    final GetRolesRequest input = ApiHelper.setAccessCode(new GetRolesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getRolesRequest != null) {
        getRolesRequest.cancel();
    }
    getRolesRequest = ApiHelper.createUserClient().getRoles(input, new AsyncCallback<GetRolesResponse>() {

        @Override
        public void onSuccess(GetRolesResponse output) {
            getRolesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.roles != null && output.roles.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.roles);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Role>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetRolesSuccess(input, output), RoleController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getRolesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetRolesFailure(input, caught), RoleController.this);
        }
    });
}
Also used : GetRolesFailure(com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesFailure) GetRolesSuccess(com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesSuccess) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetRolesRequest(com.willshex.blogwt.shared.api.user.call.GetRolesRequest) GetRolesResponse(com.willshex.blogwt.shared.api.user.call.GetRolesResponse)

Example 3 with GetRolesResponse

use of com.willshex.blogwt.shared.api.user.call.GetRolesResponse in project blogwt by billy1380.

the class UserService method getRoles.

public Request getRoles(GetRolesRequest input, AsyncSuccess<GetRolesRequest, GetRolesResponse> onSuccess, AsyncFailure<GetRolesRequest> onFailure) {
    Request handle = null;
    try {
        handle = sendRequest(UserMethodGetRoles, input, new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                try {
                    GetRolesResponse outputParameter = new GetRolesResponse();
                    parseResponse(response, outputParameter);
                    if (onSuccess != null) {
                        onSuccess.call(input, outputParameter);
                    }
                    onCallSuccess(UserService.this, UserMethodGetRoles, input, outputParameter);
                } catch (JSONException | HttpException exception) {
                    if (onFailure != null) {
                        onFailure.call(input, exception);
                    }
                    onCallFailure(UserService.this, UserMethodGetRoles, input, exception);
                }
            }

            @Override
            public void onError(Request request, Throwable exception) {
                if (onFailure != null) {
                    onFailure.call(input, exception);
                }
                onCallFailure(UserService.this, UserMethodGetRoles, input, exception);
            }
        });
        onCallStart(UserService.this, UserMethodGetRoles, input, handle);
    } catch (RequestException exception) {
        if (onFailure != null) {
            onFailure.call(input, exception);
        }
        onCallFailure(UserService.this, UserMethodGetRoles, 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) GetRolesResponse(com.willshex.blogwt.shared.api.user.call.GetRolesResponse)

Aggregations

GetRolesRequest (com.willshex.blogwt.shared.api.user.call.GetRolesRequest)3 GetRolesResponse (com.willshex.blogwt.shared.api.user.call.GetRolesResponse)3 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)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 GetRolesFailure (com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesFailure)1 GetRolesSuccess (com.willshex.blogwt.client.api.user.event.GetRolesEventHandler.GetRolesSuccess)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