fixed a bug on Excludes

master
lucio.lelii 3 years ago
parent eab7dc19b4
commit 13016497f1

@ -79,7 +79,7 @@ public class Node2ItemConverter {
public Content getContent(Node node) throws RepositoryException, BackendGenericError{
Content content = new Content();
setGenericFields(node, Content.class, content);
setGenericFields(node, Content.class, null, content);
return content;
}
@ -92,7 +92,7 @@ public class Node2ItemConverter {
msg.setWithAttachments(false);
}
setRooItemCommonFields(node, Collections.emptyList(), Message.class, msg);
setRootItemCommonFields(node, Collections.emptyList(), Message.class, msg);
return msg;
}
@ -128,7 +128,7 @@ public class Node2ItemConverter {
item.setLocked(node.isLocked());
setRooItemCommonFields(node, excludes, classToHandle, item);
setRootItemCommonFields(node, excludes, classToHandle, item);
return item;
}
@ -141,7 +141,7 @@ public class Node2ItemConverter {
}
private <T extends RootItem> void setRooItemCommonFields(Node node, List<String> excludes, Class<T> classToHandle, T instance) throws RepositoryException{
private <T extends RootItem> void setRootItemCommonFields(Node node, List<String> excludes, Class<T> classToHandle, T instance) throws RepositoryException{
try{
instance.setParentId(node.getParent().getIdentifier());
@ -159,11 +159,11 @@ public class Node2ItemConverter {
instance.setPrimaryType(node.getPrimaryNodeType().getName());
setGenericFields(node, classToHandle, instance);
setGenericFields(node, classToHandle, excludes, instance);
}
private <T> void setGenericFields(Node node, Class<T> classToHandle, T instance){
private <T> void setGenericFields(Node node, Class<T> classToHandle,List<String> excludes, T instance){
for (Field field : retrieveAllFields(classToHandle)){
if (field.isAnnotationPresent(Attribute.class)){
Attribute attribute = field.getAnnotation(Attribute.class);
@ -180,6 +180,8 @@ public class Node2ItemConverter {
} else if (field.isAnnotationPresent(NodeAttribute.class)){
String fieldNodeName = field.getAnnotation(NodeAttribute.class).value();
//for now it excludes only first level node
if (excludes!=null && excludes.contains(fieldNodeName)) continue;
//for now it excludes only first level node
logger.trace("retrieving field node "+field.getName());
field.setAccessible(true);
try{

Loading…
Cancel
Save