Expand my Community achievements bar.

filtering properties before replication using ReplicationContentFilter

Avatar

Level 3

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. 

 
@component(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>();
 
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;
}
 
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;
}
 
public boolean allowsDescent(Node node) {
// TODO Auto-generated method stub
logger.info("descendent");
return accepts(node);
}
 
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

5 Replies

Avatar

Community Advisor

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

Thanks

Avatar

Administrator

@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

Avatar

Level 3

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.

Avatar

Administrator

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



Kautuk Sahni

Avatar

Level 3

Hi @kautuk_sahni  The provided code is good. As i mentioned this code is not trigerred due to no privileges for user to replicate those nodes. I just removed nodes from publication. so , problem solved.I hope this helps.