Example usage for com.google.gwt.gdata.client.blogger PostEntry getId

List of usage examples for com.google.gwt.gdata.client.blogger PostEntry getId

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.blogger PostEntry getId.

Prototype

public final native Id getId() ;

Source Link

Document

Returns the entry identifier.

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerCreateBlogPostCommentDemo.java

License:Apache License

/**
 * Retrieve the Blogger posts feed using the Blogger service and
 * the posts feed uri for a given blog.//w  w  w.  ja va  2s. c  om
 * On success, identify the first post entry that is available
 * for commenting, this will be the post entry that we'll
 * reply to.
 * If no posts are available for commenting, display a message.
 * Otherwise extract the blog and post ID and call insertComment
 * to add a comment.
 * If the regular expression parsing of the blog and post IDs
 * fails, display a message.
 * 
 * @param postsFeedUri The posts feed uri for a given blog
 */
private void getPosts(String postsFeedUri) {
    showStatus("Loading posts feed...", false);
    service.getBlogPostFeed(postsFeedUri, new BlogPostFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Blogger Posts " + "feed: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(BlogPostFeed result) {
            PostEntry targetPost = null;
            // get the first public post
            for (PostEntry post : result.getEntries()) {
                if (post.getRepliesLink() != null) {
                    targetPost = post;
                    break;
                }
            }
            if (targetPost == null) {
                showStatus("The target blog contains no public posts.", false);
            } else {
                String postEntryId = targetPost.getId().getValue();
                JsArrayString match = regExpMatch("blog-(\\d+)\\.post-(\\d+)", postEntryId);
                if (match.length() > 1) {
                    insertComment(match.get(1), match.get(2));
                } else {
                    showStatus("Error parsing the blog post id.", true);
                }
            }
        }
    });
}