Expand my Community achievements bar.

SOLVED

Event Type change required on clicking custom activate button on siteadmin

Avatar

Level 4

Hi ,

I  need a way to change the ReplicationAction.fromEvent(event).getType() to say which is unique say solr.Please let me know how to do it??

In siteadmin have added a extra menu item :-say activateSolr under Acitivate menu by adding /apps/wcm/core/content/siteadmin/actions/activate/menu/SolrActivate

and copied the below to solrActivate node
http://localhost:4502/libs/wcm/core/content/siteadmin/actions/activate/menu/activateNow.json

{"isDefaultAction":true,"handler":"CQ.wcm.SiteAdmin.activatePage","cls":"cq-siteadmin-activate-now","context":["toolbar","contextmenu"],"conditions":["CQ.wcm.SiteAdmin.hasAnySelection","CQ.wcm.SiteAdmin.notLocked"],"target":"CQ.wcm.SiteAdmin.getAnyTarget","jcr:primaryType":"nt:unstructured","text":"Activate"}

Now when i click on solrActivate it sends an event that is similar to activation ,with Event [topic=com/day/cq/replication] and could be mapped with ReplicationAction.fromEvent(event).getType()= ACTIVATE and replicationaction gives me the data 

ReplicationAction ReplicationAction{type=ACTIVATE, path[0]='/content/abc', time=1452329377136, userId='admin', revision='null'}

My need is that i need something different for mapping say ReplicationAction.fromEvent(event).getType()= SOLR. so by this way i will know that user has clicked in particual activateSolr menu item in particula

I am using the below code to map the same

public class ActivateEventHandler implements EventHandler, JobProcessor {
@Override
    public void handleEvent(Event event) {
            
    
        if ((null != event && event.getTopic().equals(ReplicationAction.EVENT_TOPIC))) {
            log.info("the ReplicationAction.fromEvent(event).getType()= {}", ReplicationAction.fromEvent(event).getType() );
            if(ReplicationAction.fromEvent(event).getType().equals(ReplicationActionType.ACTIVATE)){
                
                    if (EventUtil.isLocal(event)) {
                        JobUtil.processJob(event, this); 
                    }
            }
        }
    }

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

If that is the case then you can write a custom action handler for the custom menu item as I had mentioned in my last post instead of using the activation action and listening on activate events. 

View solution in original post

4 Replies

Avatar

Level 10

So you are trying to map a click action of a custom menu item to an AEM replication event. An AEM replication event is fired when an author replicates content - like a page. You can write custom event handler to handle replication events; however, not sure how you would simulate a replication event by clicking a custom menu item in AEM site admin.

I have never heard of this use case. However - on monday - I will check with other Adobe employees and post back.  

In mean time - if other community members have done this, then perhaps they will post a reply. 

Avatar

Employee Advisor

I don't now why you are creating a separate user action for activating to SOLR.  Why don't you always send content to SOLR on activation ? 

For your use case, why don't you create a custom menu click handler in SiteAdmin.Actions.js file and call your custom business logic of sending the content to SOLR and as well as activating it. The custom javascript handler method can make an AJAX request to the backend servlet for processing the node?   

Avatar

Level 4

The reason is i don't solr activation always or solr indexing always as per the needs .I would prefer only when authors requires it be indexed.

Avatar

Correct answer by
Employee Advisor

If that is the case then you can write a custom action handler for the custom menu item as I had mentioned in my last post instead of using the activation action and listening on activate events.