Description
Suggested new method by Ate. Thx!
public <T> List<T> getChildBeans(String jcrPrimaryNodeType) {
Class annotatedClass = this.objectConverter.getAnnotatedClassFor(jcrPrimaryNodeType);
if (annotatedClass == null) {
log.warn("Cannot get ChildBeans for jcrPrimaryNodeType '{}' because there is no annotated class for this node type. Return null",
jcrPrimaryNodeType);
return new ArrayList<T>();
}
if (this.node == null) {
log.warn("Cannot get ChildBeans for jcrPrimaryNodeType '{}' because the jcr node is detached. ",
jcrPrimaryNodeType);
return new ArrayList<T>();
}
List<T> childBeans = new ArrayList<T>();
NodeIterator nodes;
try {
nodes = node.getNodes();
while (nodes.hasNext()) {
Node child = nodes.nextNode();
if (child == null)
try {
String nodeObjectType = objectConverter.getPrimaryObjectType(child);
if (nodeObjectType != null && nodeObjectType.equals(jcrPrimaryNodeType)) {
T bean = (T)this.objectConverter.getObject(child);
if (bean != null) { // && annotatedClass.isAssignableFrom(bean.getClass()))
}
} catch (ObjectBeanManagerException e) {
log.warn("Skipping bean: {}", e);
}
}
} catch (RepositoryException e)
return childBeans;