Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

EventHandlers not working in AEM6.0

Avatar

Level 4

Hi Team,

We have created an event handlers which use to listen the events triggered while moving an Asset in DAM which a custom workflow.

But every time move asset button clicked the workflow gets triggered as per the configuration done in launcher.

Handler Code:

@Component(label = "Asset Moved Handler",
        description = "Provides further processing for moved assets.",
        metatype = true,
        immediate = true)
@Properties({
        @Property(label = "Event Topics",
                description = "[Required] Page Event Topics this event handler will to respond to.",
                name = EventConstants.EVENT_TOPIC,
                value = "com/adobe/cq/workflow/payload/move/job",
                propertyPrivate = true) })
@Service
public class AssetMovedHandler implements EventHandler {

    private static final Logger log = LoggerFactory.getLogger(AssetMovedHandler.class);

    @Property(name = "workflow.handler.asset-moved.workflow-model",
            label = "Workflow Model",
            value = "/etc/workflow/models/myproject/core-activation/jcr:content/model",
            description = "Workflow model to call after asset has been moved.")
    private String workflowModelId;

    @Property(name = "workflow.handler.asset-moved.asset-path",
            label = "Asset Path",
            value = "/content/dam/myproject/",
            description = "Path to apply handler to.")
    private String assetPath;

    @Reference
    private Replicator replicator;

    @Reference
    private ResourceResolverFactory resourceResolverFactory;

    @Reference
    private WorkflowService workflowService;

    @Override
    public void handleEvent(Event event) {
        // sanity check.
        log.debug("Get the event topic : "+event.getTopic());
        if ("com/adobe/cq/workflow/payload/move/job".equals(event.getTopic())) {
            Object destPathObj = event.getProperty("payload.move.dest.path");
            log.info("Get the destination object : "+ destPathObj);
            if (destPathObj != null) {
                String destPath = (String) destPathObj;
                // verify asset.
                if (destPath.startsWith(assetPath)) {
                    log.info("Asset path verified");                  
                }
            }
        }
    }

}

I just wanted to know where to look if event handlers are not working . Even all the services are active and working as expected. 

Please do let me know if I am missing anything.

Thank you

Sumit

1 Reply

Avatar

Employee

why are you using "com/adobe/cq/workflow/payload/move/job

this is for workflow internal use, what do you intend to do