Detecting Live Copy Variation Nodes in AEM 6.5 | Community
Skip to main content
New Participant
August 9, 2023
Solved

Detecting Live Copy Variation Nodes in AEM 6.5

  • August 9, 2023
  • 1 reply
  • 688 views

I am trying to escape a method when the node is a Live Copy Variation. This is the code I wrote:

 

Resource res = resourceResolver.getResource(path);
if (res == null) {
return;
}
ModifiableValueMap properties = res.adaptTo(ModifiableValueMap.class);
if (properties == null) {
return;
}
// Escape the method for Live Copy Variations Nodes
if (properties.containsKey("jcr:mixinTypes")) {
String[] array = (String[]) properties.get("jcr:mixinTypes");
boolean isLiveCopy = Arrays.asList(array).contains("cq:LiveRelationship");
if (isLiveCopy) {
return;
}
}

 Is there a better way to find out if the resource is a live copy variation?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

Hello @anasustic 

 

There is LiveRelationshipManager, which provides a lot of APIs for MSM.

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/msm/api/LiveRelationshipManager.html#hasLiveRelationship-org.apache.sling.api.resource.Resource-

 

For your usecase, please try using following API

hasLiveRelationship(Resource resource)
Checks if the given sync target is part of a Live Copy relationship.

1 reply

aanchal-sikka
aanchal-sikkaAccepted solution
New Participant
August 9, 2023

Hello @anasustic 

 

There is LiveRelationshipManager, which provides a lot of APIs for MSM.

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/msm/api/LiveRelationshipManager.html#hasLiveRelationship-org.apache.sling.api.resource.Resource-

 

For your usecase, please try using following API

hasLiveRelationship(Resource resource)
Checks if the given sync target is part of a Live Copy relationship.
Aanchal Sikka
anasusticAuthor
New Participant
August 9, 2023

Thanks so much @aanchal-sikka