Package org.apache.commons.io.input

Examples of org.apache.commons.io.input.CloseShieldInputStream


                        String name = entry.getName();
                        int pos = name.lastIndexOf('/');
                        if ( pos != -1 ) {
                            creator.switchCurrentNode(name.substring(0, pos), NT_FOLDER);
                        }
                        creator.createFileAndResourceNode(name, new CloseShieldInputStream(zis), null, entry.getTime());
                        creator.finishNode();
                        creator.finishNode();
                        if ( pos != -1 ) {
                            creator.finishNode();
                        }
View Full Code Here


                        String name = entry.getName();
                        int pos = name.lastIndexOf('/');
                        if ( pos != -1 ) {
                            creator.switchCurrentNode(name.substring(0, pos), NT_FOLDER);
                        }
                        creator.createFileAndResourceNode(name, new CloseShieldInputStream(zis), null, entry.getTime());
                        creator.finishNode();
                        creator.finishNode();
                        if ( pos != -1 ) {
                            creator.finishNode();
                        }
View Full Code Here

                }
                String path = zipFile.getPath() + ":" + name;
                name = name.substring((Constants.META_DIR + "/").length());
                if (name.equals(Constants.FILTER_XML)) {
                    // load filter
                    inf.loadFilter(new CloseShieldInputStream(zin), path);
                } else if (name.equals(Constants.CONFIG_XML)) {
                    // load config
                    inf.loadConfig(new CloseShieldInputStream(zin), path);
                } else if (name.equals(Constants.SETTINGS_XML)) {
                    // load settings
                    inf.loadSettings(new CloseShieldInputStream(zin), path);
                } else if (name.equals(Constants.PROPERTIES_XML)) {
                    // load properties
                    inf.loadProperties(new CloseShieldInputStream(zin), path);
                } else if (name.equals(Constants.PRIVILEGES_XML)) {
                    // load privileges
                    inf.loadPrivileges(new CloseShieldInputStream(zin), path);
                } else if (name.equals(Constants.PACKAGE_DEFINITION_XML)) {
                    inf.setHasDefinition(true);
                    log.debug("Contains package definition {}.", path);
                } else if (name.endsWith(".cnd")) {
                    try {
                        Reader r = new InputStreamReader(new CloseShieldInputStream(zin), "utf8");
                        CNDReader reader = ServiceProviderFactory.getProvider().getCNDReader();
                        reader.read(r, entry.getName(), null);
                        inf.getNodeTypes().add(reader);
                        log.debug("Loaded nodetypes from {}.", path);
                    } catch (IOException e1) {
View Full Code Here

        in = new PipedInputStream(out, 8192);

        pumpThread = new Thread(new Runnable() {
            public void run() {
                try {
                    pump.run(new CloseShieldInputStream(in));
                    // ensure that input stream is pumping in case it didn't read to the end
                    byte[] buffer = new byte[8192];
                    while (in.read(buffer) >= 0);
                } catch (Exception e) {
                    error = e;
View Full Code Here

        FilterInputStreamCache cache = null;

        try {
           
            //first, get the content of the request
            is = new CloseShieldInputStream(request.getInputStream());

            if(is.available() <= 0) {
                return null;
            }
           
View Full Code Here

        try {
            //try and construct xml document from input stream, we use eXist's in-memory DOM implementation

            //we have to use CloseShieldInputStream otherwise the parser closes the stream and we cant later reread
            final InputSource src = new InputSource(new CloseShieldInputStream(is));

            reader = getBrokerPool().getParserPool().borrowXMLReader();
            final MemTreeBuilder builder = new MemTreeBuilder();
            builder.startDocument();
            final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder, true);
View Full Code Here

                }

                //try and parse the response as XML
                try {
                    //we have to use CloseShieldInputStream otherwise the parser closes the stream and we cant later reread
                    final InputStream shieldedInputStream = new CloseShieldInputStream(cfis);
                    responseNode = (NodeImpl)ModuleUtils.streamToXML(context, shieldedInputStream);
                    builder.addAttribute(new QName("type", null, null ), "xml");
                    responseNode.copyTo(null, new DocumentBuilderReceiver(builder));
                } catch(final SAXException se) {
                    // could not parse to xml
                    // not an error in itself, it will be treated either as HTML,
                    // text or binary here below
                    final String msg = "Request for URI '"
                        + method.getURI().toString()
                        + "' Could not parse http response content as XML (will try html, text or fallback to binary): "
                        + se.getMessage();
                    if(logger.isDebugEnabled()) {
                        logger.debug(msg, se);
                    } else {
                        logger.info(msg);
                    }
                } catch(final IOException ioe) {
                    final String msg = "Request for URI '" + method.getURI().toString() + "' Could not read http response content: " + ioe.getMessage();
                    logger.error(msg, ioe);
                    throw new XPathException(msg, ioe);
                }

                if(responseNode == null) {
                    //response is NOT parseable as XML

                    //is it a html document?
                    if(responseMimeType.getName().equals(MimeType.HTML_TYPE.getName())) {

                        //html document
                        try {

                            //reset the stream to the start, as we need to reuse since attempting to parse to XML
                            cfis.reset();

                            //parse html to xml(html)
                           
                            //we have to use CloseShieldInputStream otherwise the parser closes the stream and we cant later reread
                            final InputStream shieldedInputStream = new CloseShieldInputStream(cfis);
                           
                            responseNode = (NodeImpl)ModuleUtils.htmlToXHtml(context, method.getURI().toString(), new InputSource(shieldedInputStream), parserFeatures, parserProperties).getDocumentElement();
                            builder.addAttribute(new QName("type", null, null), "xhtml" );
                            responseNode.copyTo(null, new DocumentBuilderReceiver(builder));
                        } catch(final URIException ue) {
View Full Code Here

        context.pushDocumentContext();
        try {
            //try and construct xml document from input stream, we use eXist's in-memory DOM implementation

            //we have to use CloseShieldInputStream otherwise the parser closes the stream and we cant later reread
            final InputSource src = new InputSource(new CloseShieldInputStream(is));

            reader = context.getBroker().getBrokerPool().getParserPool().borrowXMLReader();
            final MemTreeBuilder builder = context.getDocumentBuilder();
            final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder, true);
            reader.setContentHandler(receiver);
View Full Code Here

        protectedInputSource.setSystemId(source.getSystemId());
        protectedInputSource.setPublicId(source.getPublicId());
       
        if(source.getByteStream() != null) {
            //TODO consider AutoCloseInputStream
            final InputStream closeShieldByteStream = new CloseShieldInputStream(source.getByteStream());
            protectedInputSource.setByteStream(closeShieldByteStream);
        }
       
        if(source.getCharacterStream() != null) {
            //TODO consider AutoCloseReader
View Full Code Here

        try {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setNamespaceAware(true);
            SAXParser parser = factory.newSAXParser();
            parser.parse(
                    new CloseShieldInputStream(stream),
                    getDefaultHandler(handler, metadata));
        } catch (ParserConfigurationException e) {
            throw new TikaException("XML parser configuration error", e);
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.io.input.CloseShieldInputStream

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.