protected BusinessArchive readBusinessArchive(final File barOrFolder, List<BusinessArchiveContribution> contributions) throws InvalidBusinessArchiveFormatException, IOException { if (!barOrFolder.exists()) { throw new FileNotFoundException("the file does not exists: " + barOrFolder.getAbsolutePath()); } if (barOrFolder.isDirectory()) { return getBusinessArchive(barOrFolder, contributions); } try (FileInputStream inputStream = new FileInputStream(barOrFolder)) { return readBusinessArchive(inputStream); } }
protected BusinessArchive readBusinessArchive(final File barOrFolder, List<BusinessArchiveContribution> contributions) throws InvalidBusinessArchiveFormatException, IOException { if (!barOrFolder.exists()) { throw new FileNotFoundException("the file does not exists: " + barOrFolder.getAbsolutePath()); } if (barOrFolder.isDirectory()) { return getBusinessArchive(barOrFolder, contributions); } try (FileInputStream inputStream = new FileInputStream(barOrFolder)) { return readBusinessArchive(inputStream); } }
protected BusinessArchive readBusinessArchive(final InputStream inputStream, List<BusinessArchiveContribution> contributions) throws IOException, InvalidBusinessArchiveFormatException { File barFolder = File.createTempFile("tempBarFolder", null); barFolder.delete(); barFolder.mkdir(); try { IOUtil.unzipToFolder(inputStream, barFolder); return getBusinessArchive(barFolder, contributions); } catch (final InvalidBusinessArchiveFormatException e) { throw e; } catch (final Exception e) { throw new InvalidBusinessArchiveFormatException("Invalid format, can't read the BAR file", e); } finally { IOUtil.deleteDir(barFolder); } }
protected BusinessArchive readBusinessArchive(final InputStream inputStream, List<BusinessArchiveContribution> contributions) throws IOException, InvalidBusinessArchiveFormatException { File barFolder = File.createTempFile("tempBarFolder", null); barFolder.delete(); barFolder.mkdir(); try { IOUtil.unzipToFolder(inputStream, barFolder); return getBusinessArchive(barFolder, contributions); } catch (final InvalidBusinessArchiveFormatException e) { throw e; } catch (final Exception e) { throw new InvalidBusinessArchiveFormatException("Invalid format, can't read the BAR file", e); } finally { IOUtil.deleteDir(barFolder); } }