private static int runReplacement(
      String env, ConfigTokens conf, String scope, List<File> toProcess) {
    int errorCount = 0;
    for (File xmlFile : toProcess) {
      try {
        Document xmlDoc = FileReader.getXMLDocument(xmlFile);
        Policy tokens;
        if (StringUtils.equalsIgnoreCase(scope, "proxy")) {
          tokens = conf.getConfigbyEnv(env).getProxyFileNameMatch(xmlFile.getName());
        } else if (StringUtils.equalsIgnoreCase(scope, "policy")) {
          tokens = conf.getConfigbyEnv(env).getPolicyFileNameMatch(xmlFile.getName());
        } else if (StringUtils.equalsIgnoreCase(scope, "target")) {
          tokens = conf.getConfigbyEnv(env).getTargetFileNameMatch(xmlFile.getName());
        } else {
          continue;
        } // === N E X T ===
        xmlDoc = replaceTokens(xmlDoc, tokens);
        DOMSource source = new DOMSource(xmlDoc);
        StreamResult result = new StreamResult(xmlFile);
        tltf.get().transform(source, result);
      } catch (Exception e) {
        logger.error("Error processing " + xmlFile.getName(), e);
        errorCount++;
      }
    }

    return errorCount;
  }
  public static void configurePackage(String env, File configFile) throws Exception {
    Transformer transformer = tltf.get();

    // get the list of files in proxies folder
    XMLFileListUtil listFileUtil = new XMLFileListUtil();

    ConfigTokens conf = FileReader.getBundleConfigs(configFile);

    Map<String, List<File>> filesToProcess = new HashMap<String, List<File>>();
    filesToProcess.put("proxy", listFileUtil.getProxyFiles(configFile));
    filesToProcess.put("policy", listFileUtil.getPolicyFiles(configFile));
    filesToProcess.put("target", listFileUtil.getTargetFiles(configFile));

    doTokenReplacement(env, conf, filesToProcess);

    // special case ...
    File proxyFile = listFileUtil.getAPIProxyFiles(configFile).get(0);
    Document xmlDoc =
        FileReader.getXMLDocument(proxyFile); // there would be only one file, at least one file

    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    XPathExpression expression = xpath.compile("/APIProxy/Description");

    NodeList nodes = (NodeList) expression.evaluate(xmlDoc, XPathConstants.NODESET);
    if (nodes.item(0).hasChildNodes()) {
      // sets the description to whatever is in the <proxyname>.xml file
      nodes.item(0).setTextContent(expression.evaluate(xmlDoc));
    } else {
      // if Description is empty, then it reverts back to appending the username, git hash, etc
      nodes.item(0).setTextContent(getComment(proxyFile));
    }

    DOMSource source = new DOMSource(xmlDoc);
    StreamResult result = new StreamResult(proxyFile);
    transformer.transform(source, result);
  }