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 ofBlobProvider
for 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 URI
asURI(String link)
Parse aURI
.protected String
buildBlobKey(LiveConnectFileInfo fileInfo)
List<DocumentModel>
checkChangesAndUpdateBlob(List<DocumentModel> docs)
Check the given list of document for change and update if needed.void
close()
Should be overriden by subclasses needing something different.protected abstract String
getCacheName()
com.google.api.client.auth.oauth2.Credential
getCredential(String user)
protected com.google.api.client.auth.oauth2.Credential
getCredential(LiveConnectFileInfo fileInfo)
protected com.google.api.client.auth.oauth2.Credential
getCredential(NuxeoOAuth2Token token)
protected CredentialFactory
getCredentialFactory()
Should be overriden by subclasses needing another credential factory.protected LiveConnectFile
getFile(LiveConnectFileInfo fileInfo)
Returns theLiveConnectFile
from cache, if it doesn't exist retrieves it with API and cache it.protected LiveConnectFile
getFileFromCache(LiveConnectFileInfo fileInfo)
protected <T extends Serializable>
TgetFromCache(String key)
O
getOAuth2Provider()
protected abstract String
getPageProviderNameForUpdate()
protected boolean
hasChanged(SimpleManagedBlob blob, LiveConnectFile file)
Should be overriden by subclasses wanting to rely on a different fields.protected void
invalidateInCache(LiveConnectFileInfo fileInfo)
boolean
isVersion(ManagedBlob blob)
Should be overriden by subclasses needing something different.boolean
performsExternalAccessControl(BlobInfo blobInfo)
Checks if the blob provider performs external access control checks.void
processDocumentsUpdate()
Trigger the documents update for the implementing providers.protected void
putFileInCache(LiveConnectFile file)
protected <T extends Serializable>
voidputInCache(String key, T object)
Blob
readBlob(BlobInfo blobInfo)
Should be overriden by subclasses needing something different.protected abstract LiveConnectFile
retrieveFile(LiveConnectFileInfo fileInfo)
Retrieves the file with API.boolean
supportsSync()
Checks if sync is supported.protected SimpleManagedBlob
toBlob(LiveConnectFile file)
SimpleManagedBlob
toBlob(LiveConnectFileInfo fileInfo)
protected LiveConnectFileInfo
toFileInfo(String key)
protected LiveConnectFileInfo
toFileInfo(ManagedBlob blob)
String
writeBlob(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:
close
in interfaceBlobProvider
-
readBlob
public Blob readBlob(BlobInfo blobInfo) throws IOException
Should be overriden by subclasses needing something different.- Specified by:
readBlob
in 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:
writeBlob
in interfaceBlobProvider
- Parameters:
blob
- the blob- Returns:
- the blob key
- Throws:
IOException
-
performsExternalAccessControl
public boolean performsExternalAccessControl(BlobInfo blobInfo)
Description copied from interface:BlobProvider
Checks if the blob provider performs external access control checks.- Specified by:
performsExternalAccessControl
in interfaceBlobProvider
- Parameters:
blobInfo
- the blob information to be read- Returns:
true
if the provider performs security checks before reading a blob,false
otherwise
-
supportsSync
public boolean supportsSync()
Description copied from interface:BlobProvider
Checks 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:
supportsSync
in interfaceBlobProvider
- Returns:
true
if sync is supported
-
isVersion
public boolean isVersion(ManagedBlob blob)
Should be overriden by subclasses needing something different.- Specified by:
isVersion
in 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:BatchUpdateBlobProvider
Check 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:
checkChangesAndUpdateBlob
in interfaceBatchUpdateBlobProvider
- Parameters:
docs
- to be checked for update- Returns:
- the list of DocumentModel that have changed
-
processDocumentsUpdate
public void processDocumentsUpdate()
Description copied from interface:BatchUpdateBlobProvider
Trigger the documents update for the implementing providers.- Specified by:
processDocumentsUpdate
in 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:
getOAuth2Provider
in interfaceLiveConnectBlobProvider<O extends OAuth2ServiceProvider>
-
toBlob
public SimpleManagedBlob toBlob(LiveConnectFileInfo fileInfo) throws IOException
- Specified by:
toBlob
in 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 theLiveConnectFile
from cache, if it doesn't exist retrieves it with API and cache it.- Parameters:
fileInfo
- the file info- Returns:
- the
LiveConnectFile
from 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
-
-