Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

ResourceChangeListener not working at /content/usergenerated/asi/jcr

Himanshu_Singhal
Community Advisor
Community Advisor

Hi,

I've written ResourceChangeListener to listen to "ADDED, REMOVED, CHANGED" event and code deployed on version AEM 6.3, 6.4.
The listener is working fine for any path under /content but not working  for /content/usergenerated/asi/jcr.

Anyone have any idea about why it doesn't work for this specific path?

Regards,

Himanshu

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor
5 Replies
Arun_Patidar
Community Advisor
Community Advisor

Hi,

Could you please share more details? or sample code? You may check permission under /content/usergenerated/asi/jcr

Thanks

Arun

Himanshu_Singhal
Community Advisor
Community Advisor

Hi,

Please find below the sample code.

import java.util.List;

import org.apache.sling.api.resource.observation.ResourceChange;

import org.apache.sling.api.resource.observation.ResourceChangeListener;

import org.osgi.service.component.annotations.Component;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

/**

* User Generated Data replicator

*/

@Component(service = ResourceChangeListener.class, property = { ResourceChangeListener.PATHS + "=" + "/content",

ResourceChangeListener.CHANGES + "=" + "ADDED", ResourceChangeListener.CHANGES + "=" + "REMOVED",

ResourceChangeListener.CHANGES + "=" + "CHANGED" })

public class UGCDataReplicator implements ResourceChangeListener {

private Logger log = LoggerFactory.getLogger(this.getClass());

@Override

public void onChange(List<ResourceChange> resourceChanges) {

log.debug("Changed Resources " + resourceChanges);

}

}

And, about the permission there shouldn't be any concern cos' this code is being executed on Author with logged in as Admin user.

Regards,

Himanshu

Arun_Patidar
Community Advisor
Community Advisor

Hi,

Yes, you are right. Your code looks ok and I also tried. But ResourceChangeListener is not working under that path.

However JCR Events working as expected on the same path.

I am not sure what could be the reason.

Thanks

Arun

Himanshu_Singhal
Community Advisor
Community Advisor

Hi,

Could you please provide sample code for JCR event based on OSGI R6 annotation?

Regards,

Himanshu

Arun_Patidar
Correct answer by
Community Advisor
Community Advisor