Class GoogleDriveBlobProvider
java.lang.Object
org.nuxeo.ecm.core.blob.AbstractBlobProvider
org.nuxeo.ecm.liveconnect.core.AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
org.nuxeo.ecm.liveconnect.google.drive.GoogleDriveBlobProvider
- All Implemented Interfaces:
BlobProvider,DocumentBlobProvider,LiveConnectBlobProvider<GoogleOAuth2ServiceProvider>,BatchUpdateBlobProvider
public class GoogleDriveBlobProvider
extends AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
Provider for blobs getting information from Google Drive.
- Since:
- 7.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringprotected static final com.google.api.client.util.ObjectParserstatic final intstatic final Stringstatic final StringFields inherited from class org.nuxeo.ecm.core.blob.AbstractBlobProvider
blobProviderId, propertiesFields inherited from interface org.nuxeo.ecm.liveconnect.update.BatchUpdateBlobProvider
MAX_RESULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected InputStreamdoGet(LiveConnectFileInfo fileInfo, URI url) Executes a GET request with the user's credentials.protected <T> TexecuteAndCache(String cacheKey, com.google.api.services.drive.DriveRequest<T> request, Class<T> aClass) Executes aDriveRequestand caches the unparsed response.freezeVersion(ManagedBlob blob, Document doc) Returns a new managed blob pointing to a fixed version of the original blob.protected StringgetAlternateUrl(ManagedBlob blob) protected com.google.api.services.drive.model.AppgetAppLinks(String username, ManagedBlob blob) Returns a list of application links for the given blob.getAvailableConversions(ManagedBlob blob, BlobManager.UsageHint hint) Gets a map of available MIME type conversions and correspondingURIfor a managed blob.protected StringgetConvertedStream(ManagedBlob blob, String mimeType, DocumentModel doc) Gets anInputStreamfor a conversion to the given MIME type.protected CredentialFactoryShould be overriden by subclasses needing another credential factory.protected StringgetDownloadUrl(ManagedBlob blob) Gets the URL to which we can redirect to let the user download the file.protected com.google.api.services.drive.model.FilegetDriveFile(LiveConnectFileInfo fileInfo) Retrieves aFileresource and caches the unparsed response.protected StringgetEmbedUrl(ManagedBlob blob) Gets the URL to which we can redirect to let the user see a preview of the file.getExportLinks(ManagedBlob blob) Gets the export link.protected com.google.api.services.drive.model.FilegetPartialFile(String user, String fileId, String... fields) Retrieve a partialFileresource.protected com.google.api.services.drive.model.RevisiongetRevision(LiveConnectFileInfo fileInfo) Retrieves aRevisionresource and caches the unparsed response.protected com.google.api.services.drive.model.RevisionListgetRevisionList(LiveConnectFileInfo fileInfo) Retrieves the list ofRevisionresources for a file.protected com.google.api.services.drive.DrivegetService(String user) protected StringgetServiceUser(String username) getStream(ManagedBlob blob) Gets anInputStreamfor the data of a managed blob.protected InputStreamgetStream(ManagedBlob blob, URI uri) protected StringgetStreamUrl(ManagedBlob blob) Gets the URL from which we can stream the content of the file.getThumbnail(ManagedBlob blob) Gets anInputStreamfor a thumbnail of a managed blob.protected StringgetThumbnailUrl(ManagedBlob blob) Gets the URL from which we can stream a thumbnail.getURI(ManagedBlob blob, BlobManager.UsageHint usage, javax.servlet.http.HttpServletRequest servletRequest) Gets anURIfor the content of a managed blob.protected booleanhasChanged(SimpleManagedBlob blob, LiveConnectFile file) Should be overriden by subclasses wanting to rely on a different fields.voidinitialize(String blobProviderId, Map<String, String> properties) Initializes the blob provider.protected BlobretrieveBlobConversion(ManagedBlob blob, String mimeType, DocumentModel doc) Retrieve a stored conversion of the given blobprotected LiveConnectFileretrieveFile(LiveConnectFileInfo fileInfo) Retrieves the file with API.protected voidstoreBlobConversion(Document doc, String blobKey, Blob blob) Store a conversion of the given blobMethods inherited from class org.nuxeo.ecm.liveconnect.core.AbstractLiveConnectBlobProvider
asURI, buildBlobKey, checkChangesAndUpdateBlob, close, getCredential, getCredential, getCredential, getFile, getFileFromCache, getFromCache, getOAuth2Provider, invalidateInCache, isVersion, performsExternalAccessControl, processDocumentsUpdate, putFileInCache, putInCache, readBlob, supportsSync, toBlob, toBlob, toFileInfo, toFileInfo, writeBlobMethods inherited from class org.nuxeo.ecm.core.blob.AbstractBlobProvider
allowByteRange, getProperties, hasCreateFromKeyPermission, isColdStorageMode, isRecordMode, isTransactional, isTransient, supportsUserUpdate, supportsUserUpdateDefaultFalse, supportsUserUpdateDefaultTrueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.core.blob.BlobProvider
allowByteRange, allowDirectDownload, canConvert, deleteBlob, getBinaryGarbageCollector, getBinaryManager, getFile, getProperties, getStatus, getStream, hasCreateFromKeyPermission, isColdStorageMode, isRecordMode, isTransactional, isTransient, readBlob, supportsUserUpdate, updateBlob, writeBlob
-
Field Details
-
PREFERRED_ICON_SIZE
public static final int PREFERRED_ICON_SIZE- See Also:
-
SERVICE_ACCOUNT_ID_PROP
- See Also:
-
SERVICE_ACCOUNT_P12_PATH_PROP
- See Also:
-
CLIENT_ID_PROP
- See Also:
-
DEFAULT_EXPORT_MIMETYPE
- See Also:
-
BLOB_CONVERSIONS_FACET
- See Also:
-
BLOB_CONVERSIONS_PROPERTY
- See Also:
-
BLOB_CONVERSION_KEY
- See Also:
-
BLOB_CONVERSION_BLOB
- See Also:
-
JSON_PARSER
protected static final com.google.api.client.util.ObjectParser JSON_PARSER
-
-
Constructor Details
-
GoogleDriveBlobProvider
public GoogleDriveBlobProvider()
-
-
Method Details
-
initialize
Description copied from interface:BlobProviderInitializes the blob provider.- Specified by:
initializein interfaceBlobProvider- Overrides:
initializein classAbstractBlobProvider- Parameters:
blobProviderId- the blob provider id for this binary managerproperties- initialization properties- Throws:
IOException
-
getCacheName
- Specified by:
getCacheNamein classAbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
-
getPageProviderNameForUpdate
- Specified by:
getPageProviderNameForUpdatein classAbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
-
getURI
public URI getURI(ManagedBlob blob, BlobManager.UsageHint usage, javax.servlet.http.HttpServletRequest servletRequest) throws IOException Description copied from interface:BlobProviderGets anURIfor the content of a managed blob.- Parameters:
blob- the managed blobusage-BlobManager.UsageHintservletRequest- the servlet request, ornull- Returns:
- the
URI, ornullif none available - Throws:
IOException
-
getAvailableConversions
public Map<String,URI> getAvailableConversions(ManagedBlob blob, BlobManager.UsageHint hint) throws IOException Description copied from interface:BlobProviderGets a map of available MIME type conversions and correspondingURIfor a managed blob.- Parameters:
blob- the managed blobhint-BlobManager.UsageHint- Returns:
- a map of MIME types and
URI, which may be empty - Throws:
IOException
-
getThumbnail
Description copied from interface:BlobProviderGets anInputStreamfor a thumbnail of a managed blob.Like all
InputStream, the result must be closed when done with it to avoid resource leaks.- Parameters:
blob- the managed blob- Returns:
- the stream
- Throws:
IOException
-
getStreamUrl
Gets the URL from which we can stream the content of the file.Will return
nullif this is a native Google document.- Throws:
IOException
-
getDownloadUrl
Gets the URL to which we can redirect to let the user download the file.- Throws:
IOException
-
getAlternateUrl
- Throws:
IOException
-
getEmbedUrl
Gets the URL to which we can redirect to let the user see a preview of the file.- Throws:
IOException
-
getThumbnailUrl
Gets the URL from which we can stream a thumbnail.- Throws:
IOException
-
getExportLinks
Gets the export link.- Throws:
IOException
-
getStream
Description copied from interface:BlobProviderGets anInputStreamfor the data of a managed blob.Like all
InputStream, the result must be closed when done with it to avoid resource leaks.- Parameters:
blob- the managed blob- Returns:
- the stream
- Throws:
IOException
-
getConvertedStream
public InputStream getConvertedStream(ManagedBlob blob, String mimeType, DocumentModel doc) throws IOException Description copied from interface:DocumentBlobProviderGets anInputStreamfor a conversion to the given MIME type.Like all
InputStream, the result must be closed when done with it to avoid resource leaks.- Parameters:
blob- the managed blobmimeType- the MIME type to convert todoc- the document that holds the blob- Returns:
- the stream, or
nullif no conversion is available for the given MIME type - Throws:
IOException
-
getStream
- Throws:
IOException
-
getAppLinks
Description copied from interface:BlobProviderReturns a list of application links for the given blob.- Throws:
IOException
-
getServiceUser
-
getApp
protected com.google.api.services.drive.model.App getApp(String user, String appId) throws IOException - Throws:
IOException
-
freezeVersion
Description copied from interface:DocumentBlobProviderReturns a new managed blob pointing to a fixed version of the original blob.- Parameters:
blob- the original managed blobdoc- the document that holds the blob- Returns:
- a managed blob with fixed version, or
nullif no change is needed - Throws:
IOException
-
storeBlobConversion
Store a conversion of the given blob -
retrieveBlobConversion
Retrieve a stored conversion of the given blob -
hasChanged
Description copied from class:AbstractLiveConnectBlobProviderShould be overriden by subclasses wanting to rely on a different fields.- Overrides:
hasChangedin classAbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
-
getCredentialFactory
Description copied from class:AbstractLiveConnectBlobProviderShould be overriden by subclasses needing another credential factory.- Overrides:
getCredentialFactoryin classAbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
-
getService
- Throws:
IOException
-
retrieveFile
Description copied from class:AbstractLiveConnectBlobProviderRetrieves the file with API.- Specified by:
retrieveFilein classAbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>- Parameters:
fileInfo- the file info- Returns:
- the file retrieved from API
- Throws:
IOException
-
getPartialFile
protected com.google.api.services.drive.model.File getPartialFile(String user, String fileId, String... fields) throws IOException Retrieve a partialFileresource.- Throws:
IOException
-
getDriveFile
protected com.google.api.services.drive.model.File getDriveFile(LiveConnectFileInfo fileInfo) throws IOException Retrieves aFileresource and caches the unparsed response.- Returns:
- a
Fileresource - Throws:
IOException
-
getRevision
protected com.google.api.services.drive.model.Revision getRevision(LiveConnectFileInfo fileInfo) throws IOException Retrieves aRevisionresource and caches the unparsed response.- Returns:
- a
Revisionresource - Throws:
IOException
-
executeAndCache
protected <T> T executeAndCache(String cacheKey, com.google.api.services.drive.DriveRequest<T> request, Class<T> aClass) throws IOException Executes aDriveRequestand caches the unparsed response.- Throws:
IOException
-
getRevisionList
protected com.google.api.services.drive.model.RevisionList getRevisionList(LiveConnectFileInfo fileInfo) throws IOException Retrieves the list ofRevisionresources for a file.- Returns:
- a list of
Revisionresources - Throws:
IOException
-
doGet
Executes a GET request with the user's credentials.- Throws:
IOException
-
getClientId
-