Platform Explorer / Nuxeo Platform LTS 2019 10.10

Extension point defaultRendition

Defines the default rendition of a given document. Contributions are of the form:

    <defaultRendition>
        <script language="JavaScript">
            function run() {
              if (CurrentUser.getName() != "bob") {
                return null;
              }
              if (!CurrentUser.getGroups().contains("members")) {
                return 'aRenditionName`;
              }
              if (Document.getPropertyValue("dc:format") != "pdf") {
                return 'pdfRendition';
              }
              if (Reason == "download" || doc.getType() == "Picture") {
                return 'watermarkedImageRendition';
              }
              return 'aDefaultRendition';
          </script>
    </defaultRendition>

The language can be any JVM scripting language, the default is "JavaScript".

The script must define a "run()" function that returns a string which is the name of the rendition to be used. The method will get called with the following global context (some values may be null): Document (DocumentModel) CurrentUser (NuxeoPrincipal), Reason (String), Infos (Map).

Contribution Descriptor

Existing Contributions

  • nuxeo-platform-rendition-core-10.10.jar /OSGI-INF/rendition-contrib.xml
    <extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService">
        <defaultRendition>
          <script language="JavaScript">
            function run() {
              return 'xmlExport';
            }
          </script>
        </defaultRendition>
      </extension>
  • nuxeo-platform-rendition-core-10.10.jar /OSGI-INF/rendition-publish-contrib.xml
    <extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService">
        <defaultRendition reason="publish">
          <script language="JavaScript">
            function run() {
              if (Document.getType() == "File" || Document.getType() == "Note") {
                return 'pdf';
              } else if (Document.hasSchema("file")) {
                return 'mainBlob';
              }
              return null;
            }
          </script>
        </defaultRendition>
      </extension>
  • nuxeo-platform-rendition-core-10.10.jar /OSGI-INF/rendition-download-contrib.xml
    <extension point="defaultRendition" target="org.nuxeo.ecm.platform.rendition.service.RenditionService">
        <defaultRendition reason="download">
          <script language="JavaScript">
            function run() {
              if (Document.getType() == "File") {
                return 'mainBlob';
              } else if (Document.getType() == 'Picture') {
                return 'mainBlob';
              } else if (Document.getType() == 'Video') {
                return 'mainBlob';
              } else if (Document.getType() == 'Audio') {
                return 'mainBlob';
              } else if (Document.getType() == 'Note') {
                return 'pdf';
              } else if (Document.getFacets().contains("Collection")) {
                return 'containerDefaultRendition';
              } else if (Document.getFacets().contains("Folderish")) {
                return 'containerDefaultRendition';
              } else {
                return 'xmlExport';
              }
            }
          </script>
        </defaultRendition>
      </extension>