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

Fix JSF EL evaluation of a condition using a multi-valued property in a filter used by a picture conversion

    XMLWordPrintable

    Details

    • Release Notes Summary:
      The function nx:arrayContains is added to evaluate JSF EL condition on multi-valued properties.
    • Release Notes Description:
      Hide

      Added new functions in the EL context to work with arrays:

      • nx:arrayContains: returns true if the given array contains the given element.
      ${nx:arrayContains(array, 'foo')}
      
      • nx:arrayContainsAll: returns true if the given array contains all the given elements.
      ${nx:arrayContainsAll(array, 'bar', 'foo')}
      
      • nx:arrayContainsAny: returns true if the given array contains one of the given elements.
      ${nx:nx:arrayContainsAny(array, 'bar', 'foo')}
      
      • nx:arrayContainsNone: returns true if the given array contains none of the given elements.
      ${nx:arrayContainsNone(array, 'barfoo', 'foobar')}
      

      For instance, those functions can be used in filters to filter picture conversions:

      <extension target="org.nuxeo.ecm.platform.picture.ImagingComponent"
        point="pictureConversions">
        <pictureConversion id="subjectFilteredConversion" maxSize="200">
          <filters>
            <filter-id>subjectFilter</filter-id>
          </filters>
        </pictureConversion>
      </extension>
      
      <extension target="org.nuxeo.ecm.platform.actions.ActionService"
        point="filters">
        <filter id="subjectFilter">
          <rule grant="true">
            <condition>#{nx:arrayContains(currentDocument.dc.subjects, "art/paint")}</condition>
          </rule>
        </filter>
      </extension>
      
      Show
      Added new functions in the EL context to work with arrays: nx:arrayContains : returns true if the given array contains the given element . ${nx:arrayContains(array, 'foo' )} nx:arrayContainsAll : returns true if the given array contains all the given elements . ${nx:arrayContainsAll(array, 'bar' , 'foo' )} nx:arrayContainsAny : returns true if the given array contains one of the given elements . ${nx:nx:arrayContainsAny(array, 'bar' , 'foo' )} nx:arrayContainsNone : returns true if the given array contains none of the given elements . ${nx:arrayContainsNone(array, 'barfoo' , 'foobar' )} For instance, those functions can be used in filters to filter picture conversions: <extension target= "org.nuxeo.ecm.platform.picture.ImagingComponent" point= "pictureConversions" > <pictureConversion id= "subjectFilteredConversion" maxSize= "200" > <filters> <filter-id> subjectFilter </filter-id> </filters> </pictureConversion> </extension> <extension target= "org.nuxeo.ecm.platform.actions.ActionService" point= "filters" > <filter id= "subjectFilter" > <rule grant= "true" > <condition> #{nx:arrayContains(currentDocument.dc.subjects, "art/paint" )} </condition> </rule> </filter> </extension>
    • Backlog priority:
      500
    • Team:
      PLATFORM
    • Sprint:
      nxplatform 11.1.37, nxplatform #11
    • Story Points:
      3

      Description

      Filters can be applied to picture conversions as described in [HOWTO: Contribute Picture Conversions|Transactions and Connections]. When using a condition, it is impossible to test if a String multi-valued property (e.g. dc:subjects) contains a value (e.g. art/paint).

      How to reproduce:

      • define a new picture conversion and its filter:
        <extension target="org.nuxeo.ecm.platform.actions.ActionService" point="filters">
          
          <filter id="my-subject-filter">
            <rule grant="true">
              <condition>#{ currentDocument.dc.subjects.contains("art/paint") }</condition>
            </rule>
          </filter>
        
        </extension>
        
          <extension point="pictureConversions" target="org.nuxeo.ecm.platform.picture.ImagingComponent" >
        
            <pictureConversion chainId="Image.Blob.Resize" default="true" description="Thumbnail size 2" id="Thumbnail2" maxSize="100" order="0" rendition="true">
              <filters>
                <filter-id>my-subject-filter</filter-id>
              </filters>
            </pictureConversion>
        
          </extension>
        
      • deploy
      • create a Picture document and set subjects to Art / Paint

      Expected result: picture view Thumbnail size 2 is generated.
      Actual result: picture view Thumbnail size 2 is not generated.

      I know that JSF EL expression currentDocument.dc.subjects returns an array and method contains cannot be called on it but there is no available way to test if property dc:subjects contains a value.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 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 - 6 hours
                  6h