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

Using assets in different workspaces: AssetCompositeIdKeyTranslator denies flexible usage

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Obsolete
    • Icon: Neutral Neutral
    • None
    • 2.4.1, 2.5
    • DAM API
    • None

      Use case:

      • Using assets in different workspaces (and apps).
        -> The Assets ap/dam workspace should not be changed.

      Situation / Problem:
      The whole dam api is very flexibel build:

      • Registering a different assetProvided allows to configure using a different workspace where the asset is fetched from.
      • AssetCompositeIdKeyTranslator allows you to configure the workspace to target/fetch from.
      • The dam download servlet would work 1:1 as it delegates to the asset provided

      But there is one flaw that forces you to override/implement classes:
      1. The AssetCompositeIdKeyTranslator uses hardcoded the item key in line 72:

      ItemKey itemKey = new ItemKey(DamConstants.DEFAULT_JCR_PROVIDER_ID, session.getNode(path).getIdentifier());
      

      That means "jcr" is always stored as assetProvider id -> the second registered assetProvider will never be used.
      2. Also another problem is the 'downloadPath' module configuration of the dam module -> it defines the download path in the uri which is by default /dam/ to target the DamDownload Servlet. In my case I also need to use a different servlet (need to to pdf -> image conversions). Which is impossible as it will awlays add /dam/ to the asset link.
      3. Class info.magnolia.dam.jcr.JcrAssetProvider should not du a new of the Asset impl it provides. AND that method should be at least protected!!

      Asset createAsset(final Node assetNode) {
              if (AssetNodeTypes.isAsset(assetNode)) {
                  log.debug("Created asset linked to the following node '{}'", NodeUtil.getPathIfPossible(assetNode));
                  return new JcrAsset(this, new I18nNodeWrapper(assetNode));
              }
              throw new IllegalArgumentException("Node '" + NodeUtil.getPathIfPossible(assetNode) + "' is not defining an asset but another item type");
          }
      

      Solution:
      1. Let on the class AssetCompositeIdKeyTranslator also the AssetProviderID be configurable.
      Also the class should provide a method "getWorkspaceName()" that extends of it can access it.
      2. Define on the AssetProvider the 'downloadPath' and not globally in the module itself.
      3. Let it be configured on the AssetProvider and/or being Injected form Guice.

        Acceptance criteria

              Unassigned Unassigned
              cringele Christian Ringele
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: