List of usage examples for org.apache.commons.compress.archivers.zip ZipArchiveEntry isDirectory
public boolean isDirectory()
From source file:autoupdater.FileDAO.java
/** * Unzips a zip archive.//from ww w . j a va 2 s. c o m * * @param zip the zipfile to unzip * @param fileLocationOnDiskToDownloadTo the folder to unzip in * @return true if successful * @throws IOException */ public boolean unzipFile(ZipFile zip, File fileLocationOnDiskToDownloadTo) throws IOException { FileOutputStream dest = null; InputStream inStream = null; Enumeration<ZipArchiveEntry> zipFileEnum = zip.getEntries(); while (zipFileEnum.hasMoreElements()) { ZipArchiveEntry entry = zipFileEnum.nextElement(); File destFile = new File(fileLocationOnDiskToDownloadTo, entry.getName()); if (!destFile.getParentFile().exists()) { if (!destFile.getParentFile().mkdirs()) { throw new IOException("could not create the folders to unzip in"); } } if (!entry.isDirectory()) { try { dest = new FileOutputStream(destFile); inStream = zip.getInputStream(entry); IOUtils.copyLarge(inStream, dest); } finally { if (dest != null) { dest.close(); } if (inStream != null) { inStream.close(); } } } else { if (!destFile.exists()) { if (!destFile.mkdirs()) { throw new IOException("could not create folders to unzip file"); } } } } zip.close(); return true; }
From source file:at.spardat.xma.xdelta.JarPatcher.java
/** * Apply delta./*from ww w. j av a2 s.com*/ * * @param patch the patch * @param source the source * @param output the output * @param list the list * @param prefix the prefix * @throws IOException Signals that an I/O exception has occurred. */ public void applyDelta(ZipFile patch, ZipFile source, ZipArchiveOutputStream output, BufferedReader list, String prefix) throws IOException { String fileName = null; try { for (fileName = (next == null ? list.readLine() : next); fileName != null; fileName = (next == null ? list.readLine() : next)) { if (next != null) next = null; if (!fileName.startsWith(prefix)) { next = fileName; return; } int crcDelim = fileName.lastIndexOf(':'); int crcStart = fileName.lastIndexOf('|'); long crc = Long.valueOf(fileName.substring(crcStart + 1, crcDelim), 16); long crcSrc = Long.valueOf(fileName.substring(crcDelim + 1), 16); fileName = fileName.substring(prefix.length(), crcStart); if ("META-INF/file.list".equalsIgnoreCase(fileName)) continue; if (fileName.contains("!")) { String[] embeds = fileName.split("\\!"); ZipArchiveEntry original = getEntry(source, embeds[0], crcSrc); File originalFile = File.createTempFile("jardelta-tmp-origin-", ".zip"); File outputFile = File.createTempFile("jardelta-tmp-output-", ".zip"); Exception thrown = null; try (FileOutputStream out = new FileOutputStream(originalFile); InputStream in = source.getInputStream(original)) { int read = 0; while (-1 < (read = in.read(buffer))) { out.write(buffer, 0, read); } out.flush(); applyDelta(patch, new ZipFile(originalFile), new ZipArchiveOutputStream(outputFile), list, prefix + embeds[0] + "!"); } catch (Exception e) { thrown = e; throw e; } finally { originalFile.delete(); try (FileInputStream in = new FileInputStream(outputFile)) { if (thrown == null) { ZipArchiveEntry outEntry = copyEntry(original); output.putArchiveEntry(outEntry); int read = 0; while (-1 < (read = in.read(buffer))) { output.write(buffer, 0, read); } output.flush(); output.closeArchiveEntry(); } } finally { outputFile.delete(); } } } else { try { ZipArchiveEntry patchEntry = getEntry(patch, prefix + fileName, crc); if (patchEntry != null) { // new Entry ZipArchiveEntry outputEntry = JarDelta.entryToNewName(patchEntry, fileName); output.putArchiveEntry(outputEntry); if (!patchEntry.isDirectory()) { try (InputStream in = patch.getInputStream(patchEntry)) { int read = 0; while (-1 < (read = in.read(buffer))) { output.write(buffer, 0, read); } } } closeEntry(output, outputEntry, crc); } else { ZipArchiveEntry sourceEntry = getEntry(source, fileName, crcSrc); if (sourceEntry == null) { throw new FileNotFoundException( fileName + " not found in " + sourceName + " or " + patchName); } if (sourceEntry.isDirectory()) { ZipArchiveEntry outputEntry = new ZipArchiveEntry(sourceEntry); output.putArchiveEntry(outputEntry); closeEntry(output, outputEntry, crc); continue; } patchEntry = getPatchEntry(patch, prefix + fileName + ".gdiff", crc); if (patchEntry != null) { // changed Entry ZipArchiveEntry outputEntry = new ZipArchiveEntry(sourceEntry); outputEntry.setTime(patchEntry.getTime()); output.putArchiveEntry(outputEntry); byte[] sourceBytes = new byte[(int) sourceEntry.getSize()]; try (InputStream sourceStream = source.getInputStream(sourceEntry)) { for (int erg = sourceStream .read(sourceBytes); erg < sourceBytes.length; erg += sourceStream .read(sourceBytes, erg, sourceBytes.length - erg)) ; } InputStream patchStream = patch.getInputStream(patchEntry); GDiffPatcher diffPatcher = new GDiffPatcher(); diffPatcher.patch(sourceBytes, patchStream, output); patchStream.close(); outputEntry.setCrc(crc); closeEntry(output, outputEntry, crc); } else { // unchanged Entry ZipArchiveEntry outputEntry = new ZipArchiveEntry(sourceEntry); output.putArchiveEntry(outputEntry); try (InputStream in = source.getInputStream(sourceEntry)) { int read = 0; while (-1 < (read = in.read(buffer))) { output.write(buffer, 0, read); } } output.flush(); closeEntry(output, outputEntry, crc); } } } catch (PatchException pe) { IOException ioe = new IOException(); ioe.initCause(pe); throw ioe; } } } } catch (Exception e) { System.err.println(prefix + fileName); throw e; } finally { source.close(); output.close(); } }
From source file:com.naryx.tagfusion.expression.function.file.Unzip.java
private void performUnzip(cfSession _session, File _zipfile, File _destination, String charset, boolean _flatten, boolean overwrite) throws cfmRunTimeException { ZipFile zFile = null;//from w w w . jav a 2 s. c o m try { zFile = new ZipFile(_zipfile, charset); } catch (IOException ze) { throwException(_session, "Failed to extract zip file. Check the file is a valid zip file."); } BufferedInputStream in = null; InputStream zIn = null; FileOutputStream fout = null; File nextFile = null; String destinationFilename; byte[] buffer = new byte[4096]; int read; try { Enumeration<? extends ZipArchiveEntry> files = zFile.getEntries(); if (files == null) { throwException(_session, "Failed to extract zip file. Check the file is a valid zip file."); } ZipArchiveEntry nextEntry; // while unzip stuff goes here while (files.hasMoreElements()) { nextEntry = files.nextElement(); destinationFilename = nextEntry.getName(); File checkFile = new File( _destination.getAbsolutePath() + File.separatorChar + destinationFilename); if (checkFile.exists() && !overwrite) { throwException(_session, "File already exist"); } else { if (!nextEntry.isDirectory()) { if (_flatten) { int pathEnd = destinationFilename.lastIndexOf('/'); if (pathEnd != -1) destinationFilename = destinationFilename.substring(pathEnd + 1); } nextFile = new File( _destination.getAbsolutePath() + File.separatorChar + destinationFilename); try { nextFile = nextFile.getCanonicalFile(); } catch (IOException ignore) { } // use original nextFile if getCanonicalFile() fails File parent = nextFile.getParentFile(); if (parent != null) { parent.mkdirs(); // create the parent directory structure if needed } try { zIn = zFile.getInputStream(nextEntry); in = new BufferedInputStream(zIn); fout = new FileOutputStream(nextFile, false); while ((read = in.read(buffer)) != -1) { fout.write(buffer, 0, read); } fout.flush(); } catch (IOException ioe) { throwException(_session, "Failed to extract entry [" + nextEntry.getName() + "] from zip file to " + nextFile.getAbsolutePath() + ". Check the permissions are suitable to allow this file to be written."); } finally { StreamUtil.closeStream(in); StreamUtil.closeStream(zIn); StreamUtil.closeStream(fout); } } else if (!_flatten) { destinationFilename = nextEntry.getName(); nextFile = new File( _destination.getAbsolutePath() + File.separatorChar + destinationFilename); try { nextFile = nextFile.getCanonicalFile(); } catch (IOException ignore) { // use original nextFile if getCanonicalFile() fails } nextFile.mkdirs(); } } } } finally { try { zFile.close(); } catch (IOException ignored) { } } }
From source file:com.nit.libanki.Utils.java
public static boolean unzipFiles(ZipFile zipFile, String targetDirectory, String[] zipEntries, HashMap<String, String> zipEntryToFilenameMap) { byte[] buf = new byte[FILE_COPY_BUFFER_SIZE]; File dir = new File(targetDirectory); if (!dir.exists() && !dir.mkdirs()) { Log.e(AnkiDroidApp.TAG, "Utils.unzipFiles: Could not create target directory: " + targetDirectory); return false; }/* www . ja v a 2 s . c o m*/ if (zipEntryToFilenameMap == null) { zipEntryToFilenameMap = new HashMap<String, String>(); } BufferedInputStream zis = null; BufferedOutputStream bos = null; try { for (String requestedEntry : zipEntries) { ZipArchiveEntry ze = zipFile.getEntry(requestedEntry); if (ze != null) { String name = ze.getName(); if (zipEntryToFilenameMap.containsKey(name)) { name = zipEntryToFilenameMap.get(name); } File destFile = new File(dir, name); File parentDir = destFile.getParentFile(); if (!parentDir.exists() && !parentDir.mkdirs()) { return false; } if (!ze.isDirectory()) { // Log.i(AnkiDroidApp.TAG, "uncompress " + name); zis = new BufferedInputStream(zipFile.getInputStream(ze)); bos = new BufferedOutputStream(new FileOutputStream(destFile), FILE_COPY_BUFFER_SIZE); int n; while ((n = zis.read(buf, 0, FILE_COPY_BUFFER_SIZE)) != -1) { bos.write(buf, 0, n); } bos.flush(); bos.close(); zis.close(); } } } } catch (IOException e) { Log.e(AnkiDroidApp.TAG, "Utils.unzipFiles: Error while unzipping archive.", e); return false; } finally { try { if (bos != null) { bos.close(); } } catch (IOException e) { Log.e(AnkiDroidApp.TAG, "Utils.unzipFiles: Error while closing output stream.", e); } try { if (zis != null) { zis.close(); } } catch (IOException e) { Log.e(AnkiDroidApp.TAG, "Utils.unzipFiles: Error while closing zip input stream.", e); } } return true; }
From source file:it.geosolutions.geobatch.unredd.script.ingestion.IngestionAction.java
/** * @param inputZipFile/*from ww w. j a va2s .c om*/ * @param unzipDir * @throws ActionException */ public void unzipInputFile(File inputZipFile, File unzipDir) throws ActionException { LOGGER.debug("Unzipping " + inputZipFile + " into " + unzipDir); ArchiveInputStream in = null; try { final InputStream is = new FileInputStream(inputZipFile); in = new ArchiveStreamFactory().createArchiveInputStream("zip", is); ZipArchiveEntry entry; while ((entry = (ZipArchiveEntry) in.getNextEntry()) != null) { File currentFile = new File(unzipDir, entry.getName()); if (entry.isDirectory()) { LOGGER.info("Unzipping dir " + entry); FileUtils.forceMkdir(currentFile); } else { LOGGER.info("Unzipping file " + entry); //create parent dir if needed File parent = currentFile.getParentFile(); if (!parent.exists()) { if (LOGGER.isInfoEnabled()) LOGGER.info("Forcing creation of parent dir " + parent); FileUtils.forceMkdir(parent); } OutputStream out = new FileOutputStream(currentFile); IOUtils.copy(in, out); out.flush(); IOUtils.closeQuietly(out); } } LOGGER.info("Zip extracted in " + unzipDir); } catch (Exception e) { throw new ActionException(this, "Error extracting from " + inputZipFile, e); } finally { IOUtils.closeQuietly(in); } }
From source file:br.com.thiaguten.archive.ZipArchive.java
/** * Override to make use of the ZipFile class instead of the ZipArchiveInputStream class. * https://commons.apache.org/proper/commons-compress/zip.html *//*from w ww. java 2 s .co m*/ @Override public Path decompress(Path path) throws IOException { Path decompressDir = removeExtension(path); logger.debug("reading archive file " + path); try (ZipFile zipFile = new ZipFile(path.toString())) { // creates a new decompress folder to not override if already exists // if you do not want this behavior, just comment this line decompressDir = createFile(ArchiveAction.DECOMPRESS, decompressDir.getParent(), decompressDir); createDirectories(decompressDir); logger.debug("creating the decompress destination directory " + decompressDir); Enumeration<ZipArchiveEntry> entries = zipFile.getEntries(); while (entries.hasMoreElements()) { final ZipArchiveEntry zipArchiveEntry = entries.nextElement(); if (zipFile.canReadEntryData(zipArchiveEntry)) { final String entryName = zipArchiveEntry.getName(); final InputStream archiveInputStream = zipFile.getInputStream(zipArchiveEntry); final Path target = Paths.get(decompressDir.toString(), entryName); final Path parent = target.getParent(); if (parent != null && !exists(parent)) { createDirectories(parent); } logger.debug("reading compressed path " + entryName); if (!zipArchiveEntry.isDirectory()) { try (OutputStream outputStream = new BufferedOutputStream(newOutputStream(target))) { logger.debug("writting compressed " + entryName + " file in the decompress directory"); // byte[] content = new byte[(int) zipArchiveEntry.getSize()]; // outputStream.write(content); IOUtils.copy(archiveInputStream, outputStream); } } } } logger.debug("finishing the decompress in the directory: " + decompressDir); } return decompressDir; }
From source file:de.catma.ui.repository.wizard.FileTypePanel.java
private ArrayList<SourceDocumentResult> makeSourceDocumentResultsFromInputFile(TechInfoSet inputTechInfoSet) throws MalformedURLException, IOException { ArrayList<SourceDocumentResult> output = new ArrayList<SourceDocumentResult>(); FileType inputFileType = FileType.getFileType(inputTechInfoSet.getMimeType()); if (inputFileType != FileType.ZIP) { SourceDocumentResult outputSourceDocumentResult = new SourceDocumentResult(); String sourceDocumentID = repository.getIdFromURI(inputTechInfoSet.getURI()); outputSourceDocumentResult.setSourceDocumentID(sourceDocumentID); SourceDocumentInfo outputSourceDocumentInfo = outputSourceDocumentResult.getSourceDocumentInfo(); outputSourceDocumentInfo.setTechInfoSet(new TechInfoSet(inputTechInfoSet)); outputSourceDocumentInfo.setContentInfoSet(new ContentInfoSet()); outputSourceDocumentInfo.getTechInfoSet().setFileType(inputFileType); output.add(outputSourceDocumentResult); } else { //TODO: put this somewhere sensible URI uri = inputTechInfoSet.getURI(); ZipFile zipFile = new ZipFile(uri.getPath()); Enumeration<ZipArchiveEntry> entries = zipFile.getEntries(); String tempDir = ((CatmaApplication) UI.getCurrent()).getTempDirectory(); IDGenerator idGenerator = new IDGenerator(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); String fileName = FilenameUtils.getName(entry.getName()); String fileId = idGenerator.generate(); File entryDestination = new File(tempDir, fileId); if (entryDestination.exists()) { entryDestination.delete(); }/*from w ww. j a v a2 s. c om*/ entryDestination.getParentFile().mkdirs(); if (entry.isDirectory()) { entryDestination.mkdirs(); } else { BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry)); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(entryDestination)); IOUtils.copy(bis, bos); IOUtils.closeQuietly(bis); IOUtils.closeQuietly(bos); SourceDocumentResult outputSourceDocumentResult = new SourceDocumentResult(); URI newURI = entryDestination.toURI(); String repositoryId = repository.getIdFromURI(newURI); // we need to do this as a catma:// is appended outputSourceDocumentResult.setSourceDocumentID(repositoryId); SourceDocumentInfo outputSourceDocumentInfo = outputSourceDocumentResult .getSourceDocumentInfo(); TechInfoSet newTechInfoSet = new TechInfoSet(fileName, null, newURI); // TODO: MimeType detection ? FileType newFileType = FileType.getFileTypeFromName(fileName); newTechInfoSet.setFileType(newFileType); outputSourceDocumentInfo.setTechInfoSet(newTechInfoSet); outputSourceDocumentInfo.setContentInfoSet(new ContentInfoSet()); output.add(outputSourceDocumentResult); } } ZipFile.closeQuietly(zipFile); } for (SourceDocumentResult sdr : output) { TechInfoSet sdrTechInfoSet = sdr.getSourceDocumentInfo().getTechInfoSet(); String sdrSourceDocumentId = sdr.getSourceDocumentID(); ProtocolHandler protocolHandler = getProtocolHandlerForUri(sdrTechInfoSet.getURI(), sdrSourceDocumentId, sdrTechInfoSet.getMimeType()); String mimeType = protocolHandler.getMimeType(); sdrTechInfoSet.setMimeType(mimeType); FileType sdrFileType = FileType.getFileType(mimeType); sdrTechInfoSet.setFileType(sdrFileType); if (sdrFileType.isCharsetSupported()) { Charset charset = Charset.forName(protocolHandler.getEncoding()); sdrTechInfoSet.setCharset(charset); } else { sdrTechInfoSet.setFileOSType(FileOSType.INDEPENDENT); } loadSourceDocumentAndContent(sdr); } return output; }
From source file:com.mattc.argus.concurrent.ZipProcess.java
public void run() { running.set(true);/*from w w w . jav a 2 s.c o m*/ //Zip Archive Entry Input Stream InputStream zis = null; try { zip = new ZipFile(zipFile); ZipArchiveEntry entry; Enumeration<ZipArchiveEntry> entries; entries = zip.getEntriesInPhysicalOrder(); //While there are still Entries to process, iterate while (entries.hasMoreElements()) { entry = entries.nextElement(); //Create the Empty File to Extract to and its Parent Directory //Notify Console and ProgressLog that a File is Being Extracted File destination = new File(destDir, entry.getName()); File dirs = new File(destination.getParent()); dirs.mkdirs(); Console.info("EXT: " + Utility.relativizePath(destination, destDir.getParentFile())); Notifications.updateLog("Extracting " + destination.getName() + (entry.isDirectory() ? " as Directory" : " as File") + "..."); /* * IMPORTANT * * Ensures that All Files have a Directory to go to. * * If a Folder is for some reason created as a File, this will * detect that. It will delete the file and re-create it as a Directory * so that installation can continue. * * If all else fails, print debug information and stop extracting. * It is unlikely the installed application will work without all files * being extracted. */ try { if (!destination.getParentFile().isDirectory()) { destination.getParentFile().delete(); destination.getParentFile().mkdirs(); } destination.createNewFile(); } catch (IOException e) { String errMsg = "Failure to Extract " + zipFile.getName(); String errPath = "PATH = " + destination.getCanonicalPath(); String errParent = "PARENT = " + destination.getParentFile().getCanonicalPath(); String errIsDir = "PARENT_IS_DIRECTORY = " + destination.getParentFile().isDirectory(); //Standard IO Error Information e.printStackTrace(System.err); System.err.println(errMsg); System.err.println(errPath); System.err.println(errParent); System.err.println(errIsDir); //Log File Error Information (Possibly Standard IO if DEBUG = True) Console.exception(e); Console.error(errMsg); Console.error(errPath); Console.error(errParent); Console.error(errIsDir); //GUI Error Information. For End User. String msg = errMsg + "\n" + errPath + "\n" + errParent + "\n" + errIsDir; Notifications.exception(msg, e); //Attempt to Delete the Partially Unzipped and Non-functional install Directory if (!Utility.deleteDirectory(destDir)) { Console.error("Although extraction failed, the erroneous directory could not be removed!"); Notifications.error("Failure to Delete Partially Unzipped Directory!"); } else Console.info("Erroneous Directory Deleted Successfully!"); } //Establish a Stream to output data to the destination file zis = zip.getInputStream(entry); fos = new FileOutputStream(destination); //Read Zip Entry data into buffer, output buffer to installation file for (int c = zis.read(buffer); c > 0; c = zis.read(buffer)) fos.write(buffer, 0, c); //Close Current Entry and Destination OutputStream zis.close(); fos.close(); } } catch (ZipException e) { Console.exception(e); } catch (IOException e) { Console.exception(e); } finally { //Ensure that All Streams Are Closed to prevent Memory Leaks Utility.closeStream(zis); Utility.closeStream(fos); Utility.closeStream(zip); running.set(false); } }
From source file:com.fujitsu.dc.core.bar.BarFileInstaller.java
/** * bar?????.//www . j a v a 2 s.c o m * <ul> * <li>bar????</li> * <li>bar???????</li> * <li>TODO bar??????</li> * </ul>. * @param barFile ????bar?File * @returns bar? */ private long checkBarFileContents(File barFile) { // bar? checkBarFileSize(barFile); ZipFile zipFile = null; try { zipFile = new ZipFile(barFile, "UTF-8"); Enumeration<ZipArchiveEntry> entries = zipFile.getEntries(); ZipArchiveEntry zae = null; long entryCount = 0; String entryName = null; try { long maxBarEntryFileSize = getMaxBarEntryFileSize(); // ?? Map<String, String> requiredBarFiles = setupBarFileOrder(); while (entries.hasMoreElements()) { zae = entries.nextElement(); entryName = zae.getName(); log.info("read: " + entryName); if (!zae.isDirectory()) { // ??????bar? entryCount++; // bar?? checkBarFileEntrySize(zae, entryName, maxBarEntryFileSize); // Box????? if (zae.getName().endsWith("/" + BarFileReadRunner.MANIFEST_JSON)) { checkAndReadManifest(entryName, zae, zipFile); } } // bar??????? if (!checkBarFileStructures(zae, requiredBarFiles)) { throw DcCoreException.BarInstall.BAR_FILE_INVALID_STRUCTURES.params(entryName); } } if (!requiredBarFiles.isEmpty()) { StringBuilder entryNames = new StringBuilder(); Object[] requiredFileNames = requiredBarFiles.keySet().toArray(); for (int i = 0; i < requiredFileNames.length; i++) { if (i > 0) { entryNames.append(" " + requiredFileNames[i]); } else { entryNames.append(requiredFileNames[i]); } } throw DcCoreException.BarInstall.BAR_FILE_INVALID_STRUCTURES.params(entryNames.toString()); } return entryCount; } catch (DcCoreException e) { throw e; } catch (Exception e) { log.info(e.getMessage(), e.fillInStackTrace()); throw DcCoreException.BarInstall.BAR_FILE_CANNOT_READ.params(entryName); } } catch (FileNotFoundException e) { throw DcCoreException.BarInstall.BAR_FILE_CANNOT_OPEN.params("barFile"); } catch (ZipException e) { throw DcCoreException.BarInstall.BAR_FILE_CANNOT_OPEN.params(e.getMessage()); } catch (IOException e) { throw DcCoreException.BarInstall.BAR_FILE_CANNOT_OPEN.params(e.getMessage()); } catch (DcCoreException e) { throw e; } catch (RuntimeException e) { throw DcCoreException.Server.UNKNOWN_ERROR; } finally { ZipFile.closeQuietly(zipFile); } }
From source file:io.personium.core.bar.BarFileInstaller.java
/** * bar?????./*ww w. j a v a 2 s . c om*/ * <ul> * <li>bar????</li> * <li>bar???????</li> * <li>TODO bar??????</li> * </ul>. * @param barFile ????bar?File * @returns bar? */ private long checkBarFileContents(File barFile) { // bar? checkBarFileSize(barFile); ZipFile zipFile = null; try { zipFile = new ZipFile(barFile, "UTF-8"); Enumeration<ZipArchiveEntry> entries = zipFile.getEntries(); ZipArchiveEntry zae = null; long entryCount = 0; String entryName = null; try { long maxBarEntryFileSize = getMaxBarEntryFileSize(); // ?? Map<String, String> requiredBarFiles = setupBarFileOrder(); while (entries.hasMoreElements()) { zae = entries.nextElement(); entryName = zae.getName(); log.info("read: " + entryName); if (!zae.isDirectory()) { // ??????bar? entryCount++; // bar?? checkBarFileEntrySize(zae, entryName, maxBarEntryFileSize); // Box????? if (zae.getName().endsWith("/" + BarFileReadRunner.MANIFEST_JSON)) { checkAndReadManifest(entryName, zae, zipFile); } } // bar??????? if (!checkBarFileStructures(zae, requiredBarFiles)) { throw PersoniumCoreException.BarInstall.BAR_FILE_INVALID_STRUCTURES.params(entryName); } } if (!requiredBarFiles.isEmpty()) { StringBuilder entryNames = new StringBuilder(); Object[] requiredFileNames = requiredBarFiles.keySet().toArray(); for (int i = 0; i < requiredFileNames.length; i++) { if (i > 0) { entryNames.append(" " + requiredFileNames[i]); } else { entryNames.append(requiredFileNames[i]); } } throw PersoniumCoreException.BarInstall.BAR_FILE_INVALID_STRUCTURES .params(entryNames.toString()); } return entryCount; } catch (PersoniumCoreException e) { throw e; } catch (Exception e) { log.info(e.getMessage(), e.fillInStackTrace()); throw PersoniumCoreException.BarInstall.BAR_FILE_CANNOT_READ.params(entryName); } } catch (FileNotFoundException e) { throw PersoniumCoreException.BarInstall.BAR_FILE_CANNOT_OPEN.params("barFile"); } catch (ZipException e) { throw PersoniumCoreException.BarInstall.BAR_FILE_CANNOT_OPEN.params(e.getMessage()); } catch (IOException e) { throw PersoniumCoreException.BarInstall.BAR_FILE_CANNOT_OPEN.params(e.getMessage()); } catch (PersoniumCoreException e) { throw e; } catch (RuntimeException e) { throw PersoniumCoreException.Server.UNKNOWN_ERROR; } finally { ZipFile.closeQuietly(zipFile); } }