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

Can't list all properties of a Blob in Freemarker (ClassCastException on ?keys)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.7.1
    • Fix Version/s: QualifiedToSchedule
    • Component/s: WebEngine

      Description

      This is the same as #NXP-10101 but for BlobTemplate, and probably

      When trying to list all properties of a Blob (such as doc['file:content']) in a Freemarker template view (ex. for logging purpose) using the ?keys builtin (since a Blob is a Hash extension in Freemarker), there is a ClassCastException (see below).

      To patch it, reimplement BlobTemplate.keys()
      from
      return (TemplateCollectionModel) wrapper.wrap(getRawKeys());
      to
      return new CollectionAndSequence(new SimpleSequence(getRawKeys(), wrapper));
      and it should do the trick.

      RenderingException: java.lang.ClassCastException: freemarker.template.SimpleSequence cannot be cast to freemarker.template.TemplateCollectionModel
      at org.nuxeo.ecm.platform.rendering.fm.FreemarkerEngine.render(FreemarkerEngine.java:200)
      at org.nuxeo.ecm.webengine.model.impl.AbstractWebContext.render(AbstractWebContext.java:583)
      ... 59 more
      Caused by: java.lang.ClassCastException: freemarker.template.SimpleSequence cannot be cast to freemarker.template.TemplateCollectionModel
      at org.nuxeo.ecm.platform.rendering.fm.adapters.BlobTemplate.keys(BlobTemplate.java:56)
      at freemarker.core.BuiltIn$keysBI._getAsTemplateModel(BuiltIn.java:598)
      at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
      at freemarker.core.Expression.getStringValue(Expression.java:93)
      at freemarker.core.DollarVariable.accept(DollarVariable.java:76)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mdutoo Marc Dutoo
              Participants:
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: