use of com.willshex.blogwt.shared.api.blog.call.GetPostResponse in project blogwt by billy1380.
the class PostController method getPost.
public void getPost(Post post) {
final GetPostRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new GetPostRequest())).post(post);
if (getPostRequest != null) {
getPostRequest.cancel();
}
getPostRequest = ApiHelper.createBlogClient().getPost(input, new AsyncCallback<GetPostResponse>() {
@Override
public void onSuccess(GetPostResponse output) {
getPostRequest = null;
boolean retryingGetWithSlug = false;
if (output.status == StatusType.StatusTypeSuccess) {
if (output.post != null) {
}
} else {
if (input.post.id != null) {
getPost(new Post().slug(input.post.id.toString()));
retryingGetWithSlug = true;
}
}
if (!retryingGetWithSlug) {
DefaultEventBus.get().fireEventFromSource(new GetPostSuccess(input, output), PostController.this);
}
}
@Override
public void onFailure(Throwable caught) {
getPostRequest = null;
DefaultEventBus.get().fireEventFromSource(new GetPostFailure(input, caught), PostController.this);
}
});
}
use of com.willshex.blogwt.shared.api.blog.call.GetPostResponse in project blogwt by billy1380.
the class BlogService method getPost.
public Request getPost(GetPostRequest input, AsyncSuccess<GetPostRequest, GetPostResponse> onSuccess, AsyncFailure<GetPostRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(BlogMethodGetPost, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
GetPostResponse outputParameter = new GetPostResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(BlogService.this, BlogMethodGetPost, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodGetPost, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodGetPost, input, exception);
}
});
onCallStart(BlogService.this, BlogMethodGetPost, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(BlogService.this, BlogMethodGetPost, input, exception);
}
return handle;
}
Aggregations