public class GoogleDriveBlobProvider extends AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
Modifier and Type | Field and Description |
---|---|
protected static String |
BLOB_CONVERSION_BLOB |
protected static String |
BLOB_CONVERSION_KEY |
protected static String |
BLOB_CONVERSIONS_FACET |
protected static String |
BLOB_CONVERSIONS_PROPERTY |
static String |
CLIENT_ID_PROP |
static String |
DEFAULT_EXPORT_MIMETYPE |
protected static com.google.api.client.util.ObjectParser |
JSON_PARSER |
static int |
PREFERRED_ICON_SIZE |
static String |
SERVICE_ACCOUNT_ID_PROP |
static String |
SERVICE_ACCOUNT_P12_PATH_PROP |
blobProviderId, properties
MAX_RESULT
Constructor and Description |
---|
GoogleDriveBlobProvider() |
Modifier and Type | Method and Description |
---|---|
protected InputStream |
doGet(LiveConnectFileInfo fileInfo,
URI url)
Executes a GET request with the user's credentials.
|
protected <T> T |
executeAndCache(String cacheKey,
com.google.api.services.drive.DriveRequest<T> request,
Class<T> aClass)
Executes a
DriveRequest and caches the unparsed response. |
ManagedBlob |
freezeVersion(ManagedBlob blob,
Document doc)
Returns a new managed blob pointing to a fixed version of the original blob.
|
protected String |
getAlternateUrl(ManagedBlob blob) |
protected com.google.api.services.drive.model.App |
getApp(String user,
String appId) |
List<AppLink> |
getAppLinks(String username,
ManagedBlob blob)
Returns a list of application links for the given blob.
|
Map<String,URI> |
getAvailableConversions(ManagedBlob blob,
BlobManager.UsageHint hint)
Gets a map of available MIME type conversions and corresponding
URI for a managed blob. |
protected String |
getCacheName() |
String |
getClientId() |
InputStream |
getConvertedStream(ManagedBlob blob,
String mimeType,
DocumentModel doc)
Gets an
InputStream for a conversion to the given MIME type. |
protected CredentialFactory |
getCredentialFactory()
Should be overriden by subclasses needing another credential factory.
|
protected String |
getDownloadUrl(ManagedBlob blob)
Gets the URL to which we can redirect to let the user download the file.
|
protected com.google.api.services.drive.model.File |
getDriveFile(LiveConnectFileInfo fileInfo)
Retrieves a
File resource and caches the unparsed response. |
protected String |
getEmbedUrl(ManagedBlob blob)
Gets the URL to which we can redirect to let the user see a preview of the file.
|
protected Map<String,String> |
getExportLinks(ManagedBlob blob)
Gets the export link.
|
String |
getPageProviderNameForUpdate() |
protected com.google.api.services.drive.model.File |
getPartialFile(String user,
String fileId,
String... fields)
Retrieve a partial
File resource. |
protected com.google.api.services.drive.model.Revision |
getRevision(LiveConnectFileInfo fileInfo)
Retrieves a
Revision resource and caches the unparsed response. |
protected com.google.api.services.drive.model.RevisionList |
getRevisionList(LiveConnectFileInfo fileInfo)
Retrieves the list of
Revision resources for a file. |
protected com.google.api.services.drive.Drive |
getService(String user) |
protected String |
getServiceUser(String username) |
InputStream |
getStream(ManagedBlob blob)
Gets an
InputStream for the data of a managed blob. |
protected InputStream |
getStream(ManagedBlob blob,
URI uri) |
protected String |
getStreamUrl(ManagedBlob blob)
Gets the URL from which we can stream the content of the file.
|
InputStream |
getThumbnail(ManagedBlob blob)
Gets an
InputStream for a thumbnail of a managed blob. |
protected String |
getThumbnailUrl(ManagedBlob blob)
Gets the URL from which we can stream a thumbnail.
|
URI |
getURI(ManagedBlob blob,
BlobManager.UsageHint usage,
javax.servlet.http.HttpServletRequest servletRequest)
Gets an
URI for the content of a managed blob. |
protected boolean |
hasChanged(SimpleManagedBlob blob,
LiveConnectFile file)
Should be overriden by subclasses wanting to rely on a different fields.
|
void |
initialize(String blobProviderId,
Map<String,String> properties)
Initializes the blob provider.
|
protected Blob |
retrieveBlobConversion(ManagedBlob blob,
String mimeType,
DocumentModel doc)
Retrieve a stored conversion of the given blob
|
protected LiveConnectFile |
retrieveFile(LiveConnectFileInfo fileInfo)
Retrieves the file with API.
|
protected void |
storeBlobConversion(Document doc,
String blobKey,
Blob blob)
Store a conversion of the given blob
|
asURI, buildBlobKey, checkChangesAndUpdateBlob, close, getCredential, getCredential, getCredential, getFile, getFileFromCache, getFromCache, getOAuth2Provider, invalidateInCache, isVersion, performsExternalAccessControl, processDocumentsUpdate, putFileInCache, putInCache, readBlob, toBlob, toBlob, toFileInfo, toFileInfo, writeBlob
supportsUserUpdate, supportsUserUpdateDefaultFalse, supportsUserUpdateDefaultTrue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBinaryManager, supportsUserUpdate
public static final int PREFERRED_ICON_SIZE
public static final String SERVICE_ACCOUNT_ID_PROP
public static final String SERVICE_ACCOUNT_P12_PATH_PROP
public static final String CLIENT_ID_PROP
public static final String DEFAULT_EXPORT_MIMETYPE
protected static final String BLOB_CONVERSIONS_FACET
protected static final String BLOB_CONVERSIONS_PROPERTY
protected static final String BLOB_CONVERSION_KEY
protected static final String BLOB_CONVERSION_BLOB
protected static final com.google.api.client.util.ObjectParser JSON_PARSER
public GoogleDriveBlobProvider()
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BlobProvider
initialize
in interface BlobProvider
initialize
in class AbstractBlobProvider
blobProviderId
- the blob provider id for this binary managerproperties
- initialization propertiesIOException
protected String getCacheName()
getCacheName
in class AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
public String getPageProviderNameForUpdate()
getPageProviderNameForUpdate
in class AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
public URI getURI(ManagedBlob blob, BlobManager.UsageHint usage, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
BlobProvider
URI
for the content of a managed blob.blob
- the managed blobusage
- BlobManager.UsageHint
servletRequest
- the servlet request, or null
URI
, or null
if none availableIOException
public Map<String,URI> getAvailableConversions(ManagedBlob blob, BlobManager.UsageHint hint) throws IOException
BlobProvider
URI
for a managed blob.blob
- the managed blobhint
- BlobManager.UsageHint
URI
, which may be emptyIOException
public InputStream getThumbnail(ManagedBlob blob) throws IOException
BlobProvider
InputStream
for a thumbnail of a managed blob.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
blob
- the managed blobIOException
protected String getStreamUrl(ManagedBlob blob) throws IOException
Will return null
if this is a native Google document.
IOException
protected String getDownloadUrl(ManagedBlob blob) throws IOException
IOException
protected String getAlternateUrl(ManagedBlob blob) throws IOException
IOException
protected String getEmbedUrl(ManagedBlob blob) throws IOException
IOException
protected String getThumbnailUrl(ManagedBlob blob) throws IOException
IOException
protected Map<String,String> getExportLinks(ManagedBlob blob) throws IOException
IOException
public InputStream getStream(ManagedBlob blob) throws IOException
BlobProvider
InputStream
for the data of a managed blob.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
blob
- the managed blobIOException
public InputStream getConvertedStream(ManagedBlob blob, String mimeType, DocumentModel doc) throws IOException
BlobProvider
InputStream
for a conversion to the given MIME type.
Like all InputStream
, the result must be closed when done with it to avoid resource leaks.
blob
- the managed blobmimeType
- the MIME type to convert todoc
- the document that holds the blobnull
if no conversion is available for the given MIME typeIOException
protected InputStream getStream(ManagedBlob blob, URI uri) throws IOException
IOException
public List<AppLink> getAppLinks(String username, ManagedBlob blob) throws IOException
BlobProvider
IOException
protected String getServiceUser(String username)
protected com.google.api.services.drive.model.App getApp(String user, String appId) throws IOException
IOException
public ManagedBlob freezeVersion(ManagedBlob blob, Document doc) throws IOException
BlobProvider
blob
- the original managed blobdoc
- the document that holds the blobnull
if no change is neededIOException
protected void storeBlobConversion(Document doc, String blobKey, Blob blob)
protected Blob retrieveBlobConversion(ManagedBlob blob, String mimeType, DocumentModel doc)
protected boolean hasChanged(SimpleManagedBlob blob, LiveConnectFile file)
AbstractLiveConnectBlobProvider
hasChanged
in class AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
protected CredentialFactory getCredentialFactory()
AbstractLiveConnectBlobProvider
getCredentialFactory
in class AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
protected com.google.api.services.drive.Drive getService(String user) throws IOException
IOException
protected LiveConnectFile retrieveFile(LiveConnectFileInfo fileInfo) throws IOException
AbstractLiveConnectBlobProvider
retrieveFile
in class AbstractLiveConnectBlobProvider<GoogleOAuth2ServiceProvider>
fileInfo
- the file infoIOException
protected com.google.api.services.drive.model.File getPartialFile(String user, String fileId, String... fields) throws IOException
File
resource.IOException
protected com.google.api.services.drive.model.File getDriveFile(LiveConnectFileInfo fileInfo) throws IOException
File
resource and caches the unparsed response.File
resourceIOException
protected com.google.api.services.drive.model.Revision getRevision(LiveConnectFileInfo fileInfo) throws IOException
Revision
resource and caches the unparsed response.Revision
resourceIOException
protected <T> T executeAndCache(String cacheKey, com.google.api.services.drive.DriveRequest<T> request, Class<T> aClass) throws IOException
DriveRequest
and caches the unparsed response.IOException
protected com.google.api.services.drive.model.RevisionList getRevisionList(LiveConnectFileInfo fileInfo) throws IOException
Revision
resources for a file.Revision
resourcesIOException
protected InputStream doGet(LiveConnectFileInfo fileInfo, URI url) throws IOException
IOException
public String getClientId()
Copyright © 2016 Nuxeo SA. All rights reserved.