Beispiel #1
0
  protected void writeWebApps() throws IOException {
    // write to a subdirectory of the default temp directory
    File deployDir = new File(RunUtil.getRunDir(), getWebappDir());
    deployDir.mkdirs();

    // figure out the set of files to add or remove
    List<String> addFiles = new ArrayList<String>();
    List<String> removeFiles = new ArrayList<String>();
    FileListUtil.compareDirs("META-INF/" + getWebappDir(), deployDir, addFiles, removeFiles);

    // remove the files to remove
    for (String removeFile : removeFiles) {
      File remove = new File(deployDir, removeFile);

      // files have been extracted into directories
      if (remove.isDirectory()) {
        RunUtil.deleteDir(remove);
      }
    }

    for (String addFile : addFiles) {
      String fullPath = "/" + getWebappDir() + "/" + addFile;

      // make sure to clear the directory before we write to it
      File existingDir = new File(deployDir, addFile);
      if (existingDir.exists() && existingDir.isDirectory()) {
        RunUtil.deleteDir(existingDir);
      }

      RunUtil.extractJar(getClass(), fullPath, deployDir);
    }

    // write the updated checksum list
    RunUtil.extract(getClass(), "/META-INF/" + getWebappDir() + "/files.list", deployDir);
  }
Beispiel #2
0
  protected void writeDocumentRoot() throws IOException {
    File docDir = new File(RunUtil.getRunDir(), "docRoot");
    docDir.mkdirs();

    // figure out the set of files to add or remove
    List<String> addFiles = new ArrayList<String>();
    List<String> removeFiles = new ArrayList<String>();
    FileListUtil.compareDirs("META-INF/docroot", docDir, addFiles, removeFiles);

    for (String removeFile : removeFiles) {
      File file = new File(docDir, removeFile);
      file.delete();
    }

    for (String addFile : addFiles) {
      String fullPath = "/docroot/" + addFile;
      InputStream fileIs = WebServerLauncher.class.getResourceAsStream(fullPath);

      RunUtil.writeToFile(fileIs, new File(docDir, addFile));
      fileIs.close();
    }

    // write the updated checksum list
    RunUtil.extract(getClass(), "/META-INF/docroot/files.list", docDir);
  }