private boolean check(String path, Application app, TargetModuleID[] moduleIDs) {

    if (app.isVirtual()) {
      BundleDescriptor bd = app.getStandaloneBundleDescriptor();

      // standalone module, should be fast.
      if (moduleIDs.length != 1) {
        // wrong number...
        log("Error " + path + " is a standalone module, got more than 1 targetmoduleID");
        dumpModulesIDs("", moduleIDs);
        return false;
      }
    } else {
      for (int i = 0; i < moduleIDs.length; i++) {
        TargetModuleID parent = moduleIDs[i];
        Target target = parent.getTarget();
        log("Deployed on " + target.getName() + " with module ID " + parent.getModuleID());

        // now look at all the children
        TargetModuleID[] children = parent.getChildTargetModuleID();
        if (children == null) {
          log(
              "ERROR : App from "
                  + path
                  + " has "
                  + app.getBundleDescriptors().size()
                  + " modules but I didn't get any children TagetModuleID");
          return false;
        }

        // size is consistent ?
        if (children.length != app.getBundleDescriptors().size()) {
          log(
              "ERROR : App from "
                  + path
                  + " has "
                  + app.getBundleDescriptors().size()
                  + " modules but I got only "
                  + children.length
                  + " children TagetModuleID");
          return false;
        } else {
          log(
              "Expected "
                  + app.getBundleDescriptors().size()
                  + " children TargetModuleIDs and got "
                  + children.length);
        }

        for (int j = 0; j < children.length; j++) {
          TargetModuleID aChild = children[j];
          log("Processing " + aChild.getModuleID());

          String childModuleID = aChild.getModuleID();
          String[] splitted = childModuleID.split("#");
          if (splitted.length != 2) {
            log("Unknown sub module id " + childModuleID);
            return false;
          }

          // check that parent TargeTModuleID is correct
          if (aChild.getParentTargetModuleID().equals(parent)) {
            log("Child's parent TargetModuleID is correctly set");
          } else {
            log("Child's parent TargetModuleID is incorrect");
            return false;
          }

          String first = splitted[0];
          if (first.equals(parent.getModuleID())) {
            log("Correct parent module id for child " + childModuleID);
          } else {
            log("Incorrect parent module id for child " + childModuleID);
          }

          // look for the right module descriptor..
          ModuleDescriptor md = app.getModuleDescriptorByUri(splitted[1]);
          if (md == null) {
            log("Cannot find module descriptor for " + childModuleID);
            // return false;
          } else {
            log("Found module descriptor for " + childModuleID);
          }
          if (md.getModuleType().equals(ModuleType.WAR)) {
            log("Web module deployed at : " + aChild.getWebURL());
          }
        }
      }
    }
    // if we are here, it's good !
    return true;
  }