Example usage for com.google.gwt.gdata.client.blogger CommentEntry getSelfLink

List of usage examples for com.google.gwt.gdata.client.blogger CommentEntry getSelfLink

Introduction

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

Prototype

public final native com.google.gwt.gdata.client.Link getSelfLink() ;

Source Link

Document

Returns the link that provides the URI of the feed or entry.

Usage

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

License:Apache License

/**
 * Retrieve the Blogger comments feed using the Blogger service and
 * the comments feed uri for a given post.
 * On success, identify the first comment entry with a title starting
 * with "GWT-Blogger-Client", this will be the comment that will be deleted.
 * If no comment is found, display a message.
 * Otherwise call deleteComment to delete the comment. Alternatively
 * we could also have used targetComment.deleteEntry to
 * delete the comment, but the effect is the same.
 * /* www. j  a  v a  2  s .co m*/
 * @param commentsFeedUri The comments feed uri for a given post
 */
private void getComments(String commentsFeedUri) {
    showStatus("Loading Blogger post comments feed...", false);
    service.getBlogCommentFeed(commentsFeedUri, new BlogCommentFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus(
                    "An error occurred while retrieving the Blogger Comments " + "feed: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(BlogCommentFeed result) {
            if (result.getEntries().length == 0) {
                showStatus("The target blog post has no comments.", false);
            } else {
                // get the first comment that matches
                CommentEntry targetComment = null;
                for (CommentEntry comment : result.getEntries()) {
                    String title = comment.getTitle().getText();
                    if (title.startsWith("GWT-Blogger-Client")) {
                        targetComment = comment;
                        break;
                    }
                }
                if (targetComment == null) {
                    showStatus("Did not find a comment entry whose title starts "
                            + "with the prefix 'GWT-Blogger-Client'.", false);
                } else {
                    deleteComment(targetComment.getSelfLink().getHref());
                }
            }
        }
    });
}