Example usage for com.google.gwt.gdata.client.contacts ContactGroupEntry getEtag

List of usage examples for com.google.gwt.gdata.client.contacts ContactGroupEntry getEtag

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.contacts ContactGroupEntry getEtag.

Prototype

public final native String getEtag() ;

Source Link

Document

Returns the entity tag of the entry.

Usage

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

License:Apache License

/**
 * Retrieve the contact groups feed using the Contacts service and
 * the contact groupd feed uri./*from www .j a v a2s .  co  m*/
 * On success, identify the first group entry with a title starting
 * with "GWT-Contacts-Client", this is the group that will be deleted.
 * If no contact group is found, display a message.
 * Otherwise call deleteContactGroup to delete the group entry.
 * Alternatively we could also have used deleteContactGroup.deleteEntry to
 * delete the contact group, but the effect is the same.
 * 
 * @param contactGroupsFeedUri The contact groups feed uri
 */
private void getContactGroups(String contactGroupsFeedUri) {
    showStatus("Loading contact groups feed...", false);
    service.getContactGroupFeed(contactGroupsFeedUri, new ContactGroupFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus(
                    "An error occurred while retrieving the contact groups " + "feed: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(ContactGroupFeed result) {
            ContactGroupEntry[] entries = result.getEntries();
            ContactGroupEntry targetGroup = null;
            for (ContactGroupEntry group : entries) {
                String title = group.getTitle().getText();
                if (title.startsWith("GWT-Contacts-Client")) {
                    targetGroup = group;
                    break;
                }
            }
            if (targetGroup == null) {
                showStatus("No contacts were found with a title starting with " + "'GWT-Contacts-Client'.",
                        false);
            } else {
                String contactGroupEntryUri = targetGroup.getEditLink().getHref();
                deleteContactGroup(contactGroupEntryUri, targetGroup.getEtag());
            }
        }
    });
}