ResourceChangeListener not working at /content/usergenerated/asi/jcr | Adobe Higher Education
Skip to main content
Himanshu_Singhal
Community Advisor
Community Advisor
July 14, 2018
Répondu

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

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

Ce sujet a été fermé aux réponses.
Meilleure réponse par arunpatidar

Hi,

Please find below:

aem63app-repo/SampleJCRUGD.java at master · arunpatidar02/aem63app-repo · GitHub

5 commentaires

arunpatidar
Community Advisor
Community Advisor
July 14, 2018

Hi,

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

Thanks

Arun

Arun Patidar
Himanshu_Singhal
Community Advisor
Community Advisor
July 14, 2018

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

donquixote_dofl
Level 2
July 4, 2024

activating the service immediately, try to include this property in @8220494

immediate = true
arunpatidar
Community Advisor
Community Advisor
July 14, 2018

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

Arun Patidar
Himanshu_Singhal
Community Advisor
Community Advisor
July 15, 2018

Hi,

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

Regards,

Himanshu

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorRéponse
Community Advisor
July 15, 2018