Code snippets – XML Add-On

Document State transitions

Get allowed Document State transitions for an asset.The API will return next allowed document state transitions for the user identified by userID attribute

JSONObject jsonResponse = ProfileService.getdocstateinfo(new String[] { assetPath }, userID, resourceResolver);
LOG.debug("Profile service response: {} for asset: {}", jsonResponse, assetPath);

JSONArray jsonArray = jsonResponse.getJSONObject(assetPath).getJSONArray(DOCSTATEJSON_ALLOWEDSTATES_KEY);

for (int i = 0; i < jsonArray.length(); i++) {"Valid transition: {}", jsonArray.getString(i));

Post-processing event handler

XML Documentation solution exposes com/adobe/fmdita/postprocess/complete event that is
used to perform any post-processing operations. This event is triggered whenever an operation is
performed on a DITA file. The following operations on a DITA file trigger this event:
• Upload
• Creation
• Modification
• Deletion

For more details, please refer to page 19 on

package com.techrevel.dam.core.fmdita.listeners;
import java.util.HashMap;
import java.util.Map;
import org.apache.jackrabbit.JcrConstants;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Appends path property to DITA Assets. Needed for Fluid Topic Integration
@Component(service = EventHandler.class, property = {
EventConstants.EVENT_TOPIC + "=com/adobe/fmdita/postprocess/complete", EventConstants.EVENT_FILTER
+ "=(|(operation=org/apache/sling/api/resource/Resource/ADDED)(operation=org/apache/sling/api/resource/Resource/CHANGED))" })
public class PostProcessingEventHandler implements EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(PostProcessingEventHandler.class);
private ResourceResolverFactory resolverFactory;
public void handleEvent(Event event) {
LOG.debug("Processing the JOB *******");
// The path of the file that triggered this event. Typically, this is the file
// on which an operation has been performed.
String path = (String) event.getProperty("path");
// Fetch resource resolver
Map<String, Object> serviceParams = new HashMap<>();
serviceParams.put(ResourceResolverFactory.SUBSERVICE, "subServiceName");
ResourceResolver resolver = null;
try {
resolver = resolverFactory.getServiceResourceResolver(serviceParams);
// Resolve path of DITA Asset
String ditaResourcePath = path.substring(0, path.indexOf(JcrConstants.JCR_CONTENT) 1);
// Resolve metadata resource of DITA Asset
String metadataResourcePath = path.substring(0, path.indexOf(DamConstants.RENDITIONS_FOLDER))
} catch (LoginException e) {
LOG.error("Exception while commiting path property ", e);
} finally {
if (resolver != null) {

Fetch all DITA Map dependencies

Please refer to link:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s