Package com.google.opengse.io

Examples of com.google.opengse.io.JarFileCollection


    if (!exploded.exists()) {
      return true;
    }
    LOGGER.info("Checking differences between contents of " + warfile
        + " and " + exploded);
    JarFileCollection war = new JarFileCollection(warfile);
    String because = "contents of " + warfile + " is different from "
        + exploded + " because ";
    for (ZipEntry entry : war.getZipEntries()) {
      File destfile = getFileFromEntry(entry, exploded);
      if (!destfile.exists()) {
        LOGGER.warning(because + destfile + " does not exist");
        war.releaseResources();
        return true; // we are different!
      }
      if (entry.getSize() != destfile.length()) {
        LOGGER.warning(because + destfile + " is a different size");
        LOGGER.warning(warfile + " says it is " + entry.getSize() + " but "
            + destfile + " is " + destfile.length());
        war.releaseResources();
        return true; // we are different!
      }
    }
    war.releaseResources();
    return false; // no differences detected
  }
View Full Code Here


      throws IOException {
    LOGGER.warning("Exploding '" + warfile + "' into " + exploded);
    if (exploded.exists()) {
      FileUtil.deleteContentsOf(exploded);
    }
    JarFileCollection war = new JarFileCollection(warfile);
    List<String> entries = new ArrayList<String>(war.getFileNames());
    Collections.sort(entries, new WarComparator());
    for (String entry : entries) {
      // change (back)slashes to whatever our local OS uses
      String entryname = entry.replace('/', File.separatorChar);
      entryname = entryname.replace('\\', File.separatorChar);
      File destfile = new File(exploded, entryname);
      File tmpDestFile = new File(exploded, entryname + ".tmp");
      File dir = destfile.getParentFile();
      if (!dir.exists()) {
        dir.mkdirs();
      }
      LOGGER.info("extracting " + entry + " to " + tmpDestFile);
      FileOutputStream fileOutputStream = null;
      try {
        fileOutputStream = new FileOutputStream(tmpDestFile);
        war.writeEntryTo(entry, fileOutputStream);
        fileOutputStream.close();
        fileOutputStream = null;
        if (!tmpDestFile.renameTo(destfile)) {
          throw new IOException(
              "Cannot rename " + tmpDestFile + " to " + destfile);
        }
        if (!destfile.exists()) {
          throw new IOException(destfile + " does not exist!");
        }
      } catch (IOException ioe) {
        LOGGER.log(Level.WARNING, "", ioe);
        tmpDestFile.delete();
      } finally {
        if (fileOutputStream != null) {
          fileOutputStream.close();
        }
      }
    }
    war.releaseResources();
  }
View Full Code Here

TOP

Related Classes of com.google.opengse.io.JarFileCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.