Example usage for com.google.gwt.gdata.client.blogger PostEntryCallback PostEntryCallback

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

Introduction

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

Prototype

PostEntryCallback

Source Link

Usage

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

License:Apache License

/**
 * Create a blog post by inserting a post entry into
 * a blog posts feed./*  ww w.j av  a 2s  .  c om*/
 * Set the post's title and contents to an arbitrary string. Here
 * we prefix the title with 'GWT-Blogger-Client' so that
 * we can identify which posts were created by this demo.
 * To avoid publishing the new post we set the Atom control status
 * to "draft".
 * Finally, we associate the new post with two categories.
 * On success and failure, display a status message.
 * 
 * @param postFeed The post feed into which to insert the new post
 */
private void insertPost(BlogPostFeed postFeed) {
    showStatus("Creating blog post entry...", false);
    PostEntry newPost = PostEntry.newInstance();
    newPost.setTitle(Text.newInstance());
    newPost.getTitle().setText("GWT-Blogger-Client - inserted post");
    newPost.setContent(Text.newInstance());
    newPost.getContent().setText("This is the body of the blog post. We " + "can include <b>HTML</b> tags.");
    newPost.setControl(Control.newInstance());
    newPost.getControl().setDraft(Draft.newInstance());
    newPost.getControl().getDraft().setValue(Draft.VALUE_YES);
    Category cat1 = Category.newInstance();
    cat1.setScheme("http://www.blogger.com/atom/ns#");
    cat1.setTerm("Label1");
    Category cat2 = Category.newInstance();
    cat2.setLabel("http://www.blogger.com/atom/ns#");
    cat2.setTerm("Label2");
    newPost.setCategories(new Category[] { cat1, cat2 });
    postFeed.insertEntry(newPost, new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating a blog post: " + caught.getMessage(), true);
        }

        public void onSuccess(PostEntry result) {
            showStatus("Created a blog entry titled '" + result.getTitle().getText() + "'.", false);
        }
    });
}

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

License:Apache License

/**
 * Delete a post entry using the Blogger service and
 * the post entry uri./*from   w  w w .  j  a  va2  s.  co m*/
 * On success and failure, display a status message.
 * 
 * @param postEntryUri The uri of the post entry to delete
 */
private void deletePost(String postEntryUri) {
    showStatus("Deleting post entry...", false);
    service.deleteEntry(postEntryUri, new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while deleting a blog post: " + caught.getMessage(), true);
        }

        public void onSuccess(PostEntry result) {
            showStatus("Deleted a blog post entry.", false);
        }
    });
}

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

License:Apache License

/**
 * Retrieves a post entry by uri. On success, call
 * showData to display the post entry details.
 * //from w ww.j a va 2s .c  om
 * @param postEntryUri The uri of the post entry to retrieve
 */
private void getPost(String postEntryUri) {
    showStatus("Loading post entry...", false);
    service.getPostEntry(postEntryUri, new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Blogger Post " + "entry: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(PostEntry result) {
            showData(result);
        }
    });
}

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

License:Apache License

/**
 * Update a blog post by making use of the updateEntry
 * method of the Entry class.//from  w  ww  .  jav  a  2s .c  o m
 * Set the post's title and contents to an arbitrary string. Here
 * we prefix the title with 'GWT-Blogger-Client' so that
 * we can identify which posts were updated by this demo.
 * We also update the name of one of the post's categories.
 * On success and failure, display a status message.
 * 
 * @param postEntry The post entry which to update
 */
private void updatePost(PostEntry postEntry) {
    showStatus("Updating post entry...", false);
    postEntry.getTitle().setText("GWT-Blogger-Client - updated post");
    postEntry.setContent(Text.newInstance());
    postEntry.getContent().setText("My updated post");
    Category[] categories = postEntry.getCategories();
    for (Category category : categories) {
        if (category.getTerm().equals("Label1")) {
            category.setTerm("Label1-updated");
        }
    }
    postEntry.updateEntry(new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while updating a blog post: " + caught.getMessage(), true);
        }

        public void onSuccess(PostEntry result) {
            showStatus("Updated a blog entry.", false);
        }
    });
}