Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Activate page and related assets in workflow

Avatar

Level 2

Hi guys,

When I tried to activate the page with referenced assets (e.g. Image component) through workflow Activate page step, only the page is activated but not assets. Does somebody knows if it is expected behaviour or bug?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 10

When we update our AEM community pages with assets stored in the DAM -- we activate the assets in the DAM before using them in the page, as shown here:

[img]DAMAct.png[/img]

So - its expected behaviour to activate assets in the DAM - we do it within Adobe. 

View solution in original post

7 Replies

Avatar

Level 4

Hi,

try this

Node n = adminSession.getNode(pagePath+"/jcr:content");

AssetReferenceSearch ref = new AssetReferenceSearch(n,DamConstants.MOUNTPOINT_ASSETS,resourceResolver);
                 Map<String,Asset> allref = new HashMap<String,Asset>();
                 allref.putAll(ref.search());
                 for (Map.Entry<String, Asset> entry : allref.entrySet()) {   
                     String assetPath = entry.getKey();
                     log.info(assetPath+"<br>"); // Path of all Asset ref in page
                     log.info(assetPath +" ASSET ACTIVATION STARTED");
                     replicator.replicate(adminSession, ReplicationActionType.ACTIVATE, assetPath);
                     log.info(assetPath +" ASSET ACTIVATION ENDED");
                 }
                 log.info("PAGE ACTIVATION STARTED");
                 replicator.replicate(adminSession, ReplicationActionType.ACTIVATE, pagePath);
                 log.info("ACTIVATION ENDED");

Avatar

Correct answer by
Level 10

When we update our AEM community pages with assets stored in the DAM -- we activate the assets in the DAM before using them in the page, as shown here:

[img]DAMAct.png[/img]

So - its expected behaviour to activate assets in the DAM - we do it within Adobe. 

Avatar

Level 2

Hi vikramca06

Can you let me know on how can we relate assets programatically(Via API).

I want to write a custom workflow to add relation between assets.(source,derived and others)

Which API needs to be used ? If possible can I get a sample code?

Regards

Susmitha Sama

Avatar

Level 2

Hi Arun,

have written the following code to relate assets.

if(assetMgr.assetExists(nodePath))

{

asset = assetMgr.getAsset("nodePath");

asset.addRelation("derived",path);

}

nodepath has the parent asset

and path has the child asset which need to be related to mode path asset.

Getting null exception.

I'm not sure if this the correct syntax to add relation between assets.

Can you please guide me on the correct syntax.

Avatar

Community Advisor

I tried below in servlet.

AssetManager assetMgr = request.getResourceResolver().adaptTo(AssetManager.class);

String parentAsset = "/content/dam/AEM64App/asset.jpg";

String childAsset = "/content/dam/arch17/asset.jpg";

if (assetMgr.assetExists(parentAsset) && assetMgr.assetExists(childAsset)) {

Asset asset = assetMgr.getAsset(parentAsset);

asset.addRelation("derived", childAsset);

}



Arun Patidar