Search in sources :

Example 1 with GetGeneratedDownloadsResponse

use of com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse in project blogwt by billy1380.

the class GeneratedDownloadController method fetchGeneratedDownloads.

private void fetchGeneratedDownloads() {
    final GetGeneratedDownloadsRequest input = ApiHelper.setAccessCode(new GetGeneratedDownloadsRequest()).pager(pager);
    input.session(SessionController.get().sessionForApiCall());
    if (getGeneratedDownloadsRequest != null) {
        getGeneratedDownloadsRequest.cancel();
    }
    getGeneratedDownloadsRequest = ApiHelper.createDownloadClient().getGeneratedDownloads(input, new AsyncCallback<GetGeneratedDownloadsResponse>() {

        @Override
        public void onSuccess(GetGeneratedDownloadsResponse output) {
            getGeneratedDownloadsRequest = null;
            if (output.status == StatusType.StatusTypeSuccess) {
                if (output.downloads != null && output.downloads.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.downloads);
                } else {
                    updateRowCount(input.pager.start.intValue(), true);
                    updateRowData(input.pager.start.intValue(), Collections.<GeneratedDownload>emptyList());
                }
            }
            DefaultEventBus.get().fireEventFromSource(new GetGeneratedDownloadsSuccess(input, output), GeneratedDownloadController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            getGeneratedDownloadsRequest = null;
            DefaultEventBus.get().fireEventFromSource(new GetGeneratedDownloadsFailure(input, caught), GeneratedDownloadController.this);
        }
    });
}
Also used : GetGeneratedDownloadsResponse(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse) GetGeneratedDownloadsSuccess(com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsSuccess) GetGeneratedDownloadsFailure(com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsFailure) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetGeneratedDownloadsRequest(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest)

Example 2 with GetGeneratedDownloadsResponse

use of com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse in project blogwt by billy1380.

the class DownloadService method getGeneratedDownloads.

public Request getGeneratedDownloads(final GetGeneratedDownloadsRequest input, final AsyncCallback<GetGeneratedDownloadsResponse> callback) {
    Request handle = null;
    try {
        handle = sendRequest(DownloadMethodGetGeneratedDownloads, input, new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                try {
                    GetGeneratedDownloadsResponse outputParameter = new GetGeneratedDownloadsResponse();
                    parseResponse(response, outputParameter);
                    callback.onSuccess(outputParameter);
                    onCallSuccess(DownloadService.this, DownloadMethodGetGeneratedDownloads, input, outputParameter);
                } catch (JSONException | HttpException exception) {
                    callback.onFailure(exception);
                    onCallFailure(DownloadService.this, DownloadMethodGetGeneratedDownloads, input, exception);
                }
            }

            @Override
            public void onError(Request request, Throwable exception) {
                callback.onFailure(exception);
                onCallFailure(DownloadService.this, DownloadMethodGetGeneratedDownloads, input, exception);
            }
        });
        onCallStart(DownloadService.this, DownloadMethodGetGeneratedDownloads, input, handle);
    } catch (RequestException exception) {
        callback.onFailure(exception);
        onCallFailure(DownloadService.this, DownloadMethodGetGeneratedDownloads, input, exception);
    }
    return handle;
}
Also used : GenerateDownloadResponse(com.willshex.blogwt.shared.api.download.call.GenerateDownloadResponse) GetGeneratedDownloadsResponse(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse) DeleteGeneratedDownloadsResponse(com.willshex.blogwt.shared.api.download.call.DeleteGeneratedDownloadsResponse) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback) GetGeneratedDownloadsResponse(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse) DeleteGeneratedDownloadsRequest(com.willshex.blogwt.shared.api.download.call.DeleteGeneratedDownloadsRequest) GenerateDownloadRequest(com.willshex.blogwt.shared.api.download.call.GenerateDownloadRequest) Request(com.google.gwt.http.client.Request) GetGeneratedDownloadsRequest(com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest) JSONException(com.google.gwt.json.client.JSONException) HttpException(com.willshex.gson.web.service.client.HttpException) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

GetGeneratedDownloadsRequest (com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest)2 GetGeneratedDownloadsResponse (com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsResponse)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 GetGeneratedDownloadsFailure (com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsFailure)1 GetGeneratedDownloadsSuccess (com.willshex.blogwt.client.api.download.event.GetGeneratedDownloadsEventHandler.GetGeneratedDownloadsSuccess)1 DeleteGeneratedDownloadsRequest (com.willshex.blogwt.shared.api.download.call.DeleteGeneratedDownloadsRequest)1 DeleteGeneratedDownloadsResponse (com.willshex.blogwt.shared.api.download.call.DeleteGeneratedDownloadsResponse)1 GenerateDownloadRequest (com.willshex.blogwt.shared.api.download.call.GenerateDownloadRequest)1 GenerateDownloadResponse (com.willshex.blogwt.shared.api.download.call.GenerateDownloadResponse)1 HttpException (com.willshex.gson.web.service.client.HttpException)1