/** Store a configuration for a type. A given type can have several configurations. */
  private void storeConfiguration(
      Map<String, List<Configuration>> configurationsMap, Configuration config) {

    List<Configuration> configurationsList = configurationsMap.get(config.getType());

    if (configurationsList == null) {
      configurationsList = new ArrayList<Configuration>();
      configurationsMap.put(config.getType(), configurationsList);
    }

    configurationsList.add(config);
  }
  public Map<String, List<Configuration>> parse(InputStream inputStream)
      throws InstallerParserException {
    if (inputStream == null) throw new InstallerParserException("InputStream null");

    Map<String, List<Configuration>> configurations = new HashMap<String, List<Configuration>>();
    try {
      // Parsing installers configuration inputstream
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();

      Document doc = builder.parse(inputStream);
      Element rootElement = doc.getDocumentElement();

      NodeList nodes = rootElement.getElementsByTagName("Configuration");
      logger.debug("Found " + nodes.getLength() + " configurations");
      for (int i = 0; i < nodes.getLength(); i++) {
        Element el = (Element) nodes.item(i);

        Configuration config = new Configuration();
        config.setPackageUrl(el.getAttribute("packageURL"));
        config.setInstallerCmd(el.getAttribute("installerCmd"));
        config.setSanityCheckCmd(el.getAttribute("sanityCheckCmd"));
        config.setGenerateNatureCmd(el.getAttribute("generateNatureCmd"));
        config.setType(el.getAttribute("type"));
        config.setName(el.getAttribute("name"));
        config.setVersion(el.getAttribute("version"));

        // stores this new configuration in the configuration map to be returned
        storeConfiguration(configurations, config);

        logger.debug(config.toString());
      }
    } catch (Exception e) {
      logger.error(e.getMessage());
      throw new InstallerParserException(e);
    }

    return configurations;
  }