Show Menu

Developing for Brand Portal with AEM Assets

An abridged walk-through using AEM's DamSyncService API in conjunction with AEM Workflow to programmatically publish assets to AEM Assets Brand Portal.

DAMSyncService API

Below is an abbreviated version of the code used in the WorkflowProcess demonstrated in the above video. The full, working code is available via ACS AEM Commons' Brand Portal Sync Workflow Process and can be used as is, or adapted for use.
They key call outs are
  1. Obtaining the DAMSyncService object
  2. Collecting the workflow payload(s) path(s)
  3. Passing the payload path(s) to
    1. damSyncService.publishResourcesToMP(..) to publish assets TO Brand Portal
    2. damSyncService.unpublishResourcesFromMP(..) to remove assets FROM Brand Portal
import com.adobe.cq.dam.mac.sync.api.DAMSyncService;

public class BrandPortalSyncProcess implements WorkflowProcess {

  private DAMSyncService damSyncService;

  public final void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
    List<String> assetPaths = new ArrayList<String>();
    assetPaths.add((String) workItem.getWorkflowData().getPayload());

    // Publish assets to Brand Portal    
    damSyncService.publishResourcesToMP(assetPaths, resourceResolver);

    // Unpublish assets from Brand Portal    
    damSyncService.unpublishResourcesFromMP(assetPaths, resourceResolver);

Remember, the DAMSyncService APIs use the usual asynchronous, job-based replication to publish assets to Brand Portal.
To understand the ramifications of this, please read through Understanding Brand Portal with AEM Assets .

Asset folder mpConfig property

All illustrated in the above video, a valid AEM Cloud Service configuration path must be provided in a property names mpConfig on an ancestor Assets Folder node.
This property must be on the Asset's folder node ( sling:Folder or sling:OrderedFolder , and NOT the folder's jcr:content node). For example:

If an asset is passed to the DAMSyncService and that assets does not have an ancestor Assets folder node with the mpConfig property set, the following exception will occur:
Caused by: java.lang.NullPointerException: null
 at com.adobe.cq.dam.mac.sync.impl.DAMSyncServiceImpl.getTenantFromConfiguration(
 at com.adobe.cq.dam.mac.sync.impl.DAMSyncServiceImpl.getTenantIdForPath(
 at com.adobe.cq.dam.mac.sync.impl.DAMSyncServiceImpl.getAgentFilter(
 at com.adobe.cq.dam.mac.sync.impl.DAMSyncServiceImpl.syncFolder(
 at com.adobe.cq.dam.mac.sync.impl.DAMSyncServiceImpl.publishResourcesToMP(
 at com.adobe.acs.commons.workflow.process.impl.BrandPortalSyncProcess.execute(
 ... 9 common frames omitted