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

Add "getFileExtension" to the Bean handling "currentDocument"

    XMLWordPrintable

    Details

      Description

      Building a filter that checks the file extension is "complicated" (not complicated, more cumbersome):

      • Eiher you must create your custom bean
      • Or you must use a complicated EL such as:
       <filter id="file-is-docx">
          <rule grant="true">
             <condition>#{currentDocument.hasSchema("file") &amp;&amp;  currentDocument.file.content != null &amp;&amp; currentDocument.getPropertyValue("file:content").getFilename().indexOf(".docx") > -1}</condition>
          </rule>
        </filter>
      

      (which of course is not good. A file named the file.docx.zip would pass the test)

      So having something like currentDocument.getFileExtension() which returns "" if the blob is null or there is not file extension, and returns the lowercase file extension would be very nice. For fine tuning, the API could accept a parameter giving the xpath to test (file:content by default)

      I understand that in the context of a filter, adding a getFileExtension() API means mainly adding it to DoocumentModel. But still. Would be useful and optimized.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: