Class BinaryMetadataServiceImpl
- java.lang.Object
-
- org.nuxeo.binary.metadata.internals.BinaryMetadataServiceImpl
-
- All Implemented Interfaces:
BinaryMetadataService
public class BinaryMetadataServiceImpl extends Object implements BinaryMetadataService
- Since:
- 7.1
-
-
Field Summary
Fields Modifier and Type Field Description protected BinaryMetadataComponent
binaryMetadataComponent
-
Constructor Summary
Constructors Modifier Constructor Description protected
BinaryMetadataServiceImpl(BinaryMetadataComponent binaryMetadataComponent)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
applyUpdates(DocumentModel doc, List<MetadataMappingUpdate> mappingUpdates)
Applies synchronously the givenmappingUpdates
computed byBinaryMetadataService.getMetadataUpdates(DocumentModel, boolean)
to the document.protected Set<MetadataRuleDescriptor>
checkFilter(ActionContext actionContext)
Check for each Binary Rule if the document is accepted or not.protected ActionContext
createActionContext(DocumentModel doc)
protected List<MetadataMappingDescriptor>
getMapping(Collection<String> mappingDescriptorIds)
List<MetadataMappingUpdate>
getMetadataUpdates(DocumentModel doc, boolean creation)
Returns the list ofMetadataMappingUpdate
to apply to the document and the blob according to following rules: If creation, write metadata from Blob to doc. If Blob dirty and document metadata dirty, write metadata from doc to Blob. If Blob dirty and document metadata not dirty, write metadata from Blob to doc. If Blob not dirty and document metadata dirty, write metadata from doc to Blob. In all cases, the metadata is never written from doc to Blob ifMetadataMappingDescriptor#isReadOnly()
returns true.protected BinaryMetadataProcessor
getProcessor(String processorId)
List<MetadataMappingDescriptor>
getSyncMapping(DocumentModel doc)
Deprecated.since 2021.13, because only used byhandleSyncUpdate(DocumentModel)
void
handleSyncUpdate(DocumentModel doc)
Deprecated.void
handleUpdate(List<MetadataMappingDescriptor> mappingDescriptors, DocumentModel doc)
Deprecated.protected boolean
isDirtyMapping(MetadataMappingDescriptor mappingDescriptor, DocumentModel doc)
Maps inspector only.Map<String,Object>
readMetadata(String processorName, Blob blob, boolean ignorePrefix)
Read and return metadata from a given binary with a given processor.Map<String,Object>
readMetadata(String processorName, Blob blob, List<String> metadataNames, boolean ignorePrefix)
Read and return metadata from a given binary and a given metadata list with a given processor.Map<String,Object>
readMetadata(Blob blob, boolean ignorePrefix)
Read and return metadata from a given binary with Nuxeo default processor.Map<String,Object>
readMetadata(Blob blob, List<String> metadataNames, boolean ignorePrefix)
Read and return metadata from a given binary and a given metadata list with Nuxeo default processor.Blob
writeMetadata(String processorName, Blob blob, String mappingDescriptorId, DocumentModel doc)
Write given metadata mapping id into a given binary with a Nuxeo default processor.Blob
writeMetadata(String processorName, Blob blob, Map<String,Object> metadata, boolean ignorePrefix)
Write given metadata into a given binary with a given processor.Blob
writeMetadata(Blob blob, String mappingDescriptorId, DocumentModel doc)
Write given metadata mapping id into a given binary with a Nuxeo default processor.Blob
writeMetadata(Blob blob, Map<String,Object> metadata, boolean ignorePrefix)
Write given metadata into a given binary with a Nuxeo default processor.void
writeMetadata(DocumentModel doc)
Write metadata (from a binary) into a given Nuxeo Document according to the metadata mapping and rules contributions.void
writeMetadata(DocumentModel doc, String mappingDescriptorId)
Apply metadata mapping and override document properties according to the contribution.void
writeMetadata(DocumentModel doc, MetadataMappingDescriptor mappingDescriptor)
-
-
-
Field Detail
-
binaryMetadataComponent
protected BinaryMetadataComponent binaryMetadataComponent
-
-
Constructor Detail
-
BinaryMetadataServiceImpl
protected BinaryMetadataServiceImpl(BinaryMetadataComponent binaryMetadataComponent)
-
-
Method Detail
-
readMetadata
public Map<String,Object> readMetadata(String processorName, Blob blob, List<String> metadataNames, boolean ignorePrefix)
Description copied from interface:BinaryMetadataService
Read and return metadata from a given binary and a given metadata list with a given processor.- Specified by:
readMetadata
in interfaceBinaryMetadataService
- Parameters:
processorName
- Name of the contributed processor to run.blob
- Binary which metadata are read.metadataNames
- Metadata list to extract from the binary.ignorePrefix
- Since 7.3- Returns:
- Extracted metadata.
-
readMetadata
public Map<String,Object> readMetadata(Blob blob, List<String> metadataNames, boolean ignorePrefix)
Description copied from interface:BinaryMetadataService
Read and return metadata from a given binary and a given metadata list with Nuxeo default processor.- Specified by:
readMetadata
in interfaceBinaryMetadataService
- Parameters:
blob
- Binary which metadata are read.metadataNames
- Metadata list to extract from the binary.ignorePrefix
- Since 7.3- Returns:
- Extracted metadata.
-
readMetadata
public Map<String,Object> readMetadata(Blob blob, boolean ignorePrefix)
Description copied from interface:BinaryMetadataService
Read and return metadata from a given binary with Nuxeo default processor.- Specified by:
readMetadata
in interfaceBinaryMetadataService
- Parameters:
blob
- Binary which metadata are read.ignorePrefix
- Since 7.3- Returns:
- Extracted metadata.
-
readMetadata
public Map<String,Object> readMetadata(String processorName, Blob blob, boolean ignorePrefix)
Description copied from interface:BinaryMetadataService
Read and return metadata from a given binary with a given processor.- Specified by:
readMetadata
in interfaceBinaryMetadataService
- Parameters:
processorName
- Name of the contributed processor to run.blob
- Binary which metadata are read.ignorePrefix
- Since 7.3- Returns:
- Extracted metadata.
-
writeMetadata
public Blob writeMetadata(String processorName, Blob blob, Map<String,Object> metadata, boolean ignorePrefix)
Description copied from interface:BinaryMetadataService
Write given metadata into a given binary with a given processor.- Specified by:
writeMetadata
in interfaceBinaryMetadataService
- Parameters:
processorName
- Name of the contributed processor to run.blob
- Binary which metadata are written.metadata
- Injected metadata.ignorePrefix
- Since 7.3- Returns:
- the updated blob, or
null
if there was an error (since 7.4)
-
writeMetadata
public Blob writeMetadata(Blob blob, Map<String,Object> metadata, boolean ignorePrefix)
Description copied from interface:BinaryMetadataService
Write given metadata into a given binary with a Nuxeo default processor.- Specified by:
writeMetadata
in interfaceBinaryMetadataService
- Parameters:
blob
- Binary which metadata are written.metadata
- Injected metadata.ignorePrefix
- Since 7.3- Returns:
- the updated blob, or
null
if there was an error (since 7.4)
-
writeMetadata
public Blob writeMetadata(String processorName, Blob blob, String mappingDescriptorId, DocumentModel doc)
Description copied from interface:BinaryMetadataService
Write given metadata mapping id into a given binary with a Nuxeo default processor.- Specified by:
writeMetadata
in interfaceBinaryMetadataService
- Parameters:
processorName
- Name of the contributed processor to run.blob
- Binary which metadata are written.mappingDescriptorId
- The metadata mapping to apply on the document.doc
- Document from properties will be read.- Returns:
- the updated blob, or
null
if there was an error (since 7.4)
-
writeMetadata
public Blob writeMetadata(Blob blob, String mappingDescriptorId, DocumentModel doc)
Description copied from interface:BinaryMetadataService
Write given metadata mapping id into a given binary with a Nuxeo default processor.- Specified by:
writeMetadata
in interfaceBinaryMetadataService
- Parameters:
blob
- Binary which metadata are written.mappingDescriptorId
- The metadata mapping to apply on the document.doc
- Document from properties will be read.- Returns:
- the updated blob, or
null
if there was an error (since 7.4)
-
writeMetadata
public void writeMetadata(DocumentModel doc)
Description copied from interface:BinaryMetadataService
Write metadata (from a binary) into a given Nuxeo Document according to the metadata mapping and rules contributions.The document is not saved in the session, it's up to the caller to deal with this.
- Specified by:
writeMetadata
in interfaceBinaryMetadataService
- Parameters:
doc
- Nuxeo Document which metadata are written.
-
writeMetadata
public void writeMetadata(DocumentModel doc, String mappingDescriptorId)
Description copied from interface:BinaryMetadataService
Apply metadata mapping and override document properties according to the contribution.The document is not saved in the session, it's up to the caller to deal with this.
- Specified by:
writeMetadata
in interfaceBinaryMetadataService
- Parameters:
doc
- The input document.mappingDescriptorId
- The metadata mapping to apply on the document.
-
writeMetadata
public void writeMetadata(DocumentModel doc, MetadataMappingDescriptor mappingDescriptor)
-
getMetadataUpdates
public List<MetadataMappingUpdate> getMetadataUpdates(DocumentModel doc, boolean creation)
Description copied from interface:BinaryMetadataService
Returns the list ofMetadataMappingUpdate
to apply to the document and the blob according to following rules:- If creation, write metadata from Blob to doc.
- If Blob dirty and document metadata dirty, write metadata from doc to Blob.
- If Blob dirty and document metadata not dirty, write metadata from Blob to doc.
- If Blob not dirty and document metadata dirty, write metadata from doc to Blob.
MetadataMappingDescriptor#isReadOnly()
returns true.- Specified by:
getMetadataUpdates
in interfaceBinaryMetadataService
-
applyUpdates
public void applyUpdates(DocumentModel doc, List<MetadataMappingUpdate> mappingUpdates)
Description copied from interface:BinaryMetadataService
Applies synchronously the givenmappingUpdates
computed byBinaryMetadataService.getMetadataUpdates(DocumentModel, boolean)
to the document.The document is not saved in the session, it's up to the caller to deal with this.
Note: This is potentially a long processing.
- Specified by:
applyUpdates
in interfaceBinaryMetadataService
-
handleSyncUpdate
@Deprecated public void handleSyncUpdate(DocumentModel doc)
Deprecated.Description copied from interface:BinaryMetadataService
Handle document and blob updates according to following rules in an event context:- Define if rule should be executed in async or sync mode.
- If Blob dirty and document metadata dirty, write metadata from doc to Blob.
- If Blob dirty and document metadata not dirty, write metadata from Blob to doc.
- If Blob not dirty and document metadata dirty, write metadata from doc to Blob.
MetadataMappingDescriptor#isReadOnly()
returns true.The document is not saved in the session, it's up to the caller to deal with this.
- Specified by:
handleSyncUpdate
in interfaceBinaryMetadataService
-
handleUpdate
@Deprecated public void handleUpdate(List<MetadataMappingDescriptor> mappingDescriptors, DocumentModel doc)
Deprecated.Description copied from interface:BinaryMetadataService
Handle document and blob updates according to following rules in an event context:- Define if rule should be executed in async or sync mode.
- If Blob dirty and document metadata dirty, write metadata from doc to Blob.
- If Blob dirty and document metadata not dirty, write metadata from Blob to doc.
- If Blob not dirty and document metadata dirty, write metadata from doc to Blob.
MetadataMappingDescriptor#isReadOnly()
returns true.The document is not saved in the session, it's up to the caller to deal with this.
- Specified by:
handleUpdate
in interfaceBinaryMetadataService
-
checkFilter
protected Set<MetadataRuleDescriptor> checkFilter(ActionContext actionContext)
Check for each Binary Rule if the document is accepted or not.- Returns:
- the list of metadata which should be processed sorted by rules order. (high to low priority)
-
createActionContext
protected ActionContext createActionContext(DocumentModel doc)
-
getProcessor
protected BinaryMetadataProcessor getProcessor(String processorId) throws NoSuchMethodException
- Throws:
NoSuchMethodException
-
getSyncMapping
@Deprecated public List<MetadataMappingDescriptor> getSyncMapping(DocumentModel doc)
Deprecated.since 2021.13, because only used byhandleSyncUpdate(DocumentModel)
- Returns:
- Dirty metadata from metadata mapping contribution and handle async processes.
-
getMapping
protected List<MetadataMappingDescriptor> getMapping(Collection<String> mappingDescriptorIds)
-
isDirtyMapping
protected boolean isDirtyMapping(MetadataMappingDescriptor mappingDescriptor, DocumentModel doc)
Maps inspector only.
-
-