try {
JarFactory tmpJar = new JarFactory(tmpWorkDir);
tmpJar.unJar(new File(installerJar));
} catch (ZipException zipEx) {
throw new AddonFatalException("Could not unbundle jar "+installerJar, zipEx);
} catch (IOException ioEx) {
throw new AddonFatalException("Could not unbundle jar "+installerJar, ioEx);
}
File apiFrom = new File(tmpWorkDir + File.separator + API_JAR);
File apiTo = new File(appServerLibDir + File.separator + API_JAR);
File implNew = new File(tmpWorkDir + File.separator + IMPL_JAR);
File implOrig = new File(appServerLibDir + File.separator + IMPL_JAR);
File implOld = new File(appServerLibDir + File.separator + IMPL_JAR + ".old");
// check if api jar already exists. If it does, that's an error.
if (apiTo.exists()) {
throw new AddonFatalException("JSF API jar already exists - have you installed a different version already? If so, uninstall it before running this upgrade.");
}
// check if a backup impl file already exists, If it does, that's an error.
if (implOld.exists()) {
throw new AddonFatalException("JSF Impl backup jar already exists - have you installed a different version already? If so, uninstall it before running this upgrade.");
}
System.out.println("Installing new api file "+apiTo);
copyFile(apiFrom, apiTo);
if (!implOrig.exists()) {
throw new AddonFatalException("JSF implementation jar does not exist at: "+implOrig);
}
System.out.println("Backing up old impl file to "+implOld);
if (!implOrig.renameTo(implOld)) {
throw new AddonFatalException("Could not backup JSF impl jar from "+implOrig+" to "+implOld);
}
System.out.println("Installing new impl file "+implOrig);
copyFile(implNew, implOrig);