Uploaded image for project: 'Magnolia DAM Module'
  1. Magnolia DAM Module
  2. MGNLDAM-723

Null-unsafe templating function: getAssetMap

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Neutral Neutral
    • None
    • None
    • DAM Templating
    • None
    • MariaDB, CentOS

      This ticket is related to the Dam Templating Functions.
      damfn in docu
      DamTemplatingFunctions.java in git

      First thing we've noticed is that the method below is not null-safe, so when an asset does not exist, it will throw a NullPointerException which will break the rendering process.

      Map<String, Object> getAssetMap(Asset asset)
      

      And consequently, this other method is also unsafe, as it calls the aforementioned one:

      Map<String, Object> getAssetMap(String itemKey)
      

      This can be avoided by using the following method instead:

      Map<String, Object> getAssetMapForAssetId(String assetKey)
      

      , as long as the asset is referred by its id.

      This leads also to the misleading documentation, as it is stated in https://documentation.magnolia-cms.com/display/DOCS/damfn that

      *) getAssetMapForAssetId(String itemKey) and getAssetMap(String itemKey) are both identical.

      , which is not completely true, as getAssetMapForAssetId is null-safe, while getAssetMap is not.

        Acceptance criteria

              Unassigned Unassigned
              fnavarro Federico Navarro
              Federico Navarro, Marcel Evers, Mariusz Chruscielewski, Nuno Cruz, Simon Lutz, Stef te Winkel
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD