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
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static enumprotected static classNested classes/interfaces inherited from interface org.nuxeo.ecm.core.blob.BlobDispatcher
BlobDispatcher.BlobDispatch -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected Stringprotected static final StringPseudo-property for the flexible record state.protected static final StringPseudo-property for the record state.protected static final Stringprotected static final Patternprotected static final Stringprotected static final StringPseudo-property for the document path.protected static final StringPseudo-property for the repository name.protected List<DefaultBlobDispatcher.Rule> protected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckBlob(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 voidcheckBlobCanBeDeleted(Document doc, String xpath) protected booleancompare(Object a, DefaultBlobDispatcher.Clause clause, boolean eqneq, IntPredicate predicate) protected Objectprotected voiddeleteBlobIfRecord(String blobProviderId, Document doc, String xpath) getBlobProvider(String repositoryName) Decides whichBlobProviderto 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 whichBlobProviderto 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.Clauseprotected PatterngetPatternFromGlob(String glob) protected StringgetProviderId(Document doc, Blob blob, String blobXPath) protected ObjectgetValue(Document doc, Blob blob, String blobXPath, DefaultBlobDispatcher.Clause clause) voidinitialize(Map<String, String> properties) Initializes this blob dispatcher.booleanprotected booleanmatch(Object value, DefaultBlobDispatcher.Clause clause) voidnotifyAfterCopy(Document doc) Notifies the blob dispatcher that the document has been copied.voidNotifies the blob dispatcher that the document is about to be removed.voidnotifyChanges(Document doc, Set<String> xpaths) Notifies the blob dispatcher that a set of xpaths have changed on a document.voidnotifyMakeRecord(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:BlobDispatcherInitializes this blob dispatcher.- Specified by:
initializein interfaceBlobDispatcher
-
getClause
-
getPatternFromGlob
-
getBlobProviderIds
Description copied from interface:BlobDispatcherGets 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:
getBlobProviderIdsin 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:BlobDispatcherDecides whichBlobProviderto use to read a blob from the given repository if no prefix is specified in the blob key.- Specified by:
getBlobProviderin interfaceBlobDispatcher- Parameters:
repositoryName- the repository name- Returns:
- the blob provider id
-
getBlobProvider
Description copied from interface:BlobDispatcherDecides whichBlobProviderto use to write the given blob, and whether the provider id should be added as prefix to the managed blob key.- Specified by:
getBlobProviderin 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:BlobDispatcherNotifies the blob dispatcher that a set of xpaths have changed on a document.- Specified by:
notifyChangesin 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:BlobDispatcherNotifies the blob dispatcher that the document was made a record.- Specified by:
notifyMakeRecordin interfaceBlobDispatcher- Parameters:
doc- the document
-
notifyAfterCopy
Description copied from interface:BlobDispatcherNotifies the blob dispatcher that the document has been copied.- Specified by:
notifyAfterCopyin interfaceBlobDispatcher- Parameters:
doc- the new document, the result of the copy
-
notifyBeforeRemove
Description copied from interface:BlobDispatcherNotifies the blob dispatcher that the document is about to be removed.- Specified by:
notifyBeforeRemovein interfaceBlobDispatcher- Parameters:
doc- the document
-
deleteBlobIfRecord
-
checkBlobCanBeDeleted
-
isUseRepositoryName
public boolean isUseRepositoryName()- Specified by:
isUseRepositoryNamein interfaceBlobDispatcher- Returns:
- true if the blobs are dispatched to the provider with the same name than the repository.
-