Examples of ArchiveInputStream


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

     */
    protected void fillMapsFromArchive(Resource src, String encoding,
                                       Map fileEntries, Map matchFileEntries,
                                       Map dirEntries, Map matchDirEntries) {
        ArchiveEntry entry = null;
        ArchiveInputStream ai = null;

        try {
            try {
                ai = StreamHelper.getInputStream(factory, src, encoding);
                if (ai == null) {
                    ai =
                        factory.getArchiveStream(new BufferedInputStream(src
                                                                         .getInputStream()),
                                                 encoding);
                }
            } catch (IOException ex) {
                throw new BuildException("problem opening " + src, ex);
            }
            while ((entry = ai.getNextEntry()) != null) {
                if (skipUnreadable && !ai.canReadEntryData(entry)) {
                    log(Messages.skippedIsUnreadable(entry));
                    continue;
                }
                Resource r = builder.buildResource(src, encoding, entry);
                String name = entry.getName();
View Full Code Here

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

        return supportedTypes;
    }

    public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {
        ArchiveInputStream zip = new ZipArchiveInputStream(stream);
        ArchiveEntry entry = zip.getNextEntry();
        Parser parser = context.get(Parser.class, EmptyParser.INSTANCE);
        while (entry != null) {
            if (!relevantFileNames.contains(entry.getName())) {
                entry = zip.getNextEntry();
                continue;
            }

            parser.parse(new CloseShieldInputStream(zip), handler, metadata, context);
            entry = zip.getNextEntry();
        }
        zip.close();
    }
View Full Code Here

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

        stream = new CloseShieldInputStream(stream);

        // 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);
        if (!type.equals(MediaType.OCTET_STREAM)) {
            metadata.set(CONTENT_TYPE, type.toString());
        }

        // Use the delegate parser to parse the contained document
        EmbeddedDocumentExtractor extractor = context.get(
                EmbeddedDocumentExtractor.class,
                new ParsingEmbeddedDocumentExtractor(context));

        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
        xhtml.startDocument();

        try {
            ArchiveEntry entry = ais.getNextEntry();
            while (entry != null) {
                if (!entry.isDirectory()) {
                    parseEntry(ais, entry, extractor, xhtml);
                }
                entry = ais.getNextEntry();
            }
        } finally {
            ais.close();
        }

        xhtml.endDocument();
    }
View Full Code Here

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

    }

    private static MediaType detectArchiveFormat(byte[] prefix, int length) {
        try {
            ArchiveStreamFactory factory = new ArchiveStreamFactory();
            ArchiveInputStream ais = factory.createArchiveInputStream(
                    new ByteArrayInputStream(prefix, 0, length));
            try {
                if ((ais instanceof TarArchiveInputStream)
                        && !TarArchiveInputStream.matches(prefix, length)) {
                    // ArchiveStreamFactory is too relaxed, see COMPRESS-117
View Full Code Here

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

        }
    }

    private void expandStream(String name, InputStream stream, File dir)
        throws IOException {
        ArchiveInputStream is = null;
        try {
            FileNameMapper mapper = getMapper();
            log("Expanding: " + name + " into " + dir, Project.MSG_INFO);
            is = factory.getArchiveStream(new BufferedInputStream(stream),
                                          getEncoding());
            boolean empty = true;
            ArchiveEntry ent = null;
            while ((ent = is.getNextEntry()) != null) {
                empty = false;
                log("extracting " + ent.getName(), Project.MSG_DEBUG);
                extractFile(FileUtils.getFileUtils(), null, dir, is,
                            ent.getName(), ent.getLastModifiedDate(),
                            ent.isDirectory(), mapper);
View Full Code Here

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

    public InputStream getInputStream() throws IOException {
        if (isReference()) {
            return ((Resource) getCheckedRef()).getInputStream();
        }
        Resource archive = getArchive();
        final ArchiveInputStream i =
            factory.getArchiveStream(new BufferedInputStream(archive.getInputStream()),
                                     getEncoding());
        ArchiveEntry ae = null;
        while ((ae = i.getNextEntry()) != null) {
            if (ae.getName().equals(getName())) {
                return i;
            }
        }
View Full Code Here

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

    /**
     * fetches information from the named entry inside the archive.
     */
    protected void fetchEntry() {
        Resource archive = getArchive();
        ArchiveInputStream i = null;
        try {
            i = factory.getArchiveStream(archive.getInputStream(),
                                         getEncoding());
            ArchiveEntry ae = null;
            while ((ae = i.getNextEntry()) != null) {
                if (ae.getName().equals(getName())) {
                    setEntry(ae);
                    return;
                }
            }
View Full Code Here

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

     */
    protected void fillMapsFromArchive(Resource src, String encoding,
                                       Map fileEntries, Map matchFileEntries,
                                       Map dirEntries, Map matchDirEntries) {
        ArchiveEntry entry = null;
        ArchiveInputStream ai = null;

        try {
            try {
                ai =
                    factory.getArchiveStream(new BufferedInputStream(src
                                                                     .getInputStream()),
                                             encoding);
            } catch (IOException ex) {
                throw new BuildException("problem opening " + src, ex);
            }
            while ((entry = ai.getNextEntry()) != null) {
                Resource r = builder.buildResource(src, encoding, entry);
                String name = entry.getName();
                if (entry.isDirectory()) {
                    name = trimSeparator(name);
                    dirEntries.put(name, r);
View Full Code Here

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

    protected void checkArchiveContent(File archive, List<String> expected)
            throws Exception {
        final InputStream is = new FileInputStream(archive);
        try {
            final BufferedInputStream buf = new BufferedInputStream(is);
            final ArchiveInputStream in = factory.createArchiveInputStream(buf);
            this.checkArchiveContent(in, expected);
        } finally {
            is.close();
        }
    }
View Full Code Here

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

    protected void checkArchiveContent(File archive, List<String> expected)
            throws Exception {
        final InputStream is = new FileInputStream(archive);
        try {
            final BufferedInputStream buf = new BufferedInputStream(is);
            final ArchiveInputStream in = factory.createArchiveInputStream(buf);
            this.checkArchiveContent(in, expected);
        } finally {
            is.close();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.