List of usage examples for org.apache.commons.compress.archivers ArchiveException getMessage
public String getMessage()
From source file:ezbake.deployer.utilities.Utilities.java
public static void appendFilesInTarArchive(OutputStream output, Iterable<ArtifactDataEntry> filesToAdd) throws DeploymentException { ArchiveStreamFactory asf = new ArchiveStreamFactory(); try (GZIPOutputStream gzs = new GZIPOutputStream(output)) { try (ArchiveOutputStream aos = asf.createArchiveOutputStream(ArchiveStreamFactory.TAR, gzs)) { for (ArtifactDataEntry entry : filesToAdd) { aos.putArchiveEntry(entry.getEntry()); IOUtils.write(entry.getData(), aos); aos.closeArchiveEntry(); }//from w w w .j av a2 s . co m } } catch (ArchiveException e) { log.error(e.getMessage(), e); throw new DeploymentException(e.getMessage()); } catch (IOException e) { log.error(e.getMessage(), e); throw new DeploymentException(e.getMessage()); } }
From source file:ezbake.deployer.utilities.Utilities.java
public static void appendFilesInTarArchive(OutputStream output, byte[] currentArchive, Iterable<ArtifactDataEntry> filesToAdd) throws DeploymentException { ArchiveStreamFactory asf = new ArchiveStreamFactory(); try (GZIPOutputStream gzs = new GZIPOutputStream(output)) { try (ArchiveOutputStream aos = asf.createArchiveOutputStream(ArchiveStreamFactory.TAR, gzs)) { try (GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream(currentArchive))) { try (TarArchiveInputStream tarInputStream = new TarArchiveInputStream(gzip)) { TarArchiveEntry tarEntry = null; while ((tarEntry = tarInputStream.getNextTarEntry()) != null) { aos.putArchiveEntry(tarEntry); IOUtils.copy(tarInputStream, aos); aos.closeArchiveEntry(); }/* w w w. j av a2 s . c om*/ } } for (ArtifactDataEntry entry : filesToAdd) { aos.putArchiveEntry(entry.getEntry()); IOUtils.write(entry.getData(), aos); aos.closeArchiveEntry(); } } } catch (ArchiveException e) { log.error(e.getMessage(), e); throw new DeploymentException(e.getMessage()); } catch (IOException e) { log.error(e.getMessage(), e); throw new DeploymentException(e.getMessage()); } }
From source file:io.github.retz.executor.FileManager.java
static void fetchPersistentFiles(List<String> files, String destination, boolean trustPVFiles) throws IOException { for (String file : files) { java.nio.file.Path path = Paths.get(file).getFileName(); if (path == null) { throw new FileSystemException(destination); }// w w w . j a va 2s . c om File f = new File(FilenameUtils.concat(destination, path.toString())); LOG.info("Downloading: {} as {}", file, f); if (f.exists()) { LOG.debug("File already exists: {}", f); if (!trustPVFiles) { try { boolean needsDecompression = needsDecompression(f, destination); if (needsDecompression) { decompress(f, destination); } else { LOG.info("File {} was correctly decompressed before. Skipping decompression.", file); } } catch (ArchiveException e) { LOG.error("ArchiveException on {}: {}", f, e.getMessage()); e.printStackTrace(); } } } else if (file.startsWith("http")) { fetchHTTPFile(file, destination); decompress(f, destination); } else if (file.startsWith("hdfs://")) { fetchHDFSFile(file, destination); decompress(f, destination); } else if (file.startsWith("maprfs://")) { fetchHDFSFile(file, destination); decompress(f, destination); } else { LOG.error("Invalid URL scheme: {}", file); } } }
From source file:ezbake.deployer.cli.commands.SSLCertsCommand.java
@Override public void call() throws IOException, TException { String[] args = globalParameters.unparsedArgs; minExpectedArgs(2, args, this); String securityId = args[0];//ww w . ja v a 2 s . c om String filePath = args[1]; List<ArtifactDataEntry> certs = new ArrayList<>(); EzSecurityRegistration.Client client = null; ThriftClientPool pool = poolSupplier.get(); try { client = pool.getClient(EzSecurityRegistrationConstants.SERVICE_NAME, EzSecurityRegistration.Client.class); AppCerts s = client.getAppCerts( getSecurityToken(pool.getSecurityId(EzSecurityRegistrationConstants.SERVICE_NAME)), securityId); for (AppCerts._Fields fields : AppCerts._Fields.values()) { Object o = s.getFieldValue(fields); if (o instanceof byte[]) { String fieldName = fields.getFieldName().replace("_", "."); TarArchiveEntry tae = new TarArchiveEntry( new File(new File(SSL_CONFIG_DIRECTORY, securityId), fieldName)); certs.add(new ArtifactDataEntry(tae, (byte[]) o)); } } ArchiveStreamFactory asf = new ArchiveStreamFactory(); FileOutputStream fos = new FileOutputStream(filePath); GZIPOutputStream gzs = new GZIPOutputStream(fos); try (TarArchiveOutputStream aos = (TarArchiveOutputStream) asf .createArchiveOutputStream(ArchiveStreamFactory.TAR, gzs)) { aos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); for (ArtifactDataEntry entry : certs) { aos.putArchiveEntry(entry.getEntry()); IOUtils.write(entry.getData(), aos); aos.closeArchiveEntry(); } aos.finish(); gzs.finish(); } catch (ArchiveException ex) { throw new DeploymentException(ex.getMessage()); } finally { IOUtils.closeQuietly(fos); } } finally { pool.returnToPool(client); } }
From source file:org.apache.camel.dataformat.tarfile.TarIterator.java
public TarIterator(Message inputMessage, InputStream inputStream) { this.inputMessage = inputMessage; //InputStream inputStream = inputMessage.getBody(InputStream.class); if (inputStream instanceof TarArchiveInputStream) { tarInputStream = (TarArchiveInputStream) inputStream; } else {/*from w w w .j av a 2 s .c o m*/ try { ArchiveInputStream input = new ArchiveStreamFactory() .createArchiveInputStream(ArchiveStreamFactory.TAR, new BufferedInputStream(inputStream)); tarInputStream = (TarArchiveInputStream) input; } catch (ArchiveException e) { throw new RuntimeException(e.getMessage(), e); } } parent = null; }