Package org.nuxeo.ecm.liveconnect.core
Class AbstractLiveConnectBlobProvider<O extends OAuth2ServiceProvider>
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.AbstractBlobProvider
-
- org.nuxeo.ecm.liveconnect.core.AbstractLiveConnectBlobProvider<O>
-
- Type Parameters:
O- The OAuth2 service provider type.
- All Implemented Interfaces:
BlobProvider,DocumentBlobProvider,LiveConnectBlobProvider<O>,BatchUpdateBlobProvider
- Direct Known Subclasses:
BoxBlobProvider,GoogleDriveBlobProvider
public abstract class AbstractLiveConnectBlobProvider<O extends OAuth2ServiceProvider> extends AbstractBlobProvider implements LiveConnectBlobProvider<O>, BatchUpdateBlobProvider, DocumentBlobProvider
Basic implementation ofBlobProviderfor live connect.- Since:
- 8.1
-
-
Field Summary
-
Fields inherited from class org.nuxeo.ecm.core.blob.AbstractBlobProvider
blobProviderId, properties
-
Fields inherited from interface org.nuxeo.ecm.liveconnect.update.BatchUpdateBlobProvider
MAX_RESULT
-
-
Constructor Summary
Constructors Constructor Description AbstractLiveConnectBlobProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected URIasURI(String link)Parse aURI.protected StringbuildBlobKey(LiveConnectFileInfo fileInfo)List<DocumentModel>checkChangesAndUpdateBlob(List<DocumentModel> docs)Check the given list of document for change and update if needed.voidclose()Should be overriden by subclasses needing something different.protected abstract StringgetCacheName()com.google.api.client.auth.oauth2.CredentialgetCredential(String user)protected com.google.api.client.auth.oauth2.CredentialgetCredential(LiveConnectFileInfo fileInfo)protected com.google.api.client.auth.oauth2.CredentialgetCredential(NuxeoOAuth2Token token)protected CredentialFactorygetCredentialFactory()Should be overriden by subclasses needing another credential factory.protected LiveConnectFilegetFile(LiveConnectFileInfo fileInfo)Returns theLiveConnectFilefrom cache, if it doesn't exist retrieves it with API and cache it.protected LiveConnectFilegetFileFromCache(LiveConnectFileInfo fileInfo)protected <T extends Serializable>
TgetFromCache(String key)OgetOAuth2Provider()protected abstract StringgetPageProviderNameForUpdate()protected booleanhasChanged(SimpleManagedBlob blob, LiveConnectFile file)Should be overriden by subclasses wanting to rely on a different fields.protected voidinvalidateInCache(LiveConnectFileInfo fileInfo)booleanisVersion(ManagedBlob blob)Should be overriden by subclasses needing something different.booleanperformsExternalAccessControl(BlobInfo blobInfo)Checks if the blob provider performs external access control checks.voidprocessDocumentsUpdate()Trigger the documents update for the implementing providers.protected voidputFileInCache(LiveConnectFile file)protected <T extends Serializable>
voidputInCache(String key, T object)BlobreadBlob(BlobInfo blobInfo)Should be overriden by subclasses needing something different.protected abstract LiveConnectFileretrieveFile(LiveConnectFileInfo fileInfo)Retrieves the file with API.booleansupportsSync()Checks if sync is supported.protected SimpleManagedBlobtoBlob(LiveConnectFile file)SimpleManagedBlobtoBlob(LiveConnectFileInfo fileInfo)protected LiveConnectFileInfotoFileInfo(String key)protected LiveConnectFileInfotoFileInfo(ManagedBlob blob)StringwriteBlob(Blob blob)Should be overriden by subclasses needing something different.-
Methods inherited from class org.nuxeo.ecm.core.blob.AbstractBlobProvider
allowByteRange, getProperties, hasCreateFromKeyPermission, initialize, isColdStorageMode, isRecordMode, isTransactional, isTransient, supportsUserUpdate, supportsUserUpdateDefaultFalse, supportsUserUpdateDefaultTrue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.blob.BlobProvider
allowByteRange, allowDirectDownload, canConvert, deleteBlob, getAppLinks, getAvailableConversions, getBinaryGarbageCollector, getBinaryManager, getFile, getProperties, getStatus, getStream, getStream, getThumbnail, getURI, hasCreateFromKeyPermission, initialize, isColdStorageMode, isRecordMode, isTransactional, isTransient, readBlob, supportsUserUpdate, updateBlob, writeBlob
-
Methods inherited from interface org.nuxeo.ecm.core.blob.DocumentBlobProvider
freezeVersion, getConvertedStream
-
-
-
-
Method Detail
-
close
public void close()
Should be overriden by subclasses needing something different.- Specified by:
closein interfaceBlobProvider
-
readBlob
public Blob readBlob(BlobInfo blobInfo) throws IOException
Should be overriden by subclasses needing something different.- Specified by:
readBlobin interfaceBlobProvider- Parameters:
blobInfo- the blob information- Returns:
- the blob
- Throws:
IOException
-
writeBlob
public String writeBlob(Blob blob) throws IOException
Should be overriden by subclasses needing something different.- Specified by:
writeBlobin interfaceBlobProvider- Parameters:
blob- the blob- Returns:
- the blob key
- Throws:
IOException
-
performsExternalAccessControl
public boolean performsExternalAccessControl(BlobInfo blobInfo)
Description copied from interface:BlobProviderChecks if the blob provider performs external access control checks.- Specified by:
performsExternalAccessControlin interfaceBlobProvider- Parameters:
blobInfo- the blob information to be read- Returns:
trueif the provider performs security checks before reading a blob,falseotherwise
-
supportsSync
public boolean supportsSync()
Description copied from interface:BlobProviderChecks if sync is supported.Sync refers to the fact that a blob from this provider may be synced with a remote system (like Nuxeo Drive) or with a process that updates things in the blob (like Binary Metadata, or WOPI).
- Specified by:
supportsSyncin interfaceBlobProvider- Returns:
trueif sync is supported
-
isVersion
public boolean isVersion(ManagedBlob blob)
Should be overriden by subclasses needing something different.- Specified by:
isVersionin interfaceBlobProvider- Parameters:
blob- the managed blob- Returns:
- true if the blob is a version or a revision
-
checkChangesAndUpdateBlob
public List<DocumentModel> checkChangesAndUpdateBlob(List<DocumentModel> docs)
Description copied from interface:BatchUpdateBlobProviderCheck the given list of document for change and update if needed. Note that session.save still needs to be called on changed documents.- Specified by:
checkChangesAndUpdateBlobin interfaceBatchUpdateBlobProvider- Parameters:
docs- to be checked for update- Returns:
- the list of DocumentModel that have changed
-
processDocumentsUpdate
public void processDocumentsUpdate()
Description copied from interface:BatchUpdateBlobProviderTrigger the documents update for the implementing providers.- Specified by:
processDocumentsUpdatein interfaceBatchUpdateBlobProvider
-
hasChanged
protected boolean hasChanged(SimpleManagedBlob blob, LiveConnectFile file)
Should be overriden by subclasses wanting to rely on a different fields.
-
getOAuth2Provider
public O getOAuth2Provider()
- Specified by:
getOAuth2Providerin interfaceLiveConnectBlobProvider<O extends OAuth2ServiceProvider>
-
toBlob
public SimpleManagedBlob toBlob(LiveConnectFileInfo fileInfo) throws IOException
- Specified by:
toBlobin interfaceLiveConnectBlobProvider<O extends OAuth2ServiceProvider>- Throws:
IOException
-
toBlob
protected SimpleManagedBlob toBlob(LiveConnectFile file)
-
buildBlobKey
protected String buildBlobKey(LiveConnectFileInfo fileInfo)
-
toFileInfo
protected LiveConnectFileInfo toFileInfo(ManagedBlob blob)
-
toFileInfo
protected LiveConnectFileInfo toFileInfo(String key)
- Since:
- 8.4
-
getFile
protected LiveConnectFile getFile(LiveConnectFileInfo fileInfo) throws IOException
Returns theLiveConnectFilefrom cache, if it doesn't exist retrieves it with API and cache it.- Parameters:
fileInfo- the file info- Returns:
- the
LiveConnectFilefrom cache, if it doesn't exist retrieves it with API and cache it - Throws:
IOException
-
getCredential
protected com.google.api.client.auth.oauth2.Credential getCredential(LiveConnectFileInfo fileInfo) throws IOException
- Throws:
IOException
-
getCredential
protected com.google.api.client.auth.oauth2.Credential getCredential(NuxeoOAuth2Token token) throws IOException
- Throws:
IOException
-
getCredential
public final com.google.api.client.auth.oauth2.Credential getCredential(String user) throws IOException
- Throws:
IOException
-
getCredentialFactory
protected CredentialFactory getCredentialFactory()
Should be overriden by subclasses needing another credential factory.
-
getFromCache
protected final <T extends Serializable> T getFromCache(String key)
-
putInCache
protected final <T extends Serializable> void putInCache(String key, T object)
-
invalidateInCache
protected final void invalidateInCache(LiveConnectFileInfo fileInfo)
-
getFileFromCache
protected final LiveConnectFile getFileFromCache(LiveConnectFileInfo fileInfo)
-
putFileInCache
protected final void putFileInCache(LiveConnectFile file)
-
getCacheName
protected abstract String getCacheName()
-
getPageProviderNameForUpdate
protected abstract String getPageProviderNameForUpdate()
-
retrieveFile
protected abstract LiveConnectFile retrieveFile(LiveConnectFileInfo fileInfo) throws IOException
Retrieves the file with API.- Parameters:
fileInfo- the file info- Returns:
- the file retrieved from API
- Throws:
IOException
-
-