/** * Updates a given folder with the content of the update file * * @param forPath * @param exclusions list of files we don't want to remove from the given folder * @return * @throws IOException */ private void applyUpdateFor(String forPath, String[] exclusions) throws UpdateException { Boolean success; try { // First lets remove the "old" code in order to unzip the update on that folder File updatedFolder = new File(distributionHome + File.separator + forPath); if (exclusions != null) { success = UpdateUtil.deleteDirectory(updatedFolder, exclusions); } else { success = UpdateUtil.deleteDirectory(updatedFolder); } if (success) { logger.debug("Removed outdated folder: " + updatedFolder.getAbsolutePath()); } else { if (exclusions == null) { logger.error("Error removing outdated folder: " + updatedFolder.getAbsolutePath()); } else { // If we have exclusions is normal to have a false success because the folder could not be // removed as it have excluded files on it logger.debug("Removed outdated files in folder: " + updatedFolder.getAbsolutePath()); } } // Now we need to unzip the content of the update file into the given folder, we just removed // it, so lets create it again.... if (!updatedFolder.exists()) { success = updatedFolder.mkdirs(); if (success) { logger.debug("Created folder: " + updatedFolder.getAbsolutePath()); } else { logger.error("Error creating folder: " + updatedFolder.getAbsolutePath()); } } success = UpdateUtil.unzipDirectory(updateFile, distributionHome, forPath, dryrun); } catch (IOException e) { String error = "Error unzipping update file on: " + forPath; if (!UpdateAgent.isDebug) { error += Messages.getString("UpdateAgent.text.use.verbose", UpdateAgent.logFile); } throw new UpdateException(error, UpdateException.ERROR); } if (!success) { String error = "Error unzipping update file on: " + forPath; if (!UpdateAgent.isDebug) { error += Messages.getString("UpdateAgent.text.use.verbose", UpdateAgent.logFile); } throw new UpdateException(error, UpdateException.ERROR); } }