filtering properties before replication using ReplicationContentFilter | Community
Skip to main content
September 30, 2024

filtering properties before replication using ReplicationContentFilter

  • September 30, 2024
  • 2 replies
  • 727 views

Hello all , I have to filter out properties for replication. I used below logic . it is working fine in local machines but accepts(Property prop) is not getting called in cloud environment. Here is piece of logic. 

 
@8220494(service = ReplicationContentFilter.class)
public class ReplicationContentFilterImpl implements ReplicationContentFilter {
 
Logger logger = LoggerFactory.getLogger(getClass());
 
    static boolean Approver = false;
public static List<String> refList = new ArrayList<String>();
 
@9944223
public boolean accepts(Node node) {
// TODO Auto-generated method stub
logger.info("accepts(node) is trigerred and is he approver : {}", Approver);
if(Approver) {
logger.info("inside if approver node");
try {
return !node.getPath().startsWith("/conf");
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
 
@9944223
public boolean accepts(Property property) {
// TODO Auto-generated method stub
logger.info("inside accepts(prop) {}",property);
if(Approver) {
try {
logger.info("inside approver condition accepts property");
if(property.getType()!=PropertyType.STRING) return true;
logger.info("string prop value");
 
if(property.isMultiple()) {
Value[] values = property.getValues();
for(Value value : values) {
if(value.getString().startsWith("/conf")) {
return false;
}
}
 
return true;
}
 
logger.info("not multi");
 
String value = property.getValue().toString();
logger.info("prop value : {}",value);
if(value.startsWith("/conf")) {
logger.info("inside value conf: {}", value);
return false;
}
String path = property.getPath();
String refNode[] = value.split("/");
String node[] = path.split("/");
logger.info("prop value is {}",value);
if(refNode.length>4 && node.length>3 && refNode[4].equals(node[3])) {
logger.info("path : {} refNode : {},node  : {}",path,refNode[4],node[3]);
if(!refNode[5].equals(node[4])) {
logger.info("refs are adding {}",value);
refList.add(value);
return false;
}
}
 
} catch (IllegalStateException | RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
 
@9944223
public boolean allowsDescent(Node node) {
// TODO Auto-generated method stub
logger.info("descendent");
return accepts(node);
}
 
@9944223
public List<String> getFilteredPaths() {
// TODO Auto-generated method stub
return null;
}
 
}

 

I think there is nothing wrong in code . why only in cloud environment it is not processing accpts(property) method ?

 

by the way i knew this method not getting called through logs.

 

I am eagerly waiting for answer

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

MukeshYadav_
Community Advisor
Community Advisor
September 30, 2024

Hi @alisyed1 ,

You may try by increasing the service ranking as if it is working in local.

Also just cross check if issue is reproducible in local by using same(latest) SDK version as in cloud

@Component(
service = {ReplicationContentFilter.class},
property = {
Constants.SERVICE_RANKING+":Integer=6000"
}
)

References https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/which-filter-is-run-first-lower-or-higher-order-priority-ranking/m-p/541873

Thanks

kautuk_sahni
Community Manager
Community Manager
October 16, 2024

@alisyed1 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
AliSyed1Author
October 16, 2024

Hai , I hope you are doing well. The code is good but execution is not reaching there due to error in another page. I somehow resolved it . Thanks for the support and sorry for the stupid question.

kautuk_sahni
Community Manager
Community Manager
October 17, 2024

@alisyed1 Could you kindly share how you resolved this? This would help in posterity.

Kautuk Sahni