Search in sources :

Example 1 with GetResourcesResponse

use of com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse in project blogwt by billy1380.

the class ResourceController method fetchResources.

private void fetchResources() {
    final GetResourcesRequest input = ApiHelper.setAccessCode(new GetResourcesRequest());
    input.pager = pager;
    input.session = SessionController.get().sessionForApiCall();
    if (getResourcesRequest != null) {
        getResourcesRequest.cancel();
    }
    getResourcesRequest = ApiHelper.createBlogClient().getResources(input, new AsyncCallback<GetResourcesResponse>() {

        @Override
        public void onSuccess(GetResourcesResponse output) {
            getResourcesRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.resources != null && output.resources.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.resources);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<Resource>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetResourcesSuccess(input, output), ResourceController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getResourcesRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetResourcesFailure(input, caught), ResourceController.this);
        }
    });
}
Also used : GetResourcesRequest(com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest) GetResourcesSuccess(com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesSuccess) GetResourcesFailure(com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetResourcesResponse(com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse)

Example 2 with GetResourcesResponse

use of com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse in project blogwt by billy1380.

the class BlogService method getResources.

public Request getResources(GetResourcesRequest input, AsyncSuccess<GetResourcesRequest, GetResourcesResponse> onSuccess, AsyncFailure<GetResourcesRequest> onFailure) {
    Request handle = null;
    try {
        handle = sendRequest(BlogMethodGetResources, input, new RequestCallback() {

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

            @Override
            public void onError(Request request, Throwable exception) {
                if (onFailure != null) {
                    onFailure.call(input, exception);
                }
                onCallFailure(BlogService.this, BlogMethodGetResources, input, exception);
            }
        });
        onCallStart(BlogService.this, BlogMethodGetResources, input, handle);
    } catch (RequestException exception) {
        if (onFailure != null) {
            onFailure.call(input, exception);
        }
        onCallFailure(BlogService.this, BlogMethodGetResources, input, exception);
    }
    return handle;
}
Also used : GetRatingsResponse(com.willshex.blogwt.shared.api.blog.call.GetRatingsResponse) UpdatePropertiesResponse(com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesResponse) SubmitRatingResponse(com.willshex.blogwt.shared.api.blog.call.SubmitRatingResponse) UpdatePostResponse(com.willshex.blogwt.shared.api.blog.call.UpdatePostResponse) GetTagsResponse(com.willshex.blogwt.shared.api.blog.call.GetTagsResponse) DeleteResourceResponse(com.willshex.blogwt.shared.api.blog.call.DeleteResourceResponse) GetArchiveEntriesResponse(com.willshex.blogwt.shared.api.blog.call.GetArchiveEntriesResponse) Response(com.google.gwt.http.client.Response) GetPostResponse(com.willshex.blogwt.shared.api.blog.call.GetPostResponse) SetupBlogResponse(com.willshex.blogwt.shared.api.blog.call.SetupBlogResponse) GetResourcesResponse(com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse) CreatePostResponse(com.willshex.blogwt.shared.api.blog.call.CreatePostResponse) GetRelatedPostsResponse(com.willshex.blogwt.shared.api.blog.call.GetRelatedPostsResponse) GetResourceResponse(com.willshex.blogwt.shared.api.blog.call.GetResourceResponse) GetPostsResponse(com.willshex.blogwt.shared.api.blog.call.GetPostsResponse) UpdateResourceResponse(com.willshex.blogwt.shared.api.blog.call.UpdateResourceResponse) DeletePostResponse(com.willshex.blogwt.shared.api.blog.call.DeletePostResponse) GetPropertiesResponse(com.willshex.blogwt.shared.api.blog.call.GetPropertiesResponse) RequestCallback(com.google.gwt.http.client.RequestCallback) UpdatePostRequest(com.willshex.blogwt.shared.api.blog.call.UpdatePostRequest) GetResourcesRequest(com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest) GetResourceRequest(com.willshex.blogwt.shared.api.blog.call.GetResourceRequest) DeleteResourceRequest(com.willshex.blogwt.shared.api.blog.call.DeleteResourceRequest) GetRelatedPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetRelatedPostsRequest) GetTagsRequest(com.willshex.blogwt.shared.api.blog.call.GetTagsRequest) UpdatePropertiesRequest(com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesRequest) GetRatingsRequest(com.willshex.blogwt.shared.api.blog.call.GetRatingsRequest) DeletePostRequest(com.willshex.blogwt.shared.api.blog.call.DeletePostRequest) SubmitRatingRequest(com.willshex.blogwt.shared.api.blog.call.SubmitRatingRequest) CreatePostRequest(com.willshex.blogwt.shared.api.blog.call.CreatePostRequest) GetArchiveEntriesRequest(com.willshex.blogwt.shared.api.blog.call.GetArchiveEntriesRequest) Request(com.google.gwt.http.client.Request) UpdateResourceRequest(com.willshex.blogwt.shared.api.blog.call.UpdateResourceRequest) GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) GetPropertiesRequest(com.willshex.blogwt.shared.api.blog.call.GetPropertiesRequest) GetPostRequest(com.willshex.blogwt.shared.api.blog.call.GetPostRequest) SetupBlogRequest(com.willshex.blogwt.shared.api.blog.call.SetupBlogRequest) JSONException(com.google.gwt.json.client.JSONException) HttpException(com.willshex.gson.web.service.client.HttpException) GetResourcesResponse(com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

GetResourcesRequest (com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest)2 GetResourcesResponse (com.willshex.blogwt.shared.api.blog.call.GetResourcesResponse)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 GetResourcesFailure (com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesFailure)1 GetResourcesSuccess (com.willshex.blogwt.client.api.blog.event.GetResourcesEventHandler.GetResourcesSuccess)1 CreatePostRequest (com.willshex.blogwt.shared.api.blog.call.CreatePostRequest)1 CreatePostResponse (com.willshex.blogwt.shared.api.blog.call.CreatePostResponse)1 DeletePostRequest (com.willshex.blogwt.shared.api.blog.call.DeletePostRequest)1 DeletePostResponse (com.willshex.blogwt.shared.api.blog.call.DeletePostResponse)1 DeleteResourceRequest (com.willshex.blogwt.shared.api.blog.call.DeleteResourceRequest)1 DeleteResourceResponse (com.willshex.blogwt.shared.api.blog.call.DeleteResourceResponse)1 GetArchiveEntriesRequest (com.willshex.blogwt.shared.api.blog.call.GetArchiveEntriesRequest)1 GetArchiveEntriesResponse (com.willshex.blogwt.shared.api.blog.call.GetArchiveEntriesResponse)1 GetPostRequest (com.willshex.blogwt.shared.api.blog.call.GetPostRequest)1 GetPostResponse (com.willshex.blogwt.shared.api.blog.call.GetPostResponse)1