private int displayFeatureTree(FeaturesService admin, String featureName, String featureVersion, String prefix) throws Exception {
int unresolved = 0;
Feature resolved = admin.getFeature(featureName, featureVersion);
if (resolved != null) {
System.out.println(prefix + " " + resolved.getName() + " " + resolved.getVersion());
} else {
System.out.println(prefix + " " + featureName + " " + featureVersion + " *");
unresolved++;
}
if (resolved != null) {
if (bundle) {
List<String> bundleLocation = new LinkedList<String>();
List<BundleInfo> bundles = resolved.getBundles();
for (BundleInfo bundleInfo : bundles) {
bundleLocation.add(bundleInfo.getLocation());
}
if (conditional) {
for (Conditional cond : resolved.getConditional()) {
List<? extends Feature> condition = cond.getCondition();
List<BundleInfo> conditionalBundles = cond.getBundles();
for (BundleInfo bundleInfo : conditionalBundles) {
bundleLocation.add(bundleInfo.getLocation() + "(condition:"+condition+")");
}
}
}
for (int i = 0, j = bundleLocation.size(); i < j; i++) {
System.out.println(prefix + " " + (i + 1 == j ? "\\" : "+") + " " + bundleLocation.get(i));
}
}
prefix += " ";
List<Feature> dependencies = resolved.getDependencies();
for (int i = 0, j = dependencies.size(); i < j; i++) {
Feature toDisplay = dependencies.get(i);
unresolved += displayFeatureTree(admin, toDisplay.getName(), toDisplay.getVersion(), prefix +1);
}
if (conditional) {
for (Conditional cond : resolved.getConditional()) {
List<Feature> conditionDependencies = cond.getDependencies();
for (int i = 0, j = conditionDependencies.size(); i < j; i++) {
Feature toDisplay = dependencies.get(i);
unresolved += displayFeatureTree(admin, toDisplay.getName(), toDisplay.getVersion(), prefix +1);
}
}
}
}