use of com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest 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);
}
});
}
use of com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest in project blogwt by billy1380.
the class DownloadJsonServlet method processAction.
@Override
protected String processAction(String action, JsonObject request) {
String output = "null";
if ("DeleteGeneratedDownloads".equals(action)) {
DeleteGeneratedDownloadsRequest input = new DeleteGeneratedDownloadsRequest();
input.fromJson(request);
output = new DeleteGeneratedDownloadsActionHandler().handle(input).toString();
} else if ("GenerateDownload".equals(action)) {
GenerateDownloadRequest input = new GenerateDownloadRequest();
input.fromJson(request);
output = new GenerateDownloadActionHandler().handle(input).toString();
} else if ("GetGeneratedDownloads".equals(action)) {
GetGeneratedDownloadsRequest input = new GetGeneratedDownloadsRequest();
input.fromJson(request);
output = new GetGeneratedDownloadsActionHandler().handle(input).toString();
}
return output;
}
use of com.willshex.blogwt.shared.api.download.call.GetGeneratedDownloadsRequest 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;
}
Aggregations