Migrating From DAM 1.x from DAM 2.x requires code changes and migration tasks are not provided. Many of the 1.x class names have been retained, but the meaning and behavior has changed.

 The new DAM documents provide details of how the new DAM works. Please read them carefully before starting to modify your code:

This document highlights the major changes and potential code challenges you may face.

Main class equivalencies

DamManager

AssetProviderRegistry replaces  DamManager .

  • AssetProviderRegistry does not give direct access to the Asset like DamManager did. It provides access to the AssetProvider. See Architecture.
  • ItemKey is now the main id used to request an AssetProviderItemFolder or Asset.

AssetProvider

AssetProvider has the same name in 2.x and 1.x but behaviors are different.

  • 2.x introduces support availability.
  • 2.x only exposes methods that uses ItemKey as the input parameter.
  • If your codes uses paths (mainly JCR related) the new DAM API provides  PathAwareAssetProvider . The  JcrAssetProvider implements this interface. See JCR API.
  • If you have created your own AssetProvider implementation, do not forget to re-configure and re-register your components once you have migrated your code. See Asset providers and renderers in the DAM Core module documentation.

Here are a few code examples that you can adapt to suit your needs.

Examples of how to access asset provider in DAM 2.x API
    public Asset getAsset(String providerId, String assetPath, String assetJcrIdentifier, ItemKey itemKey) {
        AssetProvider provider;
        // Get AssetProviderRegistry
        AssetProviderRegistry registry = Components.getComponent(AssetProviderRegistry.class);
        
        // Get AssetProvider
        if(itemKey != null) {
            provider = registry.getProviderFor(itemKey);
        } else if(StringUtils.isNotBlank(providerId)) {
            provider = registry.getProviderById(providerId);
        }else {
            provider = registry.getProviderById(DamConstants.DEFAULT_JCR_PROVIDER_ID);
        }
        
        // Create the ItemKey
        if(itemKey == null) {
            itemKey = new ItemKey(provider.getIdentifier(), assetJcrIdentifier);
        }
        
        // Get the Asset
        Asset assetFromPath = ((PathAwareAssetProvider)provider).getAsset(assetPath);
        Asset assetFromItemKey = provider.getAsset(itemKey);
...

DamTemplatingFunctions

DamTemplatingFunctions has the same name in 2.x and 1.x, but the behaviors are different. To retain minimal templating compatibility, certain 1.0 templating methods are still exposed in DamTemplatingFunctions  2.x, but are marked as deprecated. See DAM templating for a list:

AssetMap

AssetMap in 1.x was removed and replaced in 2.x with a normal Map. Once you get the new map using  (DamTemplatingFunctions.getAssetMapForAssetId(String assetKey)), the syntax on the template side remains the same. See Main methods in 2.x for code examples.

MediaType

The 1.x  MediaType class no longer exists in 2.x. It is replaced by com.google.common.net.MediaType. See MediaType.

DAM app migration tasks

Unlike, the other DAM modules, the DAM App module provides two migration tasks:

  • UpdateDamAppConfigurationTask migrates the /modules/dam-app configuration
  • UpdateDamAssetFileNamePropertiesTask modifies certain DAM JCR Asset properties, for example the file name that now contains the name of the file and the file extension.
#trackbackRdf ($trackbackUtils.getContentIdentifier($page) $page.title $trackbackUtils.getPingUrl($page))