public class

GoogleSpreadSheetConnector

extends AbstractGoogleOAuthConnector
java.lang.Object
   ↳ org.mule.modules.google.AbstractGoogleOAuthConnector
     ↳ org.mule.module.google.spreadsheet.GoogleSpreadSheetConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Connector for accessing, creating and modifying google docs spreadsheets. This connector uses OAuth2 for authentication.

Summary

[Expand]
Inherited Constants
From class org.mule.modules.google.AbstractGoogleOAuthConnector
Fields
private String accessToken
private String applicationName Application name to communicate to google
private String consumerKey The OAuth consumer key
private String consumerSecret The OAuth consumer secret
private DocsService docService
private FeedURLFactory factory
private static Logger logger
private String scope The OAuth scopes you want to request
private SpreadsheetService spreadsheetService
[Expand]
Inherited Fields
From class org.mule.modules.google.AbstractGoogleOAuthConnector
Public Constructors
GoogleSpreadSheetConnector()
Public Methods
void createSpreadsheet(String title)
Creates a new spreadsheet using a given title
Worksheet createWorksheet(String spreadsheet, int spreadsheetIndex, String title, int rowCount, int colCount)
Creates a new worksheet for an specified spreadsheet
void deleteWorksheet(String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)
Deletes an specified worksheet
String getAccessToken()
List<Row> getAllCells(String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)
Returns a list of Row in which each entry represents one of the initialized cells on a worksheet
String getAllCellsAsCsv(String spreadsheet, String worksheet, String columnSeparator, String lineSeparator, int spreadsheetIndex, int worksheetIndex)
Returns a CSV file representing all the initialized cells in a worksheet.
List<Spreadsheet> getAllSpreadsheets()
Returns all the spreadsheets associated with the user's account
List<Worksheet> getAllWorksheets(String spreadsheet, int spreadsheetIndex)
Lists all the worksheets contained in an specified spreadsheet
String getApplicationName()
List<Person> getAuthors(String spreadsheet, int spreadsheetIndex)
Returns a list of com.google.gdata.data.Person where each entry represent a a contributor on a specified spreadsheet
List<Row> getCellRange(String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex, Integer minRow, Integer maxRow, Integer minCol, Integer maxCol)
Returns a list of Row containing the cells contained in a given range
String getCellRangeAsCsv(String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex, String columnSeparator, String lineSeparator, Integer minRow, Integer maxRow, Integer minCol, Integer maxCol)
Returns a CSV file representing the requested cell range.
Object getClient()
Row getColumnHeaders(String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)
This processor returns the a worksheet's first row
String getConsumerKey()
String getConsumerSecret()
String getScope()
List<Spreadsheet> getSpreadsheetsByTitle(String title)
Returns a list of Spreadsheet with all the spreadsheets associated with the user which title matches the one specified.
List<Worksheet> getWorksheetByTitle(String spreadsheet, String title, int spreadsheetIndex)
Returns a list of Worksheet which title matches the one specified.
void postAuth()
void purgeWorksheet(String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)
This processors deletes all the cell entries of a specified worksheet.
List<Row> search(String spreadsheet, String worksheet, String query, int spreadsheetIndex, int worksheetIndex)
Performs a full-text search on a worksheet and returns a list of Row in which each entry represent a cell containing a matching value
void setAccessToken(String accessToken)
void setApplicationName(String applicationName)
void setConsumerKey(String consumerKey)
void setConsumerSecret(String consumerSecret)
void setCsvValues(String spreadsheet, String worksheet, String csv, int startingRow, int startingColumn, String lineSeparator, String columnSeparator, int spreadsheetIndex, int worksheetIndex, boolean purge)
Performs a batch update of a worksheet's cells taking values from a csv String.
void setDocService(DocsService docService)
void setRowValues(List<Row> rows, String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex, boolean purge)
Performs a batch update of a worksheet's cells taking values from a list of Row taken from the message payload.
void setScope(String scope)
void setSpreadsheetService(SpreadsheetService spreadsheetService)
void updateWorksheetMetadata(String spreadsheet, String worksheet, String title, Boolean draft, Boolean canEdit, String summary, int rowCount, int colCount, int spreadsheetIndex, int worksheetIndex)
This processor allows updating a worksheet's metadata, constituted by its title, dimensions, summary, draft and editability status.
[Expand]
Inherited Methods
From class org.mule.modules.google.AbstractGoogleOAuthConnector
From class java.lang.Object
From interface org.mule.api.context.MuleContextAware

Fields

private String accessToken

private String applicationName

Application name to communicate to google

private String consumerKey

The OAuth consumer key

private String consumerSecret

The OAuth consumer secret

private DocsService docService

private FeedURLFactory factory

private static Logger logger

private String scope

The OAuth scopes you want to request

private SpreadsheetService spreadsheetService

Public Constructors

public GoogleSpreadSheetConnector ()

Public Methods

public void createSpreadsheet (String title)

Creates a new spreadsheet using a given title

Parameters
title The title you want the new spreadsheet to have
Throws
OAuthException if there's an error authenticating
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public Worksheet createWorksheet (String spreadsheet, int spreadsheetIndex, String title, int rowCount, int colCount)

Creates a new worksheet for an specified spreadsheet

Parameters
spreadsheet The title of the spreadsheet that will contain the new worksheet
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
title The title you want the new worksheet to have
rowCount The initial number of rows you want the worksheet to have
colCount The initial number of columns you want the worksheet to have
Returns
  • an instance of Worksheet representing the newly created worksheet
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 deleteWorksheet (String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)

Deletes an specified worksheet

Parameters
spreadsheet The title of the spreadsheet that contains the worksheet to be deleted
worksheet The title of the worksheet you want to delete
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
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 List<Row> getAllCells (String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)

Returns a list of Row in which each entry represents one of the initialized cells on a worksheet

Parameters
spreadsheet The title of the spreadsheet containing the worksheet on which the cells are
worksheet The title of the worksheet containing the cells you want to get
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
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 getAllCellsAsCsv (String spreadsheet, String worksheet, String columnSeparator, String lineSeparator, int spreadsheetIndex, int worksheetIndex)

Returns a CSV file representing all the initialized cells in a worksheet. Athough this method is intended for generating a CSV file, notice that the column and line separator are customizable so you could use it to generated a text delimited file that is not strictly speaking a CSV. The generated file will have one line per cell and the following columns structure Row Number | Column Number | evaluated Value

Parameters
spreadsheet The title of the spreadsheet containing the worksheet on which the cells are
worksheet The title of the worksheet containing the cells you want to get
columnSeparator Specifies the character to be used as a column sperator. Defaults to a comma character
lineSeparator Specifies the character to be used as a line separator. Defaults to the new line \n character
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
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<Spreadsheet> getAllSpreadsheets ()

Returns all the spreadsheets associated with the user's account

Returns
  • a list of @{link org.mule.module.google.spreadsheet.model.Spreadsheet}
Throws
OAuthException if there's an error authenticating
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public List<Worksheet> getAllWorksheets (String spreadsheet, int spreadsheetIndex)

Lists all the worksheets contained in an specified spreadsheet

Parameters
spreadsheet The title of the spreadsheet you want to get the worksheets from
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
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 getApplicationName ()

public List<Person> getAuthors (String spreadsheet, int spreadsheetIndex)

Returns a list of com.google.gdata.data.Person where each entry represent a a contributor on a specified spreadsheet

Parameters
spreadsheet The title of the spreadsheet from which the info should be taken from
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
  • a list of com.google.gdata.data.Person where each entry represent a spreadsheet's contributor
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<Row> getCellRange (String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex, Integer minRow, Integer maxRow, Integer minCol, Integer maxCol)

Returns a list of Row containing the cells contained in a given range

Parameters
spreadsheet The title of the spreadsheet containing the worksheet on which the cells are
worksheet The title of the worksheet containing the cells you want to get
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
minRow The range starting row. This is a 1-based index
maxRow The range ending row. This is a 1-based index
minCol The range starting column. This is a 1-based index
maxCol The range ending column. This is a 1-based index
Returns
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 getCellRangeAsCsv (String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex, String columnSeparator, String lineSeparator, Integer minRow, Integer maxRow, Integer minCol, Integer maxCol)

Returns a CSV file representing the requested cell range. Athough this method is intended for generating a CSV file, notice that the column and line separator are customizable so you could use it to generated a text delimited file that is not strictly speaking a CSV. The generated file will have one line per cell and the following columns structure Row Number | Column Number | evaluated Value

Parameters
spreadsheet The title of the spreadsheet containing the worksheet on which the cells are
worksheet The title of the worksheet containing the cells you want to get
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
columnSeparator Specifies the character to be used as a column sperator. Defaults to a comma character
lineSeparator Specifies the character to be used as a line separator. Defaults to the new line \n character
minRow The range starting row. This is a 1-based index
maxRow The range ending row. This is a 1-based index
minCol The range starting column. This is a 1-based index
maxCol The range ending column. This is a 1-based index
Returns
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end

public Object getClient ()

public Row getColumnHeaders (String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)

This processor returns the a worksheet's first row

Parameters
spreadsheet The title of the spreadsheet from which the info should be taken from
worksheet The title of the worksheet from which the info should be taken from
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
  • an instance of Row is the worksheet has a first row initialized, null otherwise
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 getConsumerKey ()

public String getConsumerSecret ()

public String getScope ()

public List<Spreadsheet> getSpreadsheetsByTitle (String title)

Returns a list of Spreadsheet with all the spreadsheets associated with the user which title matches the one specified.

Parameters
title The title to be used in the search
Returns
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<Worksheet> getWorksheetByTitle (String spreadsheet, String title, int spreadsheetIndex)

Returns a list of Worksheet which title matches the one specified. This is not a global search. Only worksheets attached to a specified spreadsheet will be considered

Parameters
spreadsheet The title of the spreadsheet in which you want to perform the search
title The title to be used in the search
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
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 purgeWorksheet (String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex)

This processors deletes all the cell entries of a specified worksheet.

Parameters
spreadsheet The title of the spreadsheet containing the worksheet to be purged
worksheet The title of the worksheet to be purged
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
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<Row> search (String spreadsheet, String worksheet, String query, int spreadsheetIndex, int worksheetIndex)

Performs a full-text search on a worksheet and returns a list of Row in which each entry represent a cell containing a matching value

Parameters
spreadsheet The title of the spreadsheet containing the worksheet on which the cells are
worksheet The title of the worksheet containing the cells you want to get
query A full text search string, with space-separated keywords
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Returns
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 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 setCsvValues (String spreadsheet, String worksheet, String csv, int startingRow, int startingColumn, String lineSeparator, String columnSeparator, int spreadsheetIndex, int worksheetIndex, boolean purge)

Performs a batch update of a worksheet's cells taking values from a csv String. This csv file can have multiple lines and columns and you get to specify what those separators are. You can manually specify the csv string or else it will automatically taken from the message payload

Parameters
spreadsheet The title of the spreadsheet you want to update
worksheet The title of the worksheet you want to update
csv The csv content to be set on the worksheet. You can manually specify it or else it will be taken from the message payload
startingRow The number of the row where the first line of the csv will be set into. This is a 1-based index
startingColumn The number of the column where the first value of each line of the csv will be set into. This is a 1-based index
lineSeparator Specifies the character to be used as a line separator. Defaults to the new line \n character
columnSeparator Specifies the character to be used as a column sperator. Defaults to a comma character
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
purge If true, the worksheet will be purged before the values are set
Throws
Exception if an error occurs

public void setDocService (DocsService docService)

Parameters
docService

public void setRowValues (List<Row> rows, String spreadsheet, String worksheet, int spreadsheetIndex, int worksheetIndex, boolean purge)

Performs a batch update of a worksheet's cells taking values from a list of Row taken from the message payload.

Parameters
rows A list of Row taken from the message payload describing the values to be set
spreadsheet The title of the spreadsheet you want to update
worksheet The title of the worksheet you want to update
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
purge If true, the worksheet will be purged before the values are set
Throws
Exception if an error occurs

public void setScope (String scope)

Parameters
scope

public void setSpreadsheetService (SpreadsheetService spreadsheetService)

Parameters
spreadsheetService

public void updateWorksheetMetadata (String spreadsheet, String worksheet, String title, Boolean draft, Boolean canEdit, String summary, int rowCount, int colCount, int spreadsheetIndex, int worksheetIndex)

This processor allows updating a worksheet's metadata, constituted by its title, dimensions, summary, draft and editability status.

Parameters
spreadsheet The title of the spreadsheet you want to update
worksheet The title of the worksheet you want to update
title If specified, it changes the title you want to set
draft If specified, it changes the value of the draft property
canEdit If specified, it changes the worksheet's editability
summary If specified, it changes the worksheet's summary
rowCount If a value greater than zero is specified, it changes the amount of rows in the worksheet
colCount If a value greater than zero is specified, it changes the amount of columns in the worksheet
spreadsheetIndex Google's api allows for several spreadsheet to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
worksheetIndex Google's api allows for several worksheets to have the same name. In this cases it returns a list with all the ones matching the given title. Use this optional attribute to specify the zero-based list index of the want you want to use
Throws
IOException if there's a communication error with google's servers
ServiceException if the operation raises an error on google's end