Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Get all the assets/tags/contentpolicy references on the page within a workflow process step


Level 2


I am writing a custom workflow step to publish a page and all the asset/tag/content-policy references on the page, so I can publish them as well. Currently, the servlet http://localhost:4502/libs/wcm/core/content/reference.json gets all the references, but I am unable to access the services used within that servlet in my code. 

I am able to get all the asset references using the AssetReferenceSearch API. Is there a similar service for tags & content policies on a page?

Please help!



5 Replies


Employee Advisor

Could you please try with below APIs -


For tags - TagManager (The Adobe AEM Quickstart and Web Application.)

and try with 

Tag[]getTags(Resource resource)
Retrieves the tags set on the given resource.


For Content policies : ContentPolicyManager and sharing below sample code -

package com.aem.demo.core.models;

import java.util.Objects;

import javax.annotation.PostConstruct;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aem.demo.core.services.JcrUtility;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.policies.ContentPolicy;
import com.day.cq.wcm.api.policies.ContentPolicyManager;
import com.drew.lang.annotations.Nullable;

 * @author debal

@Model(adaptables = SlingHttpServletRequest.class)
public class PageModel {

	private final Logger logger = LoggerFactory.getLogger(PageModel.class);

	JcrUtility jcrUtility;

	private Page currentPage;

	private String pageStyle;

	protected void init() {
		ResourceResolver resourceResolver = jcrUtility.getResourceResolver();
		String currentPagepath = currentPage.getPath();
		logger.info(" **** Current Page Path **** {}", currentPagepath);
		Resource resource = resourceResolver.getResource(currentPagepath);
		if (Objects.nonNull(resource)) {
			ContentPolicyManager contentPolicyManager = resourceResolver.adaptTo(ContentPolicyManager.class);
			ContentPolicy contentPolicy = contentPolicyManager.getPolicy(resource);
			pageStyle = contentPolicy.getPath();
			logger.info(" **** Page style **** {}", pageStyle);


	 * @return the pageStyle
	public String getPageStyle() {
		return pageStyle;



Level 2

@DEBAL_DAS Thanks for the response.

The ContentPolicyManager will return the policies for just the current resource right? Is there an existing service/method to get the content policies of all the components & style systems referenced on that page?



Level 2

@arunpatidar Thanks for the response.

The ReferenceSearch API doesn't work. It's returning null & not even returning the assets that I am getting through the AssetReferenceSearch API.