Example usage for com.google.gwt.gdata.client.gbase ItemsEntry getSelfLink

List of usage examples for com.google.gwt.gdata.client.gbase ItemsEntry getSelfLink

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.gbase ItemsEntry 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.GoogleBaseDeleteItemDemo.java

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers.// ww  w .ja  v  a 2 s.  c  o m
 * Here, the failure handler displays an error message while the
 * success handler obtains the first Item entry with a title
 * starting with "GWT-GoogleBase-Client" and calls deleteItem
 * to delete the item. Alternatively we could also have used
 * targetItem.deleteEntry but the effect is the same.
 * If no item is found a message is displayed.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            ItemsEntry targetItem = null;
            for (ItemsEntry entry : entries) {
                if (entry.getTitle().getText().startsWith("GWT-GoogleBase-Client")) {
                    targetItem = entry;
                    break;
                }
            }
            if (targetItem == null) {
                showStatus("No item found that contains 'GWT-GoogleBase-Client' " + "in the title.", false);
            } else {
                String itemsEntryUri = targetItem.getSelfLink().getHref();
                deleteItem(itemsEntryUri);
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers./*  w w  w  . jav a  2 s  .c o m*/
 * Here, the failure handler displays an error message while the
 * success handler obtains the first item entry that is associated
 * with on or more media attachments and calls getMedia to
 * retrieve its media entries.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            ItemsEntry targetItem = null;
            for (ItemsEntry entry : entries) {
                FeedLink<MediaFeed> link = entry.getFeedLink().cast();
                if (link.getCountHint() > 0) {
                    targetItem = entry;
                    break;
                }
            }
            if (targetItem == null) {
                showStatus("You have no items containing media.", false);
            } else {
                String itemsEntryUri = targetItem.getSelfLink().getHref();
                getMedia(itemsEntryUri);
            }
        }
    });
}