public class DefaultBlobDispatcher extends Object implements 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
, 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 with integer
values. The operator ~ does glob matching using ?
to match a single arbitrary character, and *
to
match any number of characters (including none).
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" 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="default">other</property>
Modifier and Type | Class and Description |
---|---|
protected static class |
DefaultBlobDispatcher.Clause |
protected static class |
DefaultBlobDispatcher.Op |
protected static class |
DefaultBlobDispatcher.Rule |
BlobDispatcher.BlobDispatch
Modifier and Type | Field and Description |
---|---|
protected static String |
BLOB_DIGEST |
protected static String |
BLOB_ENCODING |
protected static String |
BLOB_LENGTH |
protected static String |
BLOB_MIME_TYPE |
protected static String |
BLOB_NAME |
protected static String |
BLOB_PREFIX |
protected static String |
BLOB_XPATH |
protected String |
defaultProviderId |
protected static String |
NAME_DEFAULT |
protected static Pattern |
NAME_PATTERN |
protected Set<String> |
providerIds |
protected static String |
REPOSITORY_NAME
Pseudo-property for the repository name.
|
protected List<String> |
repositoryNames |
protected List<DefaultBlobDispatcher.Rule> |
rules |
protected Set<String> |
rulesXPaths |
protected boolean |
useRepositoryName |
Constructor and Description |
---|
DefaultBlobDispatcher() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkBlob(Document doc,
Document.BlobAccessor accessor) |
BlobDispatcher.BlobDispatch |
getBlobProvider(Document doc,
Blob blob,
String xpath)
Decides which
BlobProvider to use to write the given blob, and whether the provider id should be added as
prefix to the managed blob key. |
String |
getBlobProvider(String repositoryName)
Decides which
BlobProvider to use to read a blob from the given repository if no prefix is specified in
the blob key. |
Collection<String> |
getBlobProviderIds()
Gets the provider ids to which this dispatcher can dispatch.
|
protected Pattern |
getPatternFromGlob(String glob) |
protected String |
getProviderId(Document doc,
Blob blob,
String blobXPath) |
void |
initialize(Map<String,String> properties)
Initializes this blob dispatcher.
|
void |
notifyChanges(Document doc,
Set<String> xpaths)
Notifies the blob dispatcher that a set of xpaths have changed on a document.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBlobProvider
protected static final String NAME_DEFAULT
protected static final Pattern NAME_PATTERN
protected static final String REPOSITORY_NAME
protected static final String BLOB_PREFIX
protected static final String BLOB_NAME
protected static final String BLOB_MIME_TYPE
protected static final String BLOB_ENCODING
protected static final String BLOB_DIGEST
protected static final String BLOB_LENGTH
protected static final String BLOB_XPATH
protected boolean useRepositoryName
protected List<DefaultBlobDispatcher.Rule> rules
protected Set<String> rulesXPaths
protected Set<String> providerIds
protected List<String> repositoryNames
protected String defaultProviderId
public DefaultBlobDispatcher()
public void initialize(Map<String,String> properties)
BlobDispatcher
initialize
in interface BlobDispatcher
protected Pattern getPatternFromGlob(String glob)
public Collection<String> getBlobProviderIds()
BlobDispatcher
Blobs already having a provider id not listed here won't be touched on write.
getBlobProviderIds
in interface BlobDispatcher
protected String getProviderId(Document doc, Blob blob, String blobXPath)
public String getBlobProvider(String repositoryName)
BlobDispatcher
BlobProvider
to use to read a blob from the given repository if no prefix is specified in
the blob key.getBlobProvider
in interface BlobDispatcher
repositoryName
- the repository namepublic BlobDispatcher.BlobDispatch getBlobProvider(Document doc, Blob blob, String xpath)
BlobDispatcher
BlobProvider
to use to write the given blob, and whether the provider id should be added as
prefix to the managed blob key.getBlobProvider
in interface BlobDispatcher
doc
- the document containing the blobblob
- the blobxpath
- the xpath of the blob in the documentpublic void notifyChanges(Document doc, Set<String> xpaths)
BlobDispatcher
notifyChanges
in interface BlobDispatcher
doc
- the documentxpaths
- the set of changed xpathsprotected void checkBlob(Document doc, Document.BlobAccessor accessor)
Copyright © 2018 Nuxeo. All rights reserved.