List of usage examples for com.google.gwt.gdata.client.blogger BlogPostFeedCallback BlogPostFeedCallback
BlogPostFeedCallback
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./*from w w w. ja v a 2s . c o m*/ * 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); } } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerCreateBlogPostDemo.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 . jav a 2 s. c o m * On success, call insertPost to insert a new post entry * into the retrieved posts feed. * * @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) { insertPost(result); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerDeleteBlogPostCommentDemo.java
License:Apache License
/** * Retrieve the Blogger posts feed using the Blogger service and * the posts feed uri for a given blog.//from w w w . java 2 s .c o m * On success, identify the first post entry that is available * for commenting, this will be the post entry for which a comment * will be deleted. * If no posts are available for commenting, display a message. * Otherwise call getComments to retrieve the comments feed * for the target post. * * @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 commentsFeedUri = targetPost.getRepliesLink().getHref(); getComments(commentsFeedUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerDeleteBlogPostDemo.java
License:Apache License
/** * Retrieve the Blogger posts feed using the Blogger service and * the posts feed uri for a given blog.// w ww .j a v a2s . com * On success, identify the first post entry with a title starting * with "GWT-Blogger-Client", this will be the post that will be deleted. * If no post is found, display a message. * Otherwise call deletePost to delete the post. Alternatively * we could also have used targetPost.deleteEntry to * delete the post, but the effect is the same. * * @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; for (PostEntry entry : result.getEntries()) { String title = entry.getTitle().getText(); if (title.startsWith("GWT-Blogger-Client")) { targetPost = entry; break; } } if (targetPost == null) { showStatus("Did not find a post entry whose title starts with " + "the prefix 'GWT-Blogger-Client'.", false); } else { deletePost(targetPost.getSelfLink().getHref()); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerQueryBlogPostsDemo.java
License:Apache License
/** * Retrieves a posts feed for a blog using a Query object. * In GData, feed URIs can contain querystring parameters. The * GData query objects aid in building parameterized feed URIs. * Upon successfully receiving the posts feed, the post entries * are displayed to the user via the showData method. * The PublishedMin and PublishedMax parameters are used to * limit the range of posts to a given publishing period. * /*from ww w . j a v a2s . com*/ * @param postsFeedUri The posts feed uri for a given blog. */ @SuppressWarnings("deprecation") private void queryPosts(String postsFeedUri) { final BlogPostQuery query = BlogPostQuery.newInstance(postsFeedUri); Date minDate = new Date(); minDate.setMonth(minDate.getMonth() - 1); query.setPublishedMin(DateTime.newInstance(minDate)); query.setPublishedMax(DateTime.newInstance(new Date())); showStatus("Querying Blogger for posts...", false); service.getBlogPostFeed(query, new BlogPostFeedCallback() { public void onFailure(CallErrorException caught) { showStatus("An error occurred while querying Blogger for Posts: " + caught.getMessage(), true); } public void onSuccess(BlogPostFeed result) { showData(result.getEntries()); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerRetrieveBlogPostsDemo.java
License:Apache License
/** * Retrieve the Blogger posts feed using the Blogger service and * the posts feed uri for a given blog./*ww w . j av a 2 s . com*/ * On success, call showData to display the post entries. * * @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) { showData(result.getEntries()); } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerRetrieveSpecificBlogPostDemo.java
License:Apache License
/** * Retrieve the Blogger posts feed using the Blogger service and * the posts feed uri for a given blog.//from w ww . j av a 2 s .co m * On success, call getPost on the first post entry. This will * retrieve the same entry that we already have, the purpose * is to exemplify retrieving a specific post entry directly. * If no posts are available, 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[] entries = result.getEntries(); if (entries.length == 0) { showStatus("No post entries found for the current blog.", false); } else { PostEntry targetPost = entries[0]; String postEntryUri = targetPost.getSelfLink().getHref(); getPost(postEntryUri); } } }); }
From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerUpdateBlogPostDemo.java
License:Apache License
/** * Retrieve the Blogger posts feed using the Blogger service and * the posts feed uri for a given blog./*from www. jav a 2 s. c om*/ * On success, identify the first post entry with a title starting * with "GWT-Blogger-Client", this will be the post that will be updated. * If no post is found, display a message. * Otherwise call updatePost to update the post. * * @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; for (PostEntry entry : result.getEntries()) { String title = entry.getTitle().getText(); if (title.startsWith("GWT-Blogger-Client")) { targetPost = entry; break; } } if (targetPost == null) { showStatus("Did not find a post entry whose title starts with " + "the prefix 'GWT-Blogger-Client'.", false); } else { updatePost(targetPost); } } }); }