Class DefaultBlobDispatcher
- All Implemented Interfaces:
BlobDispatcher
Alternatively, it can be configured through properties to dispatch to a blob provider based on document properties instead of the repository name.
The property name is a list of comma-separated clauses, with each clause consisting of a property, an operator and a
value. The property can be a Document
xpath, ecm:repositoryName
, ecm:path
, or, to match the
current blob being dispatched, blob:name
, blob:mime-type
, blob:encoding
, blob:digest
,
blob:length
or blob:xpath
.
Comma-separated clauses are ANDed together. The special name default
defines the default provider, and must
be present.
Available operators between property and value are =, !=, <, <= ,>, >=, ~ and ^.
The operators =, !=, <, <=, > and >= work as numeric operators if the property is numeric, otherwise as string comparisons operators.
The operator ~ does glob matching using ?
to match a single arbitrary character, and *
to match any
number of characters (including none). The operator ^ does full regexp matching.
For example, to dispatch to the "first" provider if dc:format is "video", to the "second" provider if the blob's MIME type is "video/mp4", to the "third" provider if the blob is stored as a secondary attached file, to the "fourth" provider if the lifecycle state is "approved", to the "fifth" provider if the blob's document is stored in under an "images" folder, and the document is in the default repository, and otherwise to the "other" provider:
<property name="dc:format=video">first</property>
<property name="blob:mime-type=video/mp4">second</property>
<property name="blob:xpath~files/*/file">third</property>
<property name="ecm:repositoryName=default,ecm:lifeCycleState=approved">fourth</property>
<property name="ecm:path^.*/images/.*">fifth</property>
<property name="default">other</property>
You can make use of a record blob provider by using:
<property name="records">records</property>
<property name="default">other</property>
- Since:
- 7.3
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static enum
protected static class
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.blob.BlobDispatcher
BlobDispatcher.BlobDispatch
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected String
protected static final String
Pseudo-property for the flexible record state.protected static final String
Pseudo-property for the record state.protected static final String
protected static final Pattern
protected static final String
protected static final String
Pseudo-property for the document path.protected static final String
Pseudo-property for the repository name.protected List<DefaultBlobDispatcher.Rule>
protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkBlob
(Document doc, Document.BlobAccessor accessor) Checks if the blob is stored in the expected blob provider to which it's supposed to be dispatched.protected void
checkBlobCanBeDeleted
(Document doc, String xpath) protected boolean
compare
(Object a, DefaultBlobDispatcher.Clause clause, boolean eqneq, IntPredicate predicate) protected Object
protected void
deleteBlobIfRecord
(String blobProviderId, Document doc, String xpath) getBlobProvider
(String repositoryName) Decides whichBlobProvider
to use to read a blob from the given repository if no prefix is specified in the blob key.getBlobProvider
(Document doc, Blob blob, String xpath) Decides whichBlobProvider
to use to write the given blob, and whether the provider id should be added as prefix to the managed blob key.Gets the provider ids to which this dispatcher can dispatch.protected DefaultBlobDispatcher.Clause
protected Pattern
getPatternFromGlob
(String glob) protected String
getProviderId
(Document doc, Blob blob, String blobXPath) protected Object
getValue
(Document doc, Blob blob, String blobXPath, DefaultBlobDispatcher.Clause clause) void
initialize
(Map<String, String> properties) Initializes this blob dispatcher.boolean
protected boolean
match
(Object value, DefaultBlobDispatcher.Clause clause) void
notifyAfterCopy
(Document doc) Notifies the blob dispatcher that the document has been copied.void
Notifies the blob dispatcher that the document is about to be removed.void
notifyChanges
(Document doc, Set<String> xpaths) Notifies the blob dispatcher that a set of xpaths have changed on a document.void
notifyMakeRecord
(Document doc) Notifies the blob dispatcher that the document was made a record.
-
Field Details
-
NAME_DEFAULT
- See Also:
-
NAME_RECORDS
- See Also:
-
NAME_PATTERN
-
REPOSITORY_NAME
Pseudo-property for the repository name.- See Also:
-
PATH
Pseudo-property for the document path.- See Also:
-
IS_RECORD
Pseudo-property for the record state.- Since:
- 11.1
- See Also:
-
IS_FLEXIBLE_RECORD
Pseudo-property for the flexible record state.- Since:
- 2023.1
- See Also:
-
BLOB_PREFIX
- See Also:
-
BLOB_NAME
- See Also:
-
BLOB_MIME_TYPE
- See Also:
-
BLOB_ENCODING
- See Also:
-
BLOB_DIGEST
- See Also:
-
BLOB_LENGTH
- See Also:
-
BLOB_XPATH
- See Also:
-
useRepositoryName
protected boolean useRepositoryName -
rules
-
rulesXPaths
-
providerIds
-
repositoryNames
-
defaultProviderId
-
-
Constructor Details
-
DefaultBlobDispatcher
public DefaultBlobDispatcher()
-
-
Method Details
-
initialize
Description copied from interface:BlobDispatcher
Initializes this blob dispatcher.- Specified by:
initialize
in interfaceBlobDispatcher
-
getClause
-
getPatternFromGlob
-
getBlobProviderIds
Description copied from interface:BlobDispatcher
Gets the provider ids to which this dispatcher can dispatch.Blobs already having a provider id not listed here won't be touched on write.
- Specified by:
getBlobProviderIds
in interfaceBlobDispatcher
- Returns:
- a collection containing the provider ids
-
getProviderId
-
getValue
protected Object getValue(Document doc, Blob blob, String blobXPath, DefaultBlobDispatcher.Clause clause) -
convert
-
match
-
compare
protected boolean compare(Object a, DefaultBlobDispatcher.Clause clause, boolean eqneq, IntPredicate predicate) -
getBlobProvider
Description copied from interface:BlobDispatcher
Decides whichBlobProvider
to use to read a blob from the given repository if no prefix is specified in the blob key.- Specified by:
getBlobProvider
in interfaceBlobDispatcher
- Parameters:
repositoryName
- the repository name- Returns:
- the blob provider id
-
getBlobProvider
Description copied from interface:BlobDispatcher
Decides whichBlobProvider
to use to write the given blob, and whether the provider id should be added as prefix to the managed blob key.- Specified by:
getBlobProvider
in interfaceBlobDispatcher
- Parameters:
doc
- the document containing the blobblob
- the blobxpath
- the xpath of the blob in the document- Returns:
- the blob provider id and whether it should be added as prefix
-
notifyChanges
Description copied from interface:BlobDispatcher
Notifies the blob dispatcher that a set of xpaths have changed on a document.- Specified by:
notifyChanges
in interfaceBlobDispatcher
- Parameters:
doc
- the documentxpaths
- the set of changed xpaths
-
checkBlob
Checks if the blob is stored in the expected blob provider to which it's supposed to be dispatched. If not, store it in the correct one (and maybe remove it from the previous one if it makes sense). -
notifyMakeRecord
Description copied from interface:BlobDispatcher
Notifies the blob dispatcher that the document was made a record.- Specified by:
notifyMakeRecord
in interfaceBlobDispatcher
- Parameters:
doc
- the document
-
notifyAfterCopy
Description copied from interface:BlobDispatcher
Notifies the blob dispatcher that the document has been copied.- Specified by:
notifyAfterCopy
in interfaceBlobDispatcher
- Parameters:
doc
- the new document, the result of the copy
-
notifyBeforeRemove
Description copied from interface:BlobDispatcher
Notifies the blob dispatcher that the document is about to be removed.- Specified by:
notifyBeforeRemove
in interfaceBlobDispatcher
- Parameters:
doc
- the document
-
deleteBlobIfRecord
-
checkBlobCanBeDeleted
-
isUseRepositoryName
public boolean isUseRepositoryName()- Specified by:
isUseRepositoryName
in interfaceBlobDispatcher
- Returns:
- true if the blobs are dispatched to the provider with the same name than the repository.
-