/**
   * Loads metadata references from the given file
   *
   * @param xmlFile the XML file
   * @param documentBuilder the DOM document builder
   * @return the reference map
   */
  protected static Map<String, String> loadReferences(File xmlFile, DocumentBuilder documentBuilder)
      throws IOException, SAXException {
    Map<String, String> references = new LinkedHashMap<String, String>();

    Document document = documentBuilder.parse(xmlFile);
    Node itemsNode = XmlUtils.findFirstChild(document, "refs");

    for (Node itemNode : XmlUtils.findAllChildren(itemsNode, "ref")) {
      Node keyNode = itemNode.getAttributes().getNamedItem("key");
      Node uuidNode = itemNode.getAttributes().getNamedItem("uuid");
      references.put(keyNode.getTextContent(), uuidNode.getTextContent());
    }

    return references;
  }
  /**
   * Executes the generate goal
   *
   * @throws org.apache.maven.plugin.MojoExecutionException if an error occurs
   */
  public void execute() throws MojoExecutionException, MojoFailureException {
    if (!metadataDirectory.exists() || !metadataDirectory.isDirectory()) {
      throw new MojoFailureException(
          "Metadata configuration directory "
              + metadataDirectory
              + " doesn't exist or is not a directory");
    }

    try {
      // Instantiate some required DOM tools
      DocumentBuilder documentBuilder = XmlUtils.createBuilder();

      // Load provided distribution configuration
      MetadataConfig distroConfig =
          MetadataConfig.loadFromDirectory(metadataDirectory, documentBuilder, getLog());

      generateMetadataSource(distroConfig, outputDirectory, outputPackage);

      generateMetadataFilter(distroConfig, outputFilterFile);
    } catch (Exception ex) {
      throw new MojoExecutionException("Unexpected error", ex);
    }
  }