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
or
blob:length
. 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 >.
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 lifecycle state is "approved" and the document is in the default repository, and otherwise to the "fourth" provider:
<property name="dc:format=video">first</property> <property name="blob:mime-type=video/mp4">second</property> <property name="ecm:repositoryName=default,ecm:lifeCycleState=approved">third2</property> <property name="default">fourth</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 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<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)
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 String |
getProviderId(Document doc,
Blob blob) |
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.
|
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 boolean useRepositoryName
protected List<DefaultBlobDispatcher.Rule> rules
protected Set<String> rulesXPaths
protected Set<String> providerIds
protected String defaultProviderId
public DefaultBlobDispatcher()
public void initialize(Map<String,String> properties)
BlobDispatcher
initialize
in interface BlobDispatcher
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)
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)
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 blobpublic 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 © 2016 Nuxeo SA. All rights reserved.