Package org.apache.commons.compress.archivers

Examples of org.apache.commons.compress.archivers.ArchiveStreamFactory


    try {
      Files.deleteIfExists(warExecFile);
      Files.createDirectories(warExecFile.getParent());

      try (OutputStream os = Files.newOutputStream(warExecFile);
          ArchiveOutputStream aos = new ArchiveStreamFactory().createArchiveOutputStream(
              ArchiveStreamFactory.JAR, os)) {

        // If project is a war project add the war to the project
        if ("war".equalsIgnoreCase(project.getPackaging())) {
          File projectArtifact = project.getArtifact().getFile();
View Full Code Here


     *         <code>ldPathProgram</code>
     * @throws LDPathException
     */
    public ArchiveInputStream createSchemaArchive(String coreName, String ldPathProgram) throws LDPathException {
        ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
        ArchiveStreamFactory asf = new ArchiveStreamFactory();
        TarArchiveOutputStream tarOutputStream = null;
        try {
            tarOutputStream = (TarArchiveOutputStream) asf.createArchiveOutputStream("tar", out);
        } catch (ArchiveException e) {
            String msg = "Cannot create an empty tar archive";
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        }

        try {
            InputStream is = getSolrTemplateStream();
            ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
            ZipArchiveEntry ze = null;
            byte[] schemaFile = null;
            while ((ze = zis.getNextZipEntry()) != null) {
                if (SOLR_TEMPLATE_SCHEMA.equals(ze.getName())) {
                    schemaFile = createSchemaXML(getLDPathProgram(ldPathProgram), IOUtils.toByteArray(zis));
                    TarArchiveEntry te = new TarArchiveEntry(coreName + SOLR_SCHEMA);
                    te.setSize(schemaFile.length);
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(schemaFile);
                    tarOutputStream.closeArchiveEntry();
                } else {
                    TarArchiveEntry te = new TarArchiveEntry(ze.getName().replaceAll(SOLR_TEMPLATE_NAME,
                        coreName));
                    te.setSize(ze.getSize());
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(IOUtils.toByteArray(zis));
                    tarOutputStream.closeArchiveEntry();
                }

            }
            if (schemaFile == null) {
                throw new LDPathException("Schema template ZIP should include: " + SOLR_TEMPLATE_SCHEMA);
            }
            tarOutputStream.finish();
            tarOutputStream.close();
        } catch (IOException e) {
            logger.error("", e);
            throw new LDPathException(e);
        }

        ArchiveInputStream ret;
        try {
            ret = asf.createArchiveInputStream(new ByteArrayInputStream(out.toByteArray()));
        } catch (ArchiveException e) {
            String msg = "Cannot create a final tar archive while creating an ArchiveInputStream to create a Solr core";
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        }
View Full Code Here

     *         <code>ldPathProgram</code>
     * @throws LDPathException
     */
    public ArchiveInputStream createSchemaArchive(String coreName, String ldPathProgram) throws LDPathException {
        ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
        ArchiveStreamFactory asf = new ArchiveStreamFactory();
        TarArchiveOutputStream tarOutputStream = null;
        try {
            tarOutputStream = (TarArchiveOutputStream) asf.createArchiveOutputStream("tar", out);
        } catch (ArchiveException e) {
            String msg = "Cannot create an empty tar archive";
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        }

        try {
            InputStream is = getSolrTemplateStream();
            ZipArchiveInputStream zis = new ZipArchiveInputStream(is);
            ZipArchiveEntry ze = null;
            byte[] schemaFile = null;
            while ((ze = zis.getNextZipEntry()) != null) {
                if (SOLR_TEMPLATE_SCHEMA.equals(ze.getName())) {
                    schemaFile = createSchemaXML(getLDPathProgram(ldPathProgram), IOUtils.toByteArray(zis));
                    TarArchiveEntry te = new TarArchiveEntry(coreName + SOLR_SCHEMA);
                    te.setSize(schemaFile.length);
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(schemaFile);
                    tarOutputStream.closeArchiveEntry();
                } else {
                    TarArchiveEntry te = new TarArchiveEntry(ze.getName().replaceAll(SOLR_TEMPLATE_NAME,
                        coreName));
                    te.setSize(ze.getSize());
                    tarOutputStream.putArchiveEntry(te);
                    tarOutputStream.write(IOUtils.toByteArray(zis));
                    tarOutputStream.closeArchiveEntry();
                }

            }
            if (schemaFile == null) {
                throw new LDPathException("Schema template ZIP should include: " + SOLR_TEMPLATE_SCHEMA);
            }
            tarOutputStream.finish();
            tarOutputStream.close();
        } catch (IOException e) {
            logger.error("", e);
            throw new LDPathException(e);
        }

        ArchiveInputStream ret;
        try {
            ret = asf.createArchiveInputStream(new ByteArrayInputStream(out.toByteArray()));
        } catch (ArchiveException e) {
            String msg = "Cannot create a final tar archive while creating an ArchiveInputStream to create a Solr core";
            logger.error(msg, e);
            throw new LDPathException(msg, e);
        }
View Full Code Here

        for (ReadableArFile readableArFile : arReader) {
            if ("control.tar.gz".equals(readableArFile.getName())) {

                ArchiveInputStream input = null;
                try {
                    input = new ArchiveStreamFactory()
                            .createArchiveInputStream(new BufferedInputStream(new GzipCompressorInputStream(readableArFile.open())));
                } catch (ArchiveException e) {
                    throw new IOException(e);
                }
                ArchiveEntry ae;
View Full Code Here

        if (verbose) {
            getLog().info("Unpacking sphinx to " + sphinxSourceDirectory.getAbsolutePath());
        }
        try {
            ArchiveInputStream input = new ArchiveStreamFactory().createArchiveInputStream("jar", SphinxMojo.class.getResourceAsStream("/sphinx.jar"));
            ArchiveEntry entry = input.getNextEntry();
   
            while (entry != null) {
                File archiveEntry = new File(sphinxSourceDirectory, entry.getName());
                archiveEntry.getParentFile().mkdirs();
View Full Code Here

            if(inputArchive.getName().endsWith(".tbz2")) {
                archiveInputStream = new TarArchiveInputStream(
                        new BZip2CompressorInputStream(inputStream));
            } else {
                archiveInputStream = new ArchiveStreamFactory().createArchiveInputStream(
                        new BufferedInputStream(inputStream));
            }

            final ProgressBar progressBar = new ProgressBar(inputFileSize);
            while ((entry = archiveInputStream.getNextEntry()) != null) {
View Full Code Here

    final List<File> untaredFiles = new LinkedList<File>();
    InputStream is = null;
    TarArchiveInputStream debInputStream = null;
    try {
      is = new FileInputStream(inFile);
      debInputStream = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", is);
      TarArchiveEntry entry;
      while ((entry = (TarArchiveEntry) debInputStream.getNextEntry()) != null) {
        final File outputFile = new File(outputDir, entry.getName());
        if (entry.isDirectory()) {
          if (!outputFile.exists()) {
View Full Code Here

                    }
                } else {
                    in = fin;
                }

                ArchiveInputStream zipStream = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(in));
                logArchiveType(zipStream);

                ArchiveEntry entry;
                while( (entry = zipStream.getNextEntry()) != null) {
View Full Code Here

        // Ensure that the stream supports the mark feature
        stream = new BufferedInputStream(stream);

        ArchiveInputStream ais;
        try {
            ArchiveStreamFactory factory = new ArchiveStreamFactory();
            ais = factory.createArchiveInputStream(stream);
        } catch (ArchiveException e) {
            throw new TikaException("Unable to unpack document stream", e);
        }

        MediaType type = getMediaType(ais);
View Full Code Here

        final InputStream is = useFile
            ? new Pack200CompressorInputStream(input, mode)
            : new Pack200CompressorInputStream(new FileInputStream(input),
                                               mode);
        try {
            final ArchiveInputStream in = new ArchiveStreamFactory()
                .createArchiveInputStream("jar", is);

            ArchiveEntry entry = in.getNextEntry();
            while (entry != null) {
                File archiveEntry = new File(dir, entry.getName());
View Full Code Here

TOP

Related Classes of org.apache.commons.compress.archivers.ArchiveStreamFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.