Expand my Community achievements bar.

SOLVED

How to programmatically check if a inheritance in cancelled on the path provided?

Avatar

Level 2

Hi,

 

I have a component with has a parsys inside it.

Now on breaking the  inheritance on a page for this component works flawlessly as expected.

 

Now for a different requirement i am provided a path, but i need to check if the provided path's inheritance is broken or on. How to achieve that?

FYI: I have been checking "cq:LiveSyncCancelled" mixin type is present or not. However it doesnt seem to work for the below scenario:

 

  1. Component: I have a parsys inside the component
  2. Authored the above component on a page
  3. Inside the components parsys, i authored multiple components
  4. Now break the inhertitance of the parent component
  5. I notice that cq:LiveSyncCancelled gets added to the parent node but not for the components authored inside the parsys

So my assumption of checking if the cq:LiveSyncCancelled is present or not is not a viable solution. Any API?

 

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@puniths34934369 

Check cq:isCancelledForChildren (Boolean) true property for the specified path.

View solution in original post

4 Replies

Avatar

Community Advisor

I am thinking on the other way like get the properties of the resource and check it inherited from parent or other resource:

HierarchyNodeInheritanceValueMap - This will help to retrieve the inherited properties from parent pages.

ResourceResolver resourceResolver = slingRequest.getResourceResolver();
String resourceContentPath = resourcePathURL<>;
Resource res = resourceResolver.getResource(resourceContentPath);

InheritanceValueMap inheritedProp = new HierarchyNodeInheritanceValueMap(res);
String prop1 = inheritedProp.getInherited(<property1>, String.class);

Avatar

Employee Advisor
I will recommend using MSM APIs as they abstract the internals of MSM Livecopy relationships. Even if Adobe changes some properties in future MSM releases the API will still work. So it is always better to use the abstractions and domain APIs. Also, with the above code the inheritance valuemap will traverse the entire tree structure which may not be performant.

Avatar

Correct answer by
Community Advisor

@puniths34934369 

Check cq:isCancelledForChildren (Boolean) true property for the specified path.