List of usage examples for java.util.zip ZipFile ZipFile
public ZipFile(File file, Charset charset) throws IOException
From source file:com.openAtlas.bundleInfo.maker.PackageLite.java
public static PackageLite parse(String apkPath) { ZipFile file = null;//from w ww . j a v a2s . co m StringBuilder xmlSb = new StringBuilder(100); try { File apkFile = new File(apkPath); file = new ZipFile(apkFile, ZipFile.OPEN_READ); ZipEntry entry = file.getEntry(DEFAULT_XML); AXmlResourceParser parser = new AXmlResourceParser(); parser.open(file.getInputStream(entry)); PackageLite packageLite = new PackageLite(); packageLite.apkMD5 = FileUtils.getMD5(apkPath); packageLite.size = apkFile.length(); packageLite.checkNativeLibs(file); packageLite.parse(parser); //System.err.println(packageLite.getBundleInfo().toString()); file.close(); return packageLite; //parser.close(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:it.readbeyond.minstrel.librarian.FormatHandlerCBZ.java
private List<ZipAsset> parseImagePlaylistEntry(String path, String playlistEntry) { List<ZipAsset> assets = new ArrayList<ZipAsset>(); try {/* w ww . j a v a2 s.c om*/ ZipFile zipFile = new ZipFile(new File(path), ZipFile.OPEN_READ); ZipEntry ze = zipFile.getEntry(playlistEntry); String text = this.getZipEntryText(zipFile, ze); String[] lines = text.split("\n"); // if we have lines if (lines.length > 0) { for (int i = 0; i < lines.length; i++) { String line = lines[i].trim(); // do we have a file name? if ((line.length() > 0) && (!line.startsWith("#"))) { HashMap<String, String> meta = new HashMap<String, String>(); // duration if (i + 1 < lines.length) { String line2 = lines[i + 1].trim(); if ((line2.length() > 0) && (!line2.startsWith("#"))) { i += 1; meta.put("duration", line2); // title if (i + 1 < lines.length) { String line3 = lines[i + 1].trim(); if ((line3.length() > 0) && (!line3.startsWith("#"))) { i += 1; meta.put("title", line3); } } } } // generate entry path File w = new File(new File(playlistEntry).getParent(), line); line = w.getAbsolutePath().substring(1); // add asset assets.add(new ZipAsset(line, meta)); } else { // either comment or blank line => continue } } } // close ZIP zipFile.close(); } catch (Exception e) { // nothing } return assets; }
From source file:it.readbeyond.minstrel.librarian.FormatHandlerAbstractZIP.java
protected void extractCover(File f, Format format, String publicationID) { String destinationName = publicationID + "." + format.getName() + ".png"; String entryName = format.getMetadatum("internalPathCover"); if ((entryName == null) || (entryName.equals(""))) { format.addMetadatum("relativePathThumbnail", ""); return;/*from ww w . j av a2 s . c om*/ } try { ZipFile zipFile = new ZipFile(f, ZipFile.OPEN_READ); ZipEntry entry = zipFile.getEntry(entryName); File destFile = new File(this.thumbnailDirectoryPath, "orig-" + destinationName); String destinationPath = destFile.getAbsolutePath(); BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry)); int numberOfBytesRead; byte data[] = new byte[BUFFER_SIZE]; FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE); while ((numberOfBytesRead = is.read(data, 0, BUFFER_SIZE)) > -1) { dest.write(data, 0, numberOfBytesRead); } dest.flush(); dest.close(); is.close(); fos.close(); // create thumbnail FileInputStream fis = new FileInputStream(destinationPath); Bitmap imageBitmap = BitmapFactory.decodeStream(fis); imageBitmap = Bitmap.createScaledBitmap(imageBitmap, this.thumbnailWidth, this.thumbnailHeight, false); ByteArrayOutputStream baos = new ByteArrayOutputStream(); imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] imageData = baos.toByteArray(); // write thumbnail to file File destFile2 = new File(this.thumbnailDirectoryPath, destinationName); String destinationPath2 = destFile2.getAbsolutePath(); FileOutputStream fos2 = new FileOutputStream(destFile2); fos2.write(imageData, 0, imageData.length); fos2.flush(); fos2.close(); baos.close(); // close ZIP zipFile.close(); // delete original cover destFile.delete(); // set relativePathThumbnail format.addMetadatum("relativePathThumbnail", destinationName); } catch (Exception e) { // nop } }
From source file:it.readbeyond.minstrel.librarian.FormatHandlerEPUB.java
private String getOPFPath(File f) { String ret = null;/*from www . ja va2 s.c om*/ try { ZipFile zipFile = new ZipFile(f, ZipFile.OPEN_READ); ZipEntry containerEntry = zipFile.getEntry(EPUB_CONTAINER_PATH); if (containerEntry != null) { InputStream is = zipFile.getInputStream(containerEntry); parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); parser.setInput(is, null); parser.nextTag(); ret = parseContainer(); is.close(); } zipFile.close(); } catch (Exception e) { // nop } return ret; }
From source file:net.sf.jabref.importer.ImportCustomizationDialog.java
/** * * @param frame//from w ww .jav a 2 s.c o m */ public ImportCustomizationDialog(final JabRefFrame frame) { super(frame, Localization.lang("Manage custom imports"), false); ImportTableModel tableModel = new ImportTableModel(); customImporterTable = new JTable(tableModel); TableColumnModel cm = customImporterTable.getColumnModel(); cm.getColumn(0).setPreferredWidth(COL_0_WIDTH); cm.getColumn(1).setPreferredWidth(COL_1_WIDTH); cm.getColumn(2).setPreferredWidth(COL_2_WIDTH); cm.getColumn(3).setPreferredWidth(COL_3_WIDTH); JScrollPane sp = new JScrollPane(customImporterTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); customImporterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); customImporterTable.setPreferredScrollableViewportSize(getSize()); if (customImporterTable.getRowCount() > 0) { customImporterTable.setRowSelectionInterval(0, 0); } JButton addFromFolderButton = new JButton(Localization.lang("Add from folder")); addFromFolderButton.addActionListener(e -> { CustomImporter importer = new CustomImporter(); importer.setBasePath(FileDialogs.getNewDir(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Collections.emptyList(), Localization.lang("Select Classpath of New Importer"), JFileChooser.CUSTOM_DIALOG, false)); String chosenFileStr = null; if (importer.getBasePath() != null) { chosenFileStr = FileDialogs.getNewFile(frame, importer.getFileFromBasePath(), Collections.singletonList(".class"), Localization.lang("Select new ImportFormat subclass"), JFileChooser.CUSTOM_DIALOG, false); } if (chosenFileStr != null) { try { importer.setClassName(pathToClass(importer.getFileFromBasePath(), new File(chosenFileStr))); importer.setName(importer.getInstance().getFormatName()); importer.setCliId(importer.getInstance().getId()); addOrReplaceImporter(importer); customImporterTable.revalidate(); customImporterTable.repaint(); } catch (Exception exc) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not instantiate %0", chosenFileStr)); } catch (NoClassDefFoundError exc) { JOptionPane.showMessageDialog(frame, Localization.lang( "Could not instantiate %0. Have you chosen the correct package path?", chosenFileStr)); } } }); addFromFolderButton .setToolTipText(Localization.lang("Add a (compiled) custom ImportFormat class from a class path.") + "\n" + Localization.lang("The path need not be on the classpath of JabRef.")); JButton addFromJarButton = new JButton(Localization.lang("Add from jar")); addFromJarButton.addActionListener(e -> { String basePath = FileDialogs.getNewFile(frame, new File(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)), Arrays.asList(".zip", ".jar"), Localization.lang("Select a Zip-archive"), JFileChooser.CUSTOM_DIALOG, false); if (basePath != null) { try (ZipFile zipFile = new ZipFile(new File(basePath), ZipFile.OPEN_READ)) { ZipFileChooser zipFileChooser = new ZipFileChooser(this, zipFile); zipFileChooser.setVisible(true); customImporterTable.revalidate(); customImporterTable.repaint(10); } catch (IOException exc) { LOGGER.info("Could not open Zip-archive.", exc); JOptionPane.showMessageDialog(frame, Localization.lang("Could not open %0", basePath) + "\n" + Localization.lang("Have you chosen the correct package path?")); } catch (NoClassDefFoundError exc) { LOGGER.info("Could not instantiate Zip-archive reader.", exc); JOptionPane.showMessageDialog(frame, Localization.lang("Could not instantiate %0", basePath) + "\n" + Localization.lang("Have you chosen the correct package path?")); } } }); addFromJarButton .setToolTipText(Localization.lang("Add a (compiled) custom ImportFormat class from a Zip-archive.") + "\n" + Localization.lang("The Zip-archive need not be on the classpath of JabRef.")); JButton showDescButton = new JButton(Localization.lang("Show description")); showDescButton.addActionListener(e -> { int row = customImporterTable.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(frame, Localization.lang("Please select an importer.")); } else { CustomImporter importer = ((ImportTableModel) customImporterTable.getModel()).getImporter(row); try { ImportFormat importFormat = importer.getInstance(); JOptionPane.showMessageDialog(frame, importFormat.getDescription()); } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException exc) { LOGGER.warn("Could not instantiate importer " + importer.getName(), exc); JOptionPane.showMessageDialog(frame, Localization.lang("Could not instantiate %0 %1", importer.getName() + ":\n", exc.getMessage())); } } }); JButton removeButton = new JButton(Localization.lang("Remove")); removeButton.addActionListener(e -> { int row = customImporterTable.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(frame, Localization.lang("Please select an importer.")); } else { customImporterTable.removeRowSelectionInterval(row, row); Globals.prefs.customImports .remove(((ImportTableModel) customImporterTable.getModel()).getImporter(row)); Globals.IMPORT_FORMAT_READER.resetImportFormats(); customImporterTable.revalidate(); customImporterTable.repaint(); } }); Action closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; JButton closeButton = new JButton(Localization.lang("Close")); closeButton.addActionListener(closeAction); JButton helpButton = new HelpAction(HelpFile.CUSTOM_IMPORTS).getHelpButton(); // Key bindings: JPanel mainPanel = new JPanel(); ActionMap am = mainPanel.getActionMap(); InputMap im = mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", closeAction); mainPanel.setLayout(new BorderLayout()); mainPanel.add(sp, BorderLayout.CENTER); JPanel buttons = new JPanel(); ButtonBarBuilder bb = new ButtonBarBuilder(buttons); buttons.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); bb.addGlue(); bb.addButton(addFromFolderButton); bb.addButton(addFromJarButton); bb.addButton(showDescButton); bb.addButton(removeButton); bb.addButton(closeButton); bb.addUnrelatedGap(); bb.addButton(helpButton); bb.addGlue(); getContentPane().add(mainPanel, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); this.setSize(getSize()); pack(); this.setLocationRelativeTo(frame); new FocusRequester(customImporterTable); }
From source file:io.github.jeremgamer.preview.actions.Download.java
private void download() { GeneralSave gs = new GeneralSave(); try {/*w w w . java 2 s. c o m*/ gs.load(new File("projects/" + Editor.getProjectName() + "/general.rbd")); } catch (IOException e1) { e1.printStackTrace(); } name = gs.getString("name"); new Thread(new Runnable() { @Override public void run() { if (url == null) { } else { File archive = new File(System.getProperty("user.home") + "/AppData/Roaming/.rocketbuilder/" + name + "/data.zip"); File outputFolder = new File( System.getProperty("user.home") + "/AppData/Roaming/.rocketbuilder/" + name); new File(System.getProperty("user.home") + "/AppData/Roaming/.rocketbuilder/" + name).mkdirs(); URL webFile; try { webFile = new URL(url); ReadableByteChannel rbc = Channels.newChannel(webFile.openStream()); fos = new FileOutputStream(System.getProperty("user.home") + "/AppData/Roaming/.rocketbuilder/" + name + "/data.zip"); HttpURLConnection httpConn = (HttpURLConnection) webFile.openConnection(); totalBytes = httpConn.getContentLength(); new Thread(new Runnable() { @Override public void run() { try { while (bytesCopied < totalBytes) { for (CustomProgressBar bar : barList) { bytesCopied = fos.getChannel().size(); progressValue = (int) (100 * bytesCopied / totalBytes); bar.setValue(progressValue); if (bar.isStringPainted()) { bar.setString(progressValue + "% " + bytesCopied / 1000 + "/" + totalBytes / 1000 + "Kb tape " + step + "/2"); } } } } catch (IOException e) { e.printStackTrace(); } } }).start(); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); fos.close(); step = 2; for (CustomProgressBar bar : barList) { if (bar.isStringPainted()) { bar.setString("tape " + step + "/2 : Extraction"); } } for (int timeout = 100; timeout > 0; timeout--) { RandomAccessFile ran = null; try { ran = new RandomAccessFile(archive, "rw"); break; } catch (Exception ex) { } finally { if (ran != null) try { ran.close(); } catch (IOException ex) { } ran = null; } try { Thread.sleep(100); } catch (InterruptedException ex) { } } ZipFile zipFile = new ZipFile(archive, Charset.forName("Cp437")); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); File entryDestination = new File(outputFolder, entry.getName()); entryDestination.getParentFile().mkdirs(); if (entry.isDirectory()) entryDestination.mkdirs(); else { InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(entryDestination); IOUtils.copy(in, out); IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); in.close(); out.close(); } } for (CustomProgressBar bar : barList) { bar.setString(""); } zipFile.close(); archive.delete(); } catch (IOException e) { e.printStackTrace(); } } } }).start(); }
From source file:io.github.jeremgamer.preview.actions.Launch.java
private void extractNatives() throws IOException { for (String s : NATIVE_JARS) { File archive = new File(s); ZipFile zipFile = new ZipFile(archive, Charset.forName("Cp437")); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); File entryDestination = new File(VANILLA_NATIVE_DIR.replaceAll("<version>", "1.8.1"), entry.getName());/*from w ww . ja va2 s . c om*/ entryDestination.getParentFile().mkdirs(); if (entry.isDirectory()) entryDestination.mkdirs(); else { InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(entryDestination); IOUtils.copy(in, out); IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); in.close(); out.close(); } } zipFile.close(); } }
From source file:com.alcatel_lucent.nz.wnmsextract.reader.FileUtilities.java
public void decompressZip(File inputZipPath, File zipPath) { int BUFFER = 2048; List<File> zipFiles = new ArrayList<File>(); try {// ww w . j a v a2s.com zipPath.mkdir(); } catch (SecurityException e) { jlog.fatal("Security exception when creating " + zipPath.getName()); } ZipFile zipFile = null; boolean isZip = true; // Open Zip file for reading (should be in temppath) try { zipFile = new ZipFile(inputZipPath, ZipFile.OPEN_READ); } catch (IOException e) { jlog.fatal("IO exception in " + inputZipPath.getName()); } // Create an enumeration of the entries in the zip file Enumeration<? extends ZipEntry> zipFileEntries = zipFile.entries(); if (isZip) { // Process each entry while (zipFileEntries.hasMoreElements()) { // Get a zip file entry ZipEntry entry = zipFileEntries.nextElement(); String currentEntry = entry.getName(); File destFile = null; // destFile should be pointing to temppath\%date%\ try { destFile = new File(zipPath.getAbsolutePath(), currentEntry); destFile = new File(zipPath.getAbsolutePath(), destFile.getName()); } catch (NullPointerException e) { jlog.fatal("File not found" + destFile.getName()); } // If the entry is a .zip add it to the list so that it can be extracted if (currentEntry.endsWith(".zip")) { zipFiles.add(destFile); } try { // Extract file if not a directory if (!entry.isDirectory()) { // Stream the zip entry BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry)); int currentByte; // establish buffer for writing file byte data[] = new byte[BUFFER]; FileOutputStream fos = null; // Write the current file to disk try { fos = new FileOutputStream(destFile); } catch (FileNotFoundException e) { jlog.fatal("File not found " + destFile.getName()); } catch (SecurityException e) { jlog.fatal("Access denied to " + destFile.getName()); } BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER); // read and write until last byte is encountered while ((currentByte = is.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, currentByte); } dest.flush(); dest.close(); is.close(); } } catch (IOException ioe) { jlog.fatal("IO exception in " + zipFile.getName()); } } try { zipFile.close(); } catch (IOException e) { jlog.fatal("IO exception when closing " + zipFile.getName()); } } // Recursively decompress the list of zip files for (File f : zipFiles) { decompressZip(f, zipPath); } return; }
From source file:de.elomagic.maven.http.HTTPMojo.java
/** * @todo Must may be refactored. Only a prototype * @param file// www .j a v a2s . c om * @param destDirectory * @throws MojoExecutionException */ private void unzipToFile(final File file, final File destDirectory) throws Exception { getLog().info("Extracting downloaded file to folder \"" + destDirectory + "\"."); int filesCount = 0; // create the destination directory structure (if needed) destDirectory.mkdirs(); // open archive for reading try (ZipFile zipFile = new ZipFile(file, ZipFile.OPEN_READ)) { // For every zip archive entry do Enumeration<? extends ZipEntry> zipFileEntries = zipFile.entries(); while (zipFileEntries.hasMoreElements()) { ZipEntry entry = zipFileEntries.nextElement(); getLog().debug("Extracting entry: " + entry); //create destination file // TODO Check entry path on path injections File destFile = new File(destDirectory, entry.getName()); //create parent directories if needed File parentDestFile = destFile.getParentFile(); parentDestFile.mkdirs(); if (!entry.isDirectory()) { BufferedInputStream bufIS = new BufferedInputStream(zipFile.getInputStream(entry)); // write the current file to disk Files.copy(bufIS, destFile.toPath(), StandardCopyOption.REPLACE_EXISTING); filesCount++; } } } getLog().info(filesCount + " files extracted."); }
From source file:fr.certu.chouette.gui.command.ImportCommand.java
/** * @param session// w ww .j a va 2s . c o m * @param save * @param savedIds * @param manager * @param importTask * @param format * @param inputFile * @param suffixes * @param values * @param importHolder * @param validationHolder * @throws ChouetteException */ private int importZipEntries(EntityManager session, boolean save, List<Long> savedIds, INeptuneManager<NeptuneIdentifiedObject> manager, ImportTask importTask, String format, String inputFile, List<String> suffixes, List<ParameterValue> values, ReportHolder importHolder, ReportHolder validationHolder) throws ChouetteException { SimpleParameterValue inputFileParam = new SimpleParameterValue("inputFile"); values.add(inputFileParam); ReportHolder zipHolder = new ReportHolder(); if (format.equalsIgnoreCase("neptune")) { SharedImportedData sharedData = new SharedImportedData(); UnsharedImportedData unsharedData = new UnsharedImportedData(); SimpleParameterValue sharedDataParam = new SimpleParameterValue("sharedImportedData"); sharedDataParam.setObjectValue(sharedData); values.add(sharedDataParam); SimpleParameterValue unsharedDataParam = new SimpleParameterValue("unsharedImportedData"); unsharedDataParam.setObjectValue(unsharedData); values.add(unsharedDataParam); } // unzip files , import and save contents ZipFile zip = null; File temp = null; File tempRep = new File(FileUtils.getTempDirectory(), "massImport" + importTask.getId()); if (!tempRep.exists()) tempRep.mkdirs(); File zipFile = new File(inputFile); ReportItem zipReportItem = new ExchangeReportItem(ExchangeReportItem.KEY.ZIP_FILE, Report.STATE.OK, zipFile.getName()); try { Charset encoding = FileTool.getZipCharset(inputFile); if (encoding == null) { ReportItem fileErrorItem = new ExchangeReportItem(ExchangeReportItem.KEY.ZIP_ERROR, Report.STATE.ERROR, "unknown encoding"); zipReportItem.addItem(fileErrorItem); importHolder.getReport().addItem(zipReportItem); saveImportReports(session, importTask, importHolder.getReport(), validationHolder.getReport()); return 1; } zip = new ZipFile(inputFile, encoding); zipHolder.setReport(zipReportItem); for (Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements();) { ZipEntry entry = entries.nextElement(); if (entry.isDirectory()) { File dir = new File(tempRep, entry.getName()); dir.mkdirs(); continue; } if (!FilenameUtils.isExtension(entry.getName().toLowerCase(), suffixes)) { ReportItem fileReportItem = new ExchangeReportItem(ExchangeReportItem.KEY.FILE_IGNORED, Report.STATE.OK, FilenameUtils.getName(entry.getName())); zipReportItem.addItem(fileReportItem); log.info("entry " + entry.getName() + " ignored, unknown extension"); continue; } InputStream stream = null; try { stream = zip.getInputStream(entry); } catch (IOException e) { ReportItem fileReportItem = new ExchangeReportItem(ExchangeReportItem.KEY.FILE_ERROR, Report.STATE.WARNING, FilenameUtils.getName(entry.getName())); zipReportItem.addItem(fileReportItem); log.error("entry " + entry.getName() + " cannot read", e); continue; } byte[] bytes = new byte[4096]; int len = stream.read(bytes); temp = new File(tempRep.getAbsolutePath() + "/" + entry.getName()); FileOutputStream fos = new FileOutputStream(temp); while (len > 0) { fos.write(bytes, 0, len); len = stream.read(bytes); } fos.close(); // import log.info("import file " + entry.getName()); inputFileParam.setFilepathValue(temp.getAbsolutePath()); List<NeptuneIdentifiedObject> beans = manager.doImport(null, format, values, zipHolder, validationHolder); if (beans != null && !beans.isEmpty()) { // save if (save) { saveBeans(manager, beans, savedIds, importHolder.getReport()); } else { for (NeptuneIdentifiedObject bean : beans) { GuiReportItem item = new GuiReportItem(GuiReportItem.KEY.NO_SAVE, Report.STATE.OK, bean.getName()); importHolder.getReport().addItem(item); } } } temp.delete(); } try { zip.close(); } catch (IOException e) { log.info("cannot close zip file"); } importHolder.getReport().addItem(zipReportItem); } catch (IOException e) { log.error("IO error", e); ReportItem fileErrorItem = new ExchangeReportItem(ExchangeReportItem.KEY.ZIP_ERROR, Report.STATE.ERROR, e.getLocalizedMessage()); zipReportItem.addItem(fileErrorItem); importHolder.getReport().addItem(zipReportItem); saveImportReports(session, importTask, importHolder.getReport(), validationHolder.getReport()); return 1; } catch (IllegalArgumentException e) { log.error("Format error", e); ReportItem fileErrorItem = new ExchangeReportItem(ExchangeReportItem.KEY.ZIP_ERROR, Report.STATE.ERROR, e.getLocalizedMessage()); zipReportItem.addItem(fileErrorItem); importHolder.getReport().addItem(zipReportItem); saveImportReports(session, importTask, importHolder.getReport(), validationHolder.getReport()); return 1; } finally { try { FileUtils.deleteDirectory(tempRep); } catch (IOException e) { log.warn("temporary directory " + tempRep.getAbsolutePath() + " could not be deleted"); } } return 0; }