public class

GoogleContactsConnector

extends AbstractGoogleOAuthConnector
java.lang.Object
   ↳ org.mule.modules.google.AbstractGoogleOAuthConnector
     ↳ org.mule.modules.google.contact.GoogleContactsConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Cloud connector for the Google Contacts API v3 using OAuth2 for initialization. Uses OAuth2 for authentication

Summary

Constants
String BATCH_REQUEST
String CONTACT_BATCH_FEED_URL
String CONTACT_FEED_URL
String GROUP_BATCH_FEED_URL
String GROUP_FEED_URL
int MAX_BATCH_OPERATIONS
[Expand]
Inherited Constants
From class org.mule.modules.google.AbstractGoogleOAuthConnector
Fields
private String accessToken
private String applicationName Application name registered on Google API console
private String consumerKey The OAuth2 consumer key
private String consumerSecret The OAuth2 consumer secret
private URL contactBatchUrl Contacts batch atom feed url
private URL contactFeedURL Contacts atom feed url
private ContactsService contactsService The actual instance of the com.google.gdata.client.contacts.ContactsService
private URL groupFeedURL Groups atom feed url
private URL grouptBatchUrl Groups batch atom feed url
private IdentifierPolicy identifierPolicy This policy represents which id we want to use to represent each google account.
private String scope The OAuth2 scopes you want to request
[Expand]
Inherited Fields
From class org.mule.modules.google.AbstractGoogleOAuthConnector
Public Constructors
GoogleContactsConnector()
Public Methods
ContactEntry addGroup(ContactEntry contact, String groupId)
Adds a group to a given contact
List<BatchResult> batchContacts(String batchId, List<NestedProcessor> operations)
This tag encloses a series of nested processors that perform operations on contacts entities
void batchDelete(MuleMessage message, String operationId, Collection<BaseEntry<?>> entries)
The function of this sub processor is to add updated operations into the current batch for the given entries This processor is intended to be used nested inside batch-contacts or batch-groups, although there's no syntactic validation inside the connector's XSD enforcing that.
List<BatchResult> batchGroups(String batchId, List<NestedProcessor> operations)
This tag encloses a series of nested processors that perform operations on group entities.
void batchInsert(MuleMessage message, String operationId, Collection<BaseEntry<?>> entries)
The function of this sub processor is to add insert operations into the current batch for the given entries This processor is intended to be used nested inside batch-contacts or batch-groups, although there's no syntactic validation inside the connector's XSD enforcing that.
void batchUpdate(MuleMessage message, String operationId, Collection<BaseEntry<?>> entries)
The function of this sub processor is to add updated operations into the current batch for the given entries This processor is intended to be used nested inside batch-contacts or batch-groups, although there's no syntactic validation inside the connector's XSD enforcing that.
ContactGroupEntry createGroup(ContactGroupEntry group)
Inserts a new group
void deleteContact(ContactEntry entry)
Deletes a given contact
void deleteContactById(String contactId)
Deletes a contact signaled by its id
void deleteContactPhoto(ContactEntry contact)
Deletes the photo associated to a given contact
void deleteContactPhotoById(String contactId)
Deletes the photo of a contact signaled by its id
void deleteGroup(ContactGroupEntry group)
Deletes the given group
void deleteGroupById(String groupId)
Deletes a group signaled by its id
InputStream downloadPhoto(ContactEntry contact)
Downloads the photo of a given contact
InputStream downloadPhotoById(String id)
Downloads the photo of a contact signaled by its id contact and returns it as an input stream
String getAccessToken()
String getAccessTokenId()
String getApplicationName()
String getConsumerKey()
String getConsumerSecret()
ContactEntry getContactById(String id)
Retrieves a contact by id
List<ContactEntry> getContacts(String updatedMin, String updatedMax, String datetimeFormat, String fullTextQuery, int maxResults, int firstResult, ContactQuery.SortOrder sortOrder, Boolean showDeleted, ContactQuery.OrderBy orderBy, String groupId)
Retrieves all the contacts matching the given criterias.
ContactGroupEntry getGroupById(String id)
Retrieves a group by id
ContactGroupEntry getGroupByName(String groupName)
Retrieves a group with the given name
List<ContactGroupEntry> getGroups(String updatedMin, String updatedMax, String datetimeFormat)
Returns all the groups the authenticated user has access to
IdentifierPolicy getIdentifierPolicy()
String getScope()
ContactEntry insertContact(ContactEntry contact)
Inserts a new contact
void postAuth()
void setAccessToken(String accessToken)
void setApplicationName(String applicationName)
void setConsumerKey(String consumerKey)
void setConsumerSecret(String consumerSecret)
void setIdentifierPolicy(IdentifierPolicy identifierPolicy)
void setScope(String scope)
void setService(ContactsService contactsService)
ContactEntry updateContact(ContactEntry contact)
Updates a contact entry
void updateContactPhoto(String contactId, InputStream in)
Updates the photo of a contact signaled by its id taken a java.io.InputStream as an input
ContactGroupEntry updateGroup(ContactGroupEntry group)
Updates the state of a group
Protected Methods
final ContactsService getService()
[Expand]
Inherited Methods
From class org.mule.modules.google.AbstractGoogleOAuthConnector
From class java.lang.Object

Constants

private static final String BATCH_REQUEST

Constant Value: "BATCH_REQUEST"

private static final String CONTACT_BATCH_FEED_URL

Constant Value: "https://www.google.com/m8/feeds/contacts/default/full/batch"

private static final String CONTACT_FEED_URL

Constant Value: "https://www.google.com/m8/feeds/contacts/default/full"

private static final String GROUP_BATCH_FEED_URL

Constant Value: "https://www.google.com/m8/feeds/groups/default/full/batch"

private static final String GROUP_FEED_URL

Constant Value: "https://www.google.com/m8/feeds/groups/default/full"

private static final int MAX_BATCH_OPERATIONS

Constant Value: 100 (0x00000064)

Fields

private String accessToken

private String applicationName

Application name registered on Google API console

private String consumerKey

The OAuth2 consumer key

private String consumerSecret

The OAuth2 consumer secret

private URL contactBatchUrl

Contacts batch atom feed url

private URL contactFeedURL

Contacts atom feed url

private ContactsService contactsService

The actual instance of the com.google.gdata.client.contacts.ContactsService

private URL groupFeedURL

Groups atom feed url

private URL grouptBatchUrl

Groups batch atom feed url

private IdentifierPolicy identifierPolicy

This policy represents which id we want to use to represent each google account. PROFILE means that we want the google profile id. That means, the user's primary key in google's DB. This is a long number represented as a string. EMAIL means you want to use the account's email address

private String scope

The OAuth2 scopes you want to request

Public Constructors

public GoogleContactsConnector ()

Public Methods

public ContactEntry addGroup (ContactEntry contact, String groupId)

Adds a group to a given contact

Parameters
contact An instance of com.google.gdata.data.contacts.ContactEntry representing the contact to be updated
groupId The id of the group
Returns
  • an instance of com.google.gdata.data.contacts.ContactEntry representing the contact's updated state
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public List<BatchResult> batchContacts (String batchId, List<NestedProcessor> operations)

This tag encloses a series of nested processors that perform operations on contacts entities

Parameters
batchId An id to identify the batch
operations A list with instances of org.mule.api.NestedProcessor representing the operations to be performed in the batch
Returns
  • a list with instances of org.mule.modules.google.api.domain.BatchResult
Throws
Exception if an error is encountered

public void batchDelete (MuleMessage message, String operationId, Collection<BaseEntry<?>> entries)

The function of this sub processor is to add updated operations into the current batch for the given entries This processor is intended to be used nested inside batch-contacts or batch-groups, although there's no syntactic validation inside the connector's XSD enforcing that. However, if you don't use it that way, then it's most likely to throw a java.lang.IllegalStateException

Parameters
message The current mule message
operationId Id to identify this particular operation inside the batch
entries A collection with instances of com.google.gdata.data.BaseEntry to be batch updated
Throws
IllegalStateException if not nested in batch-contact or batch-group

public List<BatchResult> batchGroups (String batchId, List<NestedProcessor> operations)

This tag encloses a series of nested processors that perform operations on group entities. According to the API's specification the maximum number of operations allowed in one batch is 100. Thus, this processor will automatically group the operations in batches of 100. According to the API's specification the maximum number of operations allowed in one batch is 100. Thus, this processor will automatically group the operations in batches of 100.

Parameters
batchId An id to identify the batch
operations A list with instances of org.mule.api.NestedProcessor representing the operations to be performed in the batch
Returns
  • a list with instances of org.mule.modules.google.api.domain.BatchResult
Throws
Exception if an error is encountered

public void batchInsert (MuleMessage message, String operationId, Collection<BaseEntry<?>> entries)

The function of this sub processor is to add insert operations into the current batch for the given entries This processor is intended to be used nested inside batch-contacts or batch-groups, although there's no syntactic validation inside the connector's XSD enforcing that. However, if you don't use it that way, then it's most likely to throw a java.lang.IllegalStateException

Parameters
message The current mule message
operationId Id to identify this particular operation inside the batch
entries A collection with instances of com.google.gdata.data.BaseEntry to be batch inserted
Throws
IllegalStateException if not nested in batch-contact or batch-group

public void batchUpdate (MuleMessage message, String operationId, Collection<BaseEntry<?>> entries)

The function of this sub processor is to add updated operations into the current batch for the given entries This processor is intended to be used nested inside batch-contacts or batch-groups, although there's no syntactic validation inside the connector's XSD enforcing that. However, if you don't use it that way, then it's most likely to throw a java.lang.IllegalStateException

Parameters
message The current mule message
operationId Id to identify this particular operation inside the batch
entries A collection with instances of com.google.gdata.data.BaseEntry to be batch updated
Throws
IllegalStateException if not nested in batch-contact or batch-group

public ContactGroupEntry createGroup (ContactGroupEntry group)

Inserts a new group

Parameters
group An instance of com.google.gdata.data.contacts.ContactGroupEntry representing the group to be inserted
Returns
  • an instance of com.google.gdata.data.contacts.ContactGroupEntry representing the newly created group
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void deleteContact (ContactEntry entry)

Deletes a given contact

Parameters
entry The contact to be deleted
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void deleteContactById (String contactId)

Deletes a contact signaled by its id

Parameters
contactId The id of the contact to be deleted
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void deleteContactPhoto (ContactEntry contact)

Deletes the photo associated to a given contact

Parameters
contact An instance of com.google.gdata.data.contacts.ContactEntry representing the contact whose photo we want deleted
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void deleteContactPhotoById (String contactId)

Deletes the photo of a contact signaled by its id

Parameters
contactId The id of the contact whose photo we want to delete
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void deleteGroup (ContactGroupEntry group)

Deletes the given group

Parameters
group An instance of com.google.gdata.data.contacts.ContactGroupEntry representing the group to be deleted
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void deleteGroupById (String groupId)

Deletes a group signaled by its id

Parameters
groupId The id of the group to be deleted
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public InputStream downloadPhoto (ContactEntry contact)

Downloads the photo of a given contact

Parameters
contact The contact whose photo we want
Returns
  • an instance of java.io.InputStream
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public InputStream downloadPhotoById (String id)

Downloads the photo of a contact signaled by its id contact and returns it as an input stream

Parameters
id The id of the contact whose photo we want
Returns
  • an instance of java.io.InputStream
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public String getAccessToken ()

public String getAccessTokenId ()

public String getApplicationName ()

public String getConsumerKey ()

public String getConsumerSecret ()

public ContactEntry getContactById (String id)

Retrieves a contact by id

Parameters
id The id of the contact
Returns
  • an instance of com.google.gdata.data.contacts.ContactEntry
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public List<ContactEntry> getContacts (String updatedMin, String updatedMax, String datetimeFormat, String fullTextQuery, int maxResults, int firstResult, ContactQuery.SortOrder sortOrder, Boolean showDeleted, ContactQuery.OrderBy orderBy, String groupId)

Retrieves all the contacts matching the given criterias. If a criteria is not provided then it's not used in the filtering. Thus, providing no criteria equals getting all contacts

Parameters
updatedMin Sets the minimum updated timestamp used for the query. Only entries with an updated timestamp equal to or later than the specified timestamp will be returned.
updatedMax Sets the maximum updated timestamp used for the query. Only entries with an updated timestamp earlier than the specified timestamp will be returned.
datetimeFormat The pattern to be used for parsing updatedMin and updatedMax
fullTextQuery Sets the full text query string that will be used for the query.
maxResults Sets the maximum number of results to return for the query. Note: a GData server may choose to provide fewer results, but will never provide more than the requested maximum.
firstResult Sets the start index for query results. This is a 1-based index.
sortOrder Valid values are NONE, ASCENDING and DESCENDING
showDeleted Wether to show deleted entries or not
orderBy The field to be used when sorting. Valid values are NONE, LAST_MODIFIED and EDITED
groupId Only show contacts from a given group
Returns
  • a list with instances of com.google.gdata.data.contacts.ContactEntry
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public ContactGroupEntry getGroupById (String id)

Retrieves a group by id

Parameters
id The id of the group to be returned
Returns
  • an instance of com.google.gdata.data.contacts.ContactGroupEntry
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public ContactGroupEntry getGroupByName (String groupName)

Retrieves a group with the given name

Parameters
groupName The name of the group you want
Returns
  • an instance of com.google.gdata.data.contacts.ContactGroupEntry or null if the group doesn't exist
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public List<ContactGroupEntry> getGroups (String updatedMin, String updatedMax, String datetimeFormat)

Returns all the groups the authenticated user has access to

Parameters
updatedMin Sets the minimum updated timestamp used for the query. Only entries with an updated timestamp equal to or later than the specified timestamp will be returned.
updatedMax Sets the maximum updated timestamp used for the query. Only entries with an updated timestamp earlier than the specified timestamp will be returned.
datetimeFormat The date pattern used to parse updatedMin and updatedMax
Returns
  • a list with instances of com.google.gdata.data.contacts.ContactGroupEntry
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public IdentifierPolicy getIdentifierPolicy ()

public String getScope ()

public ContactEntry insertContact (ContactEntry contact)

Inserts a new contact

Parameters
contact An instance of com.google.gdata.data.contacts.ContactEntry representing the contact to be inserted
Returns
  • an instance of com.google.gdata.data.contacts.ContactEntry representing the newly inserted contact
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void postAuth ()

public void setAccessToken (String accessToken)

Parameters
accessToken

public void setApplicationName (String applicationName)

Parameters
applicationName

public void setConsumerKey (String consumerKey)

Parameters
consumerKey

public void setConsumerSecret (String consumerSecret)

Parameters
consumerSecret

public void setIdentifierPolicy (IdentifierPolicy identifierPolicy)

Parameters
identifierPolicy

public void setScope (String scope)

Parameters
scope

public void setService (ContactsService contactsService)

Parameters
contactsService

public ContactEntry updateContact (ContactEntry contact)

Updates a contact entry

Parameters
contact An instance of com.google.gdata.data.contacts.ContactEntry representing the contact to be updated
Returns
  • an instance of com.google.gdata.data.contacts.ContactEntry representing the contact's updated state
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public void updateContactPhoto (String contactId, InputStream in)

Updates the photo of a contact signaled by its id taken a java.io.InputStream as an input

Parameters
contactId The id of the contact whose photo we want to update
in A java.io.InputStream with the photo's binary content
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public ContactGroupEntry updateGroup (ContactGroupEntry group)

Updates the state of a group

Parameters
group An instance of com.google.gdata.data.contacts.ContactGroupEntry with the group's new state
Returns
  • an instance of com.google.gdata.data.contacts.ContactGroupEntry reflecting the group's updated state
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

Protected Methods

protected final ContactsService getService ()