Package org.nuxeo.ecm.blob
Class AbstractCloudBinaryManager
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
-
- org.nuxeo.ecm.core.blob.binary.CachingBinaryManager
-
- org.nuxeo.ecm.blob.AbstractCloudBinaryManager
-
- All Implemented Interfaces:
BinaryManager
,BlobProvider
- Direct Known Subclasses:
AzureBinaryManager
,GoogleStorageBinaryManager
,S3BinaryManager
public abstract class AbstractCloudBinaryManager extends CachingBinaryManager implements BlobProvider
- Since:
- 7.10
- Author:
- Arnaud Kervern
-
-
Field Summary
Fields Modifier and Type Field Description static String
CACHE_COUNT_PROPERTY
static String
CACHE_MIN_AGE_PROPERTY
static String
CACHE_SIZE_PROPERTY
static String
DEFAULT_CACHE_COUNT
static String
DEFAULT_CACHE_MIN_AGE
static String
DEFAULT_CACHE_SIZE
static String
DEFAULT_DIRECTDOWNLOAD
Deprecated.since 2023.7, unused.static int
DEFAULT_DIRECTDOWNLOAD_EXPIRE
static String
DIGEST_ALGORITHM_PROPERTY
protected boolean
directDownload
static String
DIRECTDOWNLOAD_EXPIRE_PROPERTY
Deprecated.since 2023.7, useBlobProviderDescriptor.DIRECTDOWNLOAD_EXPIRE_PROPERTY
instead.static String
DIRECTDOWNLOAD_PROPERTY
Deprecated.since 2023.7, useBlobProviderDescriptor.DIRECTDOWNLOAD_PROPERTY
instead.protected int
directDownloadExpire
protected String
namespace
protected boolean
transientFlag
-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.CachingBinaryManager
cachedir, fileCache, fileStorage
-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, digestPattern, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, properties, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
-
Fields inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
PROP_KEY, PROP_PATH
-
-
Constructor Summary
Constructors Constructor Description AbstractCloudBinaryManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BinaryManager
getBinaryManager()
Gets the associated binary manager, if any.protected boolean
getBooleanProperty(String key)
Gets a boolean property.protected String
getContentDispositionHeader(Blob blob, javax.servlet.http.HttpServletRequest servletRequest)
protected String
getContentTypeHeader(Blob blob)
protected String
getDefaultDigestAlgorithm()
Gets the default message digest to use to hash binaries.protected abstract FileStorage
getFileStorage()
protected int
getIntProperty(String key)
Gets an integer property, or -1 if undefined.protected int
getIntProperty(String key, int defaultValue)
Gets an integer property, ordefaultValue
if undefined.Map<String,String>
getProperties()
Returns the properties of the blob provider.protected String
getProperty(String propertyName)
protected String
getProperty(String propertyName, String defaultValue)
protected URI
getRemoteUri(String digest, ManagedBlob blob, javax.servlet.http.HttpServletRequest servletRequest)
String
getSystemPropertyName(String propertyName)
protected abstract String
getSystemPropertyPrefix()
Gets the prefix used for configuration using system properties.URI
getURI(ManagedBlob blob, BlobManager.UsageHint hint, javax.servlet.http.HttpServletRequest servletRequest)
Gets anURI
for the content of a managed blob.void
initialize(String blobProviderId, Map<String,String> properties)
Initializes the binary manager.protected abstract BinaryGarbageCollector
instantiateGarbageCollector()
protected boolean
isDirectDownload()
boolean
isTransient()
Checks whether this blob provider is transient: blobs may disappear after a while, so a caller should not rely on them being available forever.boolean
performsExternalAccessControl(BlobInfo blobInfo)
Checks if the blob provider performs external access control checks.Blob
readBlob(BlobInfo blobInfo)
Reads aBlob
from storage.abstract void
removeBinaries(Collection<String> digests)
Remove definitively a set of binariesprotected abstract void
setupCloudClient()
Configure Cloud client using propertiesboolean
supportsUserUpdate()
Checks if user update is supported.protected boolean
supportsUserUpdateDefaultTrue()
String
writeBlob(Blob blob)
Writes aBlob
to storage and returns information about it.-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.CachingBinaryManager
close, getBinary, getBinary, getFile, initializeCache, initializeCache, initializeCache
-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
computeDigestPattern, getBinary, getDescriptor, getDigestAlgorithm, getGarbageCollector, isValidDigest, setDescriptor, storeAndDigest, toHexString
-
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, close, deleteBlob, getAppLinks, getAvailableConversions, getBinaryGarbageCollector, getFile, getStatus, getStream, getStream, getThumbnail, hasCreateFromKeyPermission, isColdStorageMode, isRecordMode, isTransactional, isVersion, readBlob, supportsSync, updateBlob, writeBlob
-
-
-
-
Field Detail
-
directDownload
protected boolean directDownload
-
directDownloadExpire
protected int directDownloadExpire
-
transientFlag
protected boolean transientFlag
-
namespace
protected String namespace
-
CACHE_SIZE_PROPERTY
public static final String CACHE_SIZE_PROPERTY
- See Also:
- Constant Field Values
-
CACHE_COUNT_PROPERTY
public static final String CACHE_COUNT_PROPERTY
- See Also:
- Constant Field Values
-
CACHE_MIN_AGE_PROPERTY
public static final String CACHE_MIN_AGE_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_SIZE
public static final String DEFAULT_CACHE_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_COUNT
public static final String DEFAULT_CACHE_COUNT
- See Also:
- Constant Field Values
-
DEFAULT_CACHE_MIN_AGE
public static final String DEFAULT_CACHE_MIN_AGE
- See Also:
- Constant Field Values
-
DIRECTDOWNLOAD_PROPERTY
@Deprecated public static final String DIRECTDOWNLOAD_PROPERTY
Deprecated.since 2023.7, useBlobProviderDescriptor.DIRECTDOWNLOAD_PROPERTY
instead.- See Also:
- Constant Field Values
-
DEFAULT_DIRECTDOWNLOAD
@Deprecated public static final String DEFAULT_DIRECTDOWNLOAD
Deprecated.since 2023.7, unused.- See Also:
- Constant Field Values
-
DIRECTDOWNLOAD_EXPIRE_PROPERTY
@Deprecated public static final String DIRECTDOWNLOAD_EXPIRE_PROPERTY
Deprecated.since 2023.7, useBlobProviderDescriptor.DIRECTDOWNLOAD_EXPIRE_PROPERTY
instead.- See Also:
- Constant Field Values
-
DEFAULT_DIRECTDOWNLOAD_EXPIRE
public static final int DEFAULT_DIRECTDOWNLOAD_EXPIRE
- See Also:
- Constant Field Values
-
DIGEST_ALGORITHM_PROPERTY
public static final String DIGEST_ALGORITHM_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSystemPropertyPrefix
protected abstract String getSystemPropertyPrefix()
Gets the prefix used for configuration using system properties.
-
getFileStorage
protected abstract FileStorage getFileStorage()
-
instantiateGarbageCollector
protected abstract BinaryGarbageCollector instantiateGarbageCollector()
-
removeBinaries
public abstract void removeBinaries(Collection<String> digests)
Description copied from interface:BinaryManager
Remove definitively a set of binaries- Specified by:
removeBinaries
in interfaceBinaryManager
- Overrides:
removeBinaries
in classAbstractBinaryManager
- Parameters:
digests
- a set of digests, must not benull
.
-
setupCloudClient
protected abstract void setupCloudClient() throws IOException
Configure Cloud client using properties- Throws:
IOException
-
initialize
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
Description copied from interface:BinaryManager
Initializes the binary manager.- Specified by:
initialize
in interfaceBinaryManager
- Specified by:
initialize
in interfaceBlobProvider
- Overrides:
initialize
in classCachingBinaryManager
- Parameters:
blobProviderId
- the blob provider id for this binary managerproperties
- initialization properties- Throws:
IOException
-
getBinaryManager
public BinaryManager getBinaryManager()
Description copied from interface:BlobProvider
Gets the associated binary manager, if any.- Specified by:
getBinaryManager
in interfaceBlobProvider
- Returns:
- the binary manager, or
null
-
readBlob
public Blob readBlob(BlobInfo blobInfo) throws IOException
Description copied from interface:BlobProvider
Reads aBlob
from storage.- Specified by:
readBlob
in interfaceBlobProvider
- Parameters:
blobInfo
- the blob information- Returns:
- the blob
- Throws:
IOException
-
writeBlob
public String writeBlob(Blob blob) throws IOException
Description copied from interface:BlobProvider
Writes aBlob
to storage and returns information about it.Called to store a user-created blob.
- 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
-
supportsUserUpdate
public boolean supportsUserUpdate()
Description copied from interface:BlobProvider
Checks if user update is supported.A user update refers to the fact that a blob from this provider may be overwritten with another blob, wherever the original blob may occur (usually in a document property).
- Specified by:
supportsUserUpdate
in interfaceBlobProvider
- Returns:
true
if user update is supported
-
supportsUserUpdateDefaultTrue
protected boolean supportsUserUpdateDefaultTrue()
-
getURI
public URI getURI(ManagedBlob blob, BlobManager.UsageHint hint, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
Description copied from interface:BlobProvider
Gets anURI
for the content of a managed blob.- Specified by:
getURI
in interfaceBlobProvider
- Parameters:
blob
- the managed blobhint
-BlobManager.UsageHint
servletRequest
- the servlet request, ornull
- Returns:
- the
URI
, ornull
if none available - Throws:
IOException
-
isDirectDownload
protected boolean isDirectDownload()
-
getRemoteUri
protected URI getRemoteUri(String digest, ManagedBlob blob, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
- Throws:
IOException
-
getIntProperty
protected int getIntProperty(String key)
Gets an integer property, or -1 if undefined.
-
getIntProperty
protected int getIntProperty(String key, int defaultValue)
Gets an integer property, ordefaultValue
if undefined.- Since:
- 11.4
-
getBooleanProperty
protected boolean getBooleanProperty(String key)
Gets a boolean property.- Since:
- 10.3
-
getContentDispositionHeader
protected String getContentDispositionHeader(Blob blob, javax.servlet.http.HttpServletRequest servletRequest)
-
getDefaultDigestAlgorithm
protected String getDefaultDigestAlgorithm()
Description copied from class:AbstractBinaryManager
Gets the default message digest to use to hash binaries.- Overrides:
getDefaultDigestAlgorithm
in classAbstractBinaryManager
-
isTransient
public boolean isTransient()
Description copied from interface:BlobProvider
Checks whether this blob provider is transient: blobs may disappear after a while, so a caller should not rely on them being available forever.- Specified by:
isTransient
in interfaceBlobProvider
-
getProperties
public Map<String,String> getProperties()
Description copied from interface:BlobProvider
Returns the properties of the blob provider.- Specified by:
getProperties
in interfaceBlobProvider
-
-