Search in sources :

Example 1 with CreatePostResponse

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

the class PostController method createPost.

public void createPost(String title, Boolean listed, Boolean commentsEnabled, String summary, String content, Boolean publish, String tags) {
    BlogService blogService = ApiHelper.createBlogClient();
    final CreatePostRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new CreatePostRequest())).post(new Post().title(title).summary(summary).content(new PostContent().body(content)).tags(TagHelper.convertToTagList(tags)).listed(listed).commentsEnabled(commentsEnabled)).publish(publish);
    blogService.createPost(input, new AsyncCallback<CreatePostResponse>() {

        @Override
        public void onSuccess(CreatePostResponse output) {
            if (output.status == StatusType.StatusTypeSuccess) {
            }
            DefaultEventBus.get().fireEventFromSource(new CreatePostSuccess(input, output), PostController.this);
        }

        @Override
        public void onFailure(Throwable caught) {
            DefaultEventBus.get().fireEventFromSource(new CreatePostFailure(input, caught), PostController.this);
        }
    });
}
Also used : BlogService(com.willshex.blogwt.client.api.blog.BlogService) CreatePostRequest(com.willshex.blogwt.shared.api.blog.call.CreatePostRequest) Post(com.willshex.blogwt.shared.api.datatype.Post) CreatePostSuccess(com.willshex.blogwt.client.api.blog.event.CreatePostEventHandler.CreatePostSuccess) CreatePostFailure(com.willshex.blogwt.client.api.blog.event.CreatePostEventHandler.CreatePostFailure) PostContent(com.willshex.blogwt.shared.api.datatype.PostContent) CreatePostResponse(com.willshex.blogwt.shared.api.blog.call.CreatePostResponse)

Example 2 with CreatePostResponse

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

the class BlogService method createPost.

public Request createPost(CreatePostRequest input, AsyncSuccess<CreatePostRequest, CreatePostResponse> onSuccess, AsyncFailure<CreatePostRequest> onFailure) {
    Request handle = null;
    try {
        handle = sendRequest(BlogMethodCreatePost, input, new RequestCallback() {

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

            @Override
            public void onError(Request request, Throwable exception) {
                if (onFailure != null) {
                    onFailure.call(input, exception);
                }
                onCallFailure(BlogService.this, BlogMethodCreatePost, input, exception);
            }
        });
        onCallStart(BlogService.this, BlogMethodCreatePost, input, handle);
    } catch (RequestException exception) {
        if (onFailure != null) {
            onFailure.call(input, exception);
        }
        onCallFailure(BlogService.this, BlogMethodCreatePost, 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) RequestException(com.google.gwt.http.client.RequestException) CreatePostResponse(com.willshex.blogwt.shared.api.blog.call.CreatePostResponse)

Aggregations

CreatePostRequest (com.willshex.blogwt.shared.api.blog.call.CreatePostRequest)2 CreatePostResponse (com.willshex.blogwt.shared.api.blog.call.CreatePostResponse)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 BlogService (com.willshex.blogwt.client.api.blog.BlogService)1 CreatePostFailure (com.willshex.blogwt.client.api.blog.event.CreatePostEventHandler.CreatePostFailure)1 CreatePostSuccess (com.willshex.blogwt.client.api.blog.event.CreatePostEventHandler.CreatePostSuccess)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 GetPostsRequest (com.willshex.blogwt.shared.api.blog.call.GetPostsRequest)1 GetPostsResponse (com.willshex.blogwt.shared.api.blog.call.GetPostsResponse)1