Activate page and related assets in workflow | Community
Skip to main content
Level 2
Oct 16, 2015 2:27 AM UTC
Solved

Activate page and related assets in workflow

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

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. 

7 replies

Level 2
May 29, 2019 1:00 PM UTC

Thank u Arun. it worked

Translate
arunpatidar
New Participant
May 28, 2019 4:18 PM UTC

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);

}

Translate
Arun Patidar
Level 2
May 28, 2019 1:38 PM UTC

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.

Translate
arunpatidar
New Participant
May 28, 2019 11:55 AM UTC
Level 2
May 28, 2019 11:15 AM UTC

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

Translate
vikramca06
Level 4
Oct 16, 2015 2:27 AM UTC

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");

Translate
smacdonald2008
smacdonald2008Accepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

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. 

Translate