private static final Log log = LogFactory.getLog(AssociationTreeBeanPopulator.class);
private static List paths;
public static AssociationTreeBean populate(UserRegistry userRegistry, String resourcePath, String associationType) {
paths = new ArrayList();
AssociationTreeBean associationTreeBean = new AssociationTreeBean();
associationTreeBean.setResourcePath(resourcePath);
associationTreeBean.setAssoType(associationType);
associationTreeBean.setAssoIndex(0);
try {
List fatherAsso = provideChildAssociations(resourcePath, associationType, userRegistry);
if (fatherAsso != null) {
Iterator ifatherAssofaterAsso = fatherAsso.iterator();
while (ifatherAssofaterAsso.hasNext()) {
Association asso = (Association) ifatherAssofaterAsso.next();
associationTreeBean.setAssociationTree(associationTreeBean.getAssociationTree() +
createAssociationTree(
asso, associationTreeBean, userRegistry));
}
}
String [] pathArray = new String [paths.size()];
for(int i=0; i<paths.size(); i++) {
pathArray[i] = (String) paths.get(i);
}
associationTreeBean.setTreeCache(pathArray);
} catch (RegistryException e) {
String msg = "Failed to generate association tree of the resource " +
resourcePath + ". " + e.getMessage();
log.error(msg, e);
associationTreeBean.setErrorMessage(msg);
}
return associationTreeBean;
}