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

Move validation after aboutToCreate event

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 8.10
    • Fix Version/s: 8.10-HF18, 9.3
    • Component/s: Core
    • Backlog priority:
      400
    • Upgrade notes:
      Hide

      Since 9.3, Nuxeo validates documents after firing the aboutTo events for create/update/import API on CoreSession.
      This behavior is also available on a 8.10 with the right HF and the following configuration contribution:

        <extension target="org.nuxeo.runtime.ConfigurationService" point="configuration">
          <property name="org.nuxeo.core.validation.after.listeners">true</property>
        </extension>
      
      Show
      Since 9.3, Nuxeo validates documents after firing the aboutTo events for create/update/import API on CoreSession. This behavior is also available on a 8.10 with the right HF and the following configuration contribution: <extension target= "org.nuxeo.runtime.ConfigurationService" point= "configuration" > <property name= "org.nuxeo.core.validation.after.listeners" > true </property> </extension>
    • Sprint:
      nxcore 9.3.9
    • Story Points:
      2

      Description

      In createDocument method of org.nuxeo.ecm.core.api.AbstractSession class, the validation service is called before the event aboutToCreate is sent

          @Override
          public DocumentModel createDocument(DocumentModel docModel) {
      ...
      
              // document validation
              if (getValidationService().isActivated(DocumentValidationService.CTX_CREATEDOC, options)) {
      (line 678)            DocumentValidationReport report = getValidationService().validate(docModel, true);
                  if (report.hasError()) {
                      throw new DocumentValidationException(report);
                  }
              }
      ...
      
      (line 692)        notifyEvent(DocumentEventTypes.ABOUT_TO_CREATE, docModel, options, null, null, false, true); // no lifecycle
      ...                                                                                                     // yet
      

      It should be called after to make the validation pass on every modified fields and just before the creation.

      Because such a change cannot be backported as if, a flag must be used to change the order.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 3 hours, 30 minutes
                  1d 3h 30m