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 Details

  • Constructor Details

  • Method Details

    • 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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 interface BinaryMetadataService
      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 of MetadataMappingUpdate 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 if MetadataMappingDescriptor#isReadOnly() returns true.
      Specified by:
      getMetadataUpdates in interface BinaryMetadataService
    • applyUpdates

      public void applyUpdates(DocumentModel doc, List<MetadataMappingUpdate> mappingUpdates)
      Description copied from interface: BinaryMetadataService
      Applies synchronously the given mappingUpdates computed by BinaryMetadataService.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 interface BinaryMetadataService
    • 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.
      In all cases, the metadata is never written from doc to Blob if 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 interface BinaryMetadataService
    • 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.
      In all cases, the metadata is never written from doc to Blob if 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 interface BinaryMetadataService
    • 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.
      since 2021.13, because only used by handleSyncUpdate(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.