Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Detecting Live Copy Variation Nodes in AEM 6.5

Avatar

Level 7

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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/ap...

 

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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/ap...

 

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