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 groupBatchUrl Groups batch atom feed url
private URL groupFeedURL Groups atom feed url
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
GoogleContactEntry addGroup(GoogleContactEntry 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<GoogleContactBaseEntity> 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<GoogleContactBaseEntity> 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<GoogleContactBaseEntity> 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.

GoogleContactGroupEntry createGroup(GoogleContactGroupEntry group)
Inserts a new group

void deleteContact(GoogleContactEntry contact)
Deletes a given contact

void deleteContactById(String contactId)
Deletes a contact signaled by its id
void deleteContactPhoto(GoogleContactEntry 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(GoogleContactGroupEntry group)
Deletes the given group

void deleteGroupById(String groupId)
Deletes a group signaled by its id

InputStream downloadPhoto(GoogleContactEntry 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 getApplicationName()
Object getClient()
String getConsumerKey()
String getConsumerSecret()
GoogleContactEntry getContactById(String id)
Retrieves a contact by id

ProviderAwarePagingDelegate<GoogleContactEntry, AbstractGoogleOAuthConnector> getContacts(String updatedMin, String updatedMax, String datetimeFormat, String fullTextQuery, ContactQuery.SortOrder sortOrder, Boolean showDeleted, ContactQuery.OrderBy orderBy, String groupId, PagingConfiguration pagingConfiguration)
Retrieves all the contacts matching the given criterias.
GoogleContactGroupEntry getGroupById(String id)
Retrieves a group by id

GoogleContactGroupEntry getGroupByName(String groupName)
Retrieves a group with the given name

ProviderAwarePagingDelegate<GoogleContactGroupEntry, AbstractGoogleOAuthConnector> getGroups(String updatedMin, String updatedMax, String datetimeFormat, PagingConfiguration pagingConfiguration)
Returns all the groups the authenticated user has access to

String getScope()
void init()
GoogleContactEntry insertContact(GoogleContactEntry contact)
Inserts a new contact

void postAuth()
void setAccessToken(String accessToken)
void setApplicationName(String applicationName)
void setConsumerKey(String consumerKey)
void setConsumerSecret(String consumerSecret)
void setScope(String scope)
void setService(ContactsService contactsService)
GoogleContactEntry updateContact(GoogleContactEntry 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

GoogleContactGroupEntry updateGroup(GoogleContactGroupEntry 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
From interface org.mule.api.context.MuleContextAware

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 groupBatchUrl

Groups batch atom feed url

private URL groupFeedURL

Groups atom feed url

private String scope

The OAuth2 scopes you want to request

Public Constructors

public GoogleContactsConnector ()

Public Methods

public GoogleContactEntry addGroup (GoogleContactEntry 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<GoogleContactBaseEntity> 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 deleted
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<GoogleContactBaseEntity> 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<GoogleContactBaseEntity> 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 GoogleContactGroupEntry createGroup (GoogleContactGroupEntry 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 (GoogleContactEntry contact)

Deletes a given contact

Parameters
contact 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 (GoogleContactEntry 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 (GoogleContactGroupEntry 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 (GoogleContactEntry 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 getApplicationName ()

public Object getClient ()

public String getConsumerKey ()

public String getConsumerSecret ()

public GoogleContactEntry 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 ProviderAwarePagingDelegate<GoogleContactEntry, AbstractGoogleOAuthConnector> getContacts (String updatedMin, String updatedMax, String datetimeFormat, String fullTextQuery, ContactQuery.SortOrder sortOrder, Boolean showDeleted, ContactQuery.OrderBy orderBy, String groupId, PagingConfiguration pagingConfiguration)

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.
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
pagingConfiguration The paging configuration object
Returns
  • an auto paginated iterator 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 GoogleContactGroupEntry 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 GoogleContactGroupEntry 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
Exception if the operation raises an error on google's end

public ProviderAwarePagingDelegate<GoogleContactGroupEntry, AbstractGoogleOAuthConnector> getGroups (String updatedMin, String updatedMax, String datetimeFormat, PagingConfiguration pagingConfiguration)

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
pagingConfiguration The pagingConfiguration object
Returns
  • an auto paginated iterator 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 String getScope ()

public void init ()

public GoogleContactEntry insertContact (GoogleContactEntry 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 setScope (String scope)

Parameters
scope

public void setService (ContactsService contactsService)

Parameters
contactsService

public GoogleContactEntry updateContact (GoogleContactEntry 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
URISyntaxException If the generation of the URL for the update endpoint fails
IllegalArgumentException If the generation of the URL for the update endpoint fails

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 GoogleContactGroupEntry updateGroup (GoogleContactGroupEntry 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 ()