Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-30145

Add a parameter not to save the document in the operation 'Document.SetMetadataFromBlob'

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.10
    • Fix Version/s: 10.10-HF49, 2021.x, 11.x
    • Component/s: Automation
    • Release Notes Summary:
      A parameter is added not to save the document in the operation 'Document.SetMetadataFromBlob'
    • Backlog priority:
      600
    • Sprint:
      nxplatform #36, nxplatform #37
    • Story Points:
      0

      Description

      Currently, when operation Document.SetMetadataFromBlob is called in an automation script triggered by a Before document modification event handler, it calls CoreSession.saveDocument(DocumentModel (see here), which causes recursive calls.

      Saving the document must be an option (e.g. using a save parameter), like it is done in several operations that update the document's properties (e.g. Document.SetProperty).

      How to reproduce:

      • in Studio, define the following metadata mapping in a XML extension:
        <extension point="metadataMappings" target="org.nuxeo.binary.metadata">
          
          <metadataMapping id="exif" processor="exifTool" blobXPath="file:content" ignorePrefix="false" >
            <metadata name="File:MIMEType" xpath="dc:description" />
          </metadataMapping>
          
        </extension>
        
      • define an event handler, triggered by event Before document modification for documents of type Picture, running the following automation script:
        function run(input, params) {
            var mimeType = input['file:content/mime-type'];
            if(mimeType.startsWith('image/')) {
              Document.SetMetadataFromBlob(input, { 'metadataMappingId': 'exif' } );
            }    
          }
          return input;
        }
        
      • deploy
      • log in the Web UI
      • create a Picture document without an attached blob
      • attach an image containing the metadata mentioned in the metadata mapping above

      Expected result: the metadata is extracted from the image file and the document property is set with its value
      Actual result: the metadata is extracted from the image file but the document property is not set. If the automation tracing is activated, a lot of logs should be generated in the server.log file, showing recursive calls

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                PagerDuty

                Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.