Class GoogleApiReader
java.lang.Object
com.northconcepts.datapipeline.core.DataObject
com.northconcepts.datapipeline.core.Endpoint
com.northconcepts.datapipeline.core.DataEndpoint
com.northconcepts.datapipeline.core.DataReader
com.northconcepts.datapipeline.internal.lang.IntegrationReader
com.northconcepts.datapipeline.google.GoogleApiReader
- Direct Known Subclasses:
GmailMessageReader,GoogleAnalyticsReportReader,GoogleCalendarReader,GoogleContactsReader
Base class for readers that call Google APIs, holding the OAuth credential, HTTP transport and application name used to
build the API client.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.northconcepts.datapipeline.core.DataEndpoint
DataEndpoint.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Credentialprotected static final JsonFactoryprotected final HttpTransportFields inherited from class com.northconcepts.datapipeline.core.DataReader
fieldLineage, recordLineageFields inherited from class com.northconcepts.datapipeline.core.DataEndpoint
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEYFields inherited from class com.northconcepts.datapipeline.core.Endpoint
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZEFields inherited from class com.northconcepts.datapipeline.core.DataObject
id, log, name, TIMESTAMP_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionGoogleApiReader(Credential credential) Creates a reader with its own trusted HTTP transport, which is shut down when the reader is closed.GoogleApiReader(Credential credentials, HttpTransport transport) Creates a reader that uses the given transport; the caller remains responsible for shutting it down. -
Method Summary
Modifier and TypeMethodDescriptionaddExceptionProperties(DataException exception) Adds this endpoint's current state to aDataException.voidclose()Indicates that this endpoint has finished reading or writing.Returns the application name passed to the Google API client (defaults to"DataPipeline Analytics Reporting").setApplicationName(String applicationName) Sets the application name passed to the Google API client (defaults to"DataPipeline Analytics Reporting").protected <T> TsetJsonFactory(T object) Assigns the shared JSON factory to the given Google model object unless it already has one, and returns the object.protected static DatetoDate(DateTime dateTime) Converts a GoogleDateTimeto aDate, returning null for null.static DataExceptiontoException(GoogleJsonError e, HttpHeaders responseHeaders) Converts a Google JSON error into aDataExceptionholding its code and each error's message, domain, location, location type and reason; the response headers are not used.Methods inherited from class com.northconcepts.datapipeline.internal.lang.IntegrationReader
openMethods inherited from class com.northconcepts.datapipeline.core.DataReader
addLineage, available, getBufferSize, getNestedEndpoint, getNestedReader, getReader, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, readImpl, setSaveLineage, skipMethods inherited from class com.northconcepts.datapipeline.core.DataEndpoint
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toStringMethods inherited from class com.northconcepts.datapipeline.core.Endpoint
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
-
Field Details
-
JSON_FACTORY
protected static final JsonFactory JSON_FACTORY -
credentials
protected final Credential credentials -
transport
protected final HttpTransport transport
-
-
Constructor Details
-
GoogleApiReader
public GoogleApiReader(Credential credentials, HttpTransport transport) Creates a reader that uses the given transport; the caller remains responsible for shutting it down. -
GoogleApiReader
public GoogleApiReader(Credential credential) Creates a reader with its own trusted HTTP transport, which is shut down when the reader is closed.
-
-
Method Details
-
getApplicationName
Returns the application name passed to the Google API client (defaults to"DataPipeline Analytics Reporting"). -
setApplicationName
Sets the application name passed to the Google API client (defaults to"DataPipeline Analytics Reporting"). -
close
Description copied from class:DataEndpointIndicates that this endpoint has finished reading or writing.- Overrides:
closein classDataEndpoint- Throws:
DataException
-
addExceptionProperties
Description copied from class:EndpointAdds this endpoint's current state to aDataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.- Overrides:
addExceptionPropertiesin classDataReader
-
setJsonFactory
protected <T> T setJsonFactory(T object) Assigns the shared JSON factory to the given Google model object unless it already has one, and returns the object. -
toException
Converts a Google JSON error into aDataExceptionholding its code and each error's message, domain, location, location type and reason; the response headers are not used. -
toDate
Converts a GoogleDateTimeto aDate, returning null for null.
-