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

DamTemplatingFunctions: getRendition(String, String) must do a null check on the inner asset

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Neutral
    • 2.0.3
    • 2.0.2
    • None

    Description

      In:

          public AssetRendition getRendition(String itemKey, String renditionName) {
              Asset asset = getAsset(itemKey);
              return getRendition(asset, MediaType.parse(asset.getMimeType()), renditionName);
          }
      

      the asset mus be null checked, as later is called "MediaType.parse(asset.getMimeType())" on it. Like this a un-handled exception is thrown which is not really catch-able in the freemarker script (null pointer check doesn't work).

      Change to:

          public AssetRendition getRendition(String itemKey, String renditionName) {
              Asset asset = getAsset(itemKey);
              if (asset == null) {
                  return null;
              }
              return getRendition(asset, MediaType.parse(asset.getMimeType()), renditionName);
          }
      

      Possible workaround:

      • Use the info.magnolia.dam.templating.functions.DamTemplatingFunctions.getAsset(String)
      • do a null check on the returned asset
      • if not null use the info.magnolia.dam.templating.functions.DamTemplatingFunctions.getRendition(Asset, String)

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              fgrilli Federico Grilli
              cringele Christian Ringele
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD