Search in sources :

Example 1 with GetPostsRequest

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

the class BlogJsonServlet method processAction.

@Override
protected String processAction(String action, JsonObject request) {
    String output = "null";
    if ("GetProperties".equals(action)) {
        GetPropertiesRequest input = new GetPropertiesRequest();
        input.fromJson(request);
        output = new GetPropertiesActionHandler().handle(input).toString();
    } else if ("GetRatings".equals(action)) {
        GetRatingsRequest input = new GetRatingsRequest();
        input.fromJson(request);
        output = new GetRatingsActionHandler().handle(input).toString();
    } else if ("SubmitRating".equals(action)) {
        SubmitRatingRequest input = new SubmitRatingRequest();
        input.fromJson(request);
        output = new SubmitRatingActionHandler().handle(input).toString();
    } else if ("UpdateResource".equals(action)) {
        UpdateResourceRequest input = new UpdateResourceRequest();
        input.fromJson(request);
        output = new UpdateResourceActionHandler().handle(input).toString();
    } else if ("GetResource".equals(action)) {
        GetResourceRequest input = new GetResourceRequest();
        input.fromJson(request);
        output = new GetResourceActionHandler().handle(input).toString();
    } else if ("GetPosts".equals(action)) {
        GetPostsRequest input = new GetPostsRequest();
        input.fromJson(request);
        output = new GetPostsActionHandler().handle(input).toString();
    } else if ("GetArchiveEntries".equals(action)) {
        GetArchiveEntriesRequest input = new GetArchiveEntriesRequest();
        input.fromJson(request);
        output = new GetArchiveEntriesActionHandler().handle(input).toString();
    } else if ("DeleteResource".equals(action)) {
        DeleteResourceRequest input = new DeleteResourceRequest();
        input.fromJson(request);
        output = new DeleteResourceActionHandler().handle(input).toString();
    } else if ("GetResources".equals(action)) {
        GetResourcesRequest input = new GetResourcesRequest();
        input.fromJson(request);
        output = new GetResourcesActionHandler().handle(input).toString();
    } else if ("GetRelatedPosts".equals(action)) {
        GetRelatedPostsRequest input = new GetRelatedPostsRequest();
        input.fromJson(request);
        output = new GetRelatedPostsActionHandler().handle(input).toString();
    } else if ("UpdateProperties".equals(action)) {
        UpdatePropertiesRequest input = new UpdatePropertiesRequest();
        input.fromJson(request);
        output = new UpdatePropertiesActionHandler().handle(input).toString();
    } else if ("GetTags".equals(action)) {
        GetTagsRequest input = new GetTagsRequest();
        input.fromJson(request);
        output = new GetTagsActionHandler().handle(input).toString();
    } else if ("GetPost".equals(action)) {
        GetPostRequest input = new GetPostRequest();
        input.fromJson(request);
        output = new GetPostActionHandler().handle(input).toString();
    } else if ("DeletePost".equals(action)) {
        DeletePostRequest input = new DeletePostRequest();
        input.fromJson(request);
        output = new DeletePostActionHandler().handle(input).toString();
    } else if ("SetupBlog".equals(action)) {
        SetupBlogRequest input = new SetupBlogRequest();
        input.fromJson(request);
        output = new SetupBlogActionHandler().handle(input).toString();
    } else if ("CreatePost".equals(action)) {
        CreatePostRequest input = new CreatePostRequest();
        input.fromJson(request);
        output = new CreatePostActionHandler().handle(input).toString();
    } else if ("UpdatePost".equals(action)) {
        UpdatePostRequest input = new UpdatePostRequest();
        input.fromJson(request);
        output = new UpdatePostActionHandler().handle(input).toString();
    }
    return output;
}
Also used : SubmitRatingRequest(com.willshex.blogwt.shared.api.blog.call.SubmitRatingRequest) GetPostsActionHandler(com.willshex.blogwt.server.api.blog.action.GetPostsActionHandler) SetupBlogRequest(com.willshex.blogwt.shared.api.blog.call.SetupBlogRequest) CreatePostRequest(com.willshex.blogwt.shared.api.blog.call.CreatePostRequest) DeleteResourceActionHandler(com.willshex.blogwt.server.api.blog.action.DeleteResourceActionHandler) GetResourceRequest(com.willshex.blogwt.shared.api.blog.call.GetResourceRequest) GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) DeletePostActionHandler(com.willshex.blogwt.server.api.blog.action.DeletePostActionHandler) GetRatingsActionHandler(com.willshex.blogwt.server.api.blog.action.GetRatingsActionHandler) DeletePostRequest(com.willshex.blogwt.shared.api.blog.call.DeletePostRequest) UpdatePropertiesRequest(com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesRequest) SetupBlogActionHandler(com.willshex.blogwt.server.api.blog.action.SetupBlogActionHandler) SubmitRatingActionHandler(com.willshex.blogwt.server.api.blog.action.SubmitRatingActionHandler) GetTagsActionHandler(com.willshex.blogwt.server.api.blog.action.GetTagsActionHandler) UpdateResourceRequest(com.willshex.blogwt.shared.api.blog.call.UpdateResourceRequest) UpdatePostActionHandler(com.willshex.blogwt.server.api.blog.action.UpdatePostActionHandler) GetRatingsRequest(com.willshex.blogwt.shared.api.blog.call.GetRatingsRequest) GetRelatedPostsActionHandler(com.willshex.blogwt.server.api.blog.action.GetRelatedPostsActionHandler) UpdatePropertiesActionHandler(com.willshex.blogwt.server.api.blog.action.UpdatePropertiesActionHandler) GetPostActionHandler(com.willshex.blogwt.server.api.blog.action.GetPostActionHandler) GetResourcesRequest(com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest) GetPropertiesRequest(com.willshex.blogwt.shared.api.blog.call.GetPropertiesRequest) GetPropertiesActionHandler(com.willshex.blogwt.server.api.blog.action.GetPropertiesActionHandler) GetResourceActionHandler(com.willshex.blogwt.server.api.blog.action.GetResourceActionHandler) GetPostRequest(com.willshex.blogwt.shared.api.blog.call.GetPostRequest) GetTagsRequest(com.willshex.blogwt.shared.api.blog.call.GetTagsRequest) UpdatePostRequest(com.willshex.blogwt.shared.api.blog.call.UpdatePostRequest) GetResourcesActionHandler(com.willshex.blogwt.server.api.blog.action.GetResourcesActionHandler) GetArchiveEntriesRequest(com.willshex.blogwt.shared.api.blog.call.GetArchiveEntriesRequest) UpdateResourceActionHandler(com.willshex.blogwt.server.api.blog.action.UpdateResourceActionHandler) GetArchiveEntriesActionHandler(com.willshex.blogwt.server.api.blog.action.GetArchiveEntriesActionHandler) CreatePostActionHandler(com.willshex.blogwt.server.api.blog.action.CreatePostActionHandler) GetRelatedPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetRelatedPostsRequest) DeleteResourceRequest(com.willshex.blogwt.shared.api.blog.call.DeleteResourceRequest)

Example 2 with GetPostsRequest

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

the class PostsPlugin method emit.

/* (non-Javadoc)
	 * 
	 * @see org.markdown4j.Plugin#emit(java.lang.StringBuilder, java.util.List,
	 * java.util.Map) */
@Override
public void emit(StringBuilder out, List<String> lines, Map<String, String> params) {
    String count = params.get("count");
    final String id = HTMLPanel.createUniqueId();
    out.append("<div id=\"");
    out.append(id);
    out.append("\">Loading...</div>");
    ApiHelper.createBlogClient().getPosts(SessionController.get().setSession(ApiHelper.setAccessCode(new GetPostsRequest())).pager(PagerHelper.createDefaultPager().count(Integer.valueOf(count)).sortBy(PostSortType.PostSortTypeCreated.toString())), (i, o) -> {
        if (manager != null) {
            String content = "";
            if (o.status == StatusType.StatusTypeSuccess && o.posts != null && !o.posts.isEmpty()) {
                SafeHtmlBuilder b = new SafeHtmlBuilder();
                for (Post object : o.posts) {
                    RENDERER.render(null, object, b);
                }
                content = b.toSafeHtml().asString();
            }
            manager.fireEvent(new PluginContentReadyEvent(this, lines, params, id, content));
        }
    }, (i, c) -> {
        if (manager != null) {
            String content = "";
            manager.fireEvent(new PluginContentReadyEvent(this, lines, params, id, content));
        }
    });
}
Also used : PluginContentReadyEvent(org.markdown4j.client.event.PluginContentReadyEventHandler.PluginContentReadyEvent) Post(com.willshex.blogwt.shared.api.datatype.Post) GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 3 with GetPostsRequest

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

the class BlogService method getPosts.

public Request getPosts(GetPostsRequest input, AsyncSuccess<GetPostsRequest, GetPostsResponse> onSuccess, AsyncFailure<GetPostsRequest> onFailure) {
    Request handle = null;
    try {
        handle = sendRequest(BlogMethodGetPosts, input, new RequestCallback() {

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

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

Example 4 with GetPostsRequest

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

the class PostOracle method lookup.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.blogwt.client.oracle.SuggestOracle#lookup(com.google.gwt
	 * .user.client.ui.SuggestOracle.Request,
	 * com.google.gwt.user.client.ui.SuggestOracle.Callback) */
@Override
protected void lookup(final Request request, final Callback callback) {
    final GetPostsRequest input = ApiHelper.setAccessCode(new GetPostsRequest());
    input.session = SessionController.get().sessionForApiCall();
    input.includePostContents = Boolean.FALSE;
    input.query = request.getQuery();
    input.pager = PagerHelper.createDefaultPager();
    input.pager.count = Integer.valueOf(request.getLimit());
    input.showAll = Boolean.TRUE;
    if (getPostsRequest != null) {
        getPostsRequest.cancel();
    }
    getPostsRequest = ApiHelper.createBlogClient().getPosts(input, new AsyncCallback<GetPostsResponse>() {

        @Override
        public void onSuccess(GetPostsResponse output) {
            if (output.status == StatusType.StatusTypeSuccess && output.pager != null) {
                foundItems(request, callback, output.posts);
            } else {
                foundItems(request, callback, Collections.<Post>emptyList());
            }
        }

        @Override
        public void onFailure(Throwable caught) {
            GWT.log("Error getting posts with query " + input.query, caught);
            foundItems(request, callback, Collections.<Post>emptyList());
        }
    });
}
Also used : GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetPostsResponse(com.willshex.blogwt.shared.api.blog.call.GetPostsResponse)

Example 5 with GetPostsRequest

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

the class StaticPosts method appendPage.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.page.StaticTemplate#appendPage(java.lang.
	 * StringBuffer) */
@Override
protected void appendPage(StringBuffer markup) {
    markup.append("<h2>Blog</h2>");
    GetPostsRequest input = input(GetPostsRequest.class).pager(PagerHelper.createDefaultPager().sortBy(PostSortType.PostSortTypePublished.toString()));
    GetPostsResponse output = new GetPostsActionHandler().handle(input);
    if (output.status == StatusType.StatusTypeSuccess && output.posts != null) {
        showPosts(output.posts, markup);
    } else {
        markup.append(output.error.toString());
    }
}
Also used : GetPostsActionHandler(com.willshex.blogwt.server.api.blog.action.GetPostsActionHandler) GetPostsRequest(com.willshex.blogwt.shared.api.blog.call.GetPostsRequest) GetPostsResponse(com.willshex.blogwt.shared.api.blog.call.GetPostsResponse)

Aggregations

GetPostsRequest (com.willshex.blogwt.shared.api.blog.call.GetPostsRequest)8 GetPostsActionHandler (com.willshex.blogwt.server.api.blog.action.GetPostsActionHandler)4 GetPostsResponse (com.willshex.blogwt.shared.api.blog.call.GetPostsResponse)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 CreatePostRequest (com.willshex.blogwt.shared.api.blog.call.CreatePostRequest)2 DeletePostRequest (com.willshex.blogwt.shared.api.blog.call.DeletePostRequest)2 DeleteResourceRequest (com.willshex.blogwt.shared.api.blog.call.DeleteResourceRequest)2 GetArchiveEntriesRequest (com.willshex.blogwt.shared.api.blog.call.GetArchiveEntriesRequest)2 GetPostRequest (com.willshex.blogwt.shared.api.blog.call.GetPostRequest)2 GetPropertiesRequest (com.willshex.blogwt.shared.api.blog.call.GetPropertiesRequest)2 GetRatingsRequest (com.willshex.blogwt.shared.api.blog.call.GetRatingsRequest)2 GetRelatedPostsRequest (com.willshex.blogwt.shared.api.blog.call.GetRelatedPostsRequest)2 GetResourceRequest (com.willshex.blogwt.shared.api.blog.call.GetResourceRequest)2 GetResourcesRequest (com.willshex.blogwt.shared.api.blog.call.GetResourcesRequest)2 GetTagsRequest (com.willshex.blogwt.shared.api.blog.call.GetTagsRequest)2 SetupBlogRequest (com.willshex.blogwt.shared.api.blog.call.SetupBlogRequest)2 SubmitRatingRequest (com.willshex.blogwt.shared.api.blog.call.SubmitRatingRequest)2 UpdatePostRequest (com.willshex.blogwt.shared.api.blog.call.UpdatePostRequest)2 UpdatePropertiesRequest (com.willshex.blogwt.shared.api.blog.call.UpdatePropertiesRequest)2 UpdateResourceRequest (com.willshex.blogwt.shared.api.blog.call.UpdateResourceRequest)2