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

Allow Event.Fire to use properties

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 10.3
    • Fix Version/s: 11.1, 2021.0
    • Component/s: Automation
    • Backlog priority:
      200
    • Sprint:
      nxcore 11.1.2
    • Story Points:
      2

      Description

      It is sometime very useful to pass properties to the an async. event.

      It is hard to do it because the operation just expects the name of the event.

      So, please, allow for also passing a property list:

      p1=123
      p2=toto
      etc.
      

      So, when handling the event from JS Automation, we can:

      var p1 = ctx.Event.context.getProperty("p1");
      var p2 = ctx.Event.context.getProperty("p2");
      

      Workaround is cumbersome. Either write a plugin or use Automation Scripting:
      1. Add the Allowed Java classes in XML:

      <extension target="org.nuxeo.automation.scripting.internals.AutomationScriptingComponent" point="classFilter">
        <classFilter>
          <allow>org.nuxeo.runtime.api.Framework</allow>
          <allow>org.nuxeo.ecm.core.event.EventProducer</allow>
          <allow>org.nuxeo.ecm.core.event.impl.EventContextImpl</allow>
          <allow>org.nuxeo.ecm.core.event.impl.DocumentEventContext</allow>
        </classFilter>
      </extension>
      

      2. Use them in script:

      . . .
        var evctx = new org.nuxeo.ecm.core.event.impl.DocumentEventContext(Session, Session.getPrincipal(), domain.doc);
        evctx.setProperty("createData_start", start);
        evctx.setProperty("createData_end", end);
        var service = org.nuxeo.runtime.api.Framework.getService(org.nuxeo.ecm.core.event.EventProducer.class);
        service.fireEvent( evctx.newEvent("CreateDataAsync") );
      . . .
      

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours
                3h