Activate page and related assets in workflow | Community
Skip to main content
Level 2
October 16, 2015
Solved

Activate page and related assets in workflow

  • October 16, 2015
  • 7 replies
  • 5344 views

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.
Best answer by smacdonald2008

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

vikramca06
Level 4
October 16, 2015

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

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

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. 

Level 2
May 28, 2019

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

arunpatidar
Community Advisor
Community Advisor
May 28, 2019
Level 2
May 28, 2019

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.

arunpatidar
Community Advisor
Community Advisor
May 28, 2019

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
Level 2
May 29, 2019

Thank u Arun. it worked