Examples of TypedInputStream


Examples of org.apache.jena.atlas.web.TypedInputStream

     * @param hintLang  Hint for the syntax
     * @param context   Content object to control reading process.
     */
    public static void parse(StreamRDF sink, InputStream in, String base, Lang hintLang, Context context)
    {
        process(sink, new TypedInputStream(in), base, hintLang, context) ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.web.TypedInputStream

     * @param base      Base URI
     */
    public static void parse(StreamRDF sink, TypedInputStream in, String base)
    {
        Lang hintLang = RDFLanguages.contentTypeToLang(in.getMediaType()) ;
        process(sink, new TypedInputStream(in), base, hintLang, null) ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.web.TypedInputStream

     * @param streamManager
     * @return TypedInputStream
     */
    public static TypedInputStream open(String filenameOrURI, StreamManager streamManager)
    {
        TypedInputStream in = streamManager.open(filenameOrURI) ;
           
        if ( in == null )
        {
            if ( log.isDebugEnabled() )
                //log.debug("Found: "+filenameOrURI+" ("+loc.getName()+")") ;
View Full Code Here

Examples of org.apache.jena.atlas.web.TypedInputStream

        }

        if ( baseURI == null )
            baseURI = chooseBaseURI(filenameOrURI) ;

        TypedInputStream in = streamManager.openNoMapOrNull(mappedURI) ;
        if ( in == null )
        {
            if ( log.isDebugEnabled() )
                log.debug("Failed to locate '"+mappedURI+"'") ;
            throw new NotFoundException("Not found: "+filenameOrURI) ;
        }
        if ( in.getMediaType() != null )
        {
            // XXX
            //syntax
        }
        model.read(in, baseURI, syntax) ;
        try { in.close(); } catch (IOException ex) {}
        return model ;
    }
View Full Code Here

Examples of org.apache.jena.atlas.web.TypedInputStream

            reqEntity.setContentType(WebContent.contentTypeRDFXML) ;
            reqEntity.setContentEncoding(WebContent.charsetUTF8) ;
            HttpEntity entity = reqEntity ;
            ((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ;
        }
        TypedInputStream ts = null ;
        // httpclient.getParams().setXXX
        try {
            HttpResponse response = httpclient.execute(httpRequest) ;

            int responseCode = response.getStatusLine().getStatusCode() ;
            String responseMessage = response.getStatusLine().getReasonPhrase() ;
           
            if ( HttpSC.isRedirection(responseCode) )
                // Not implemented yet.
                throw JenaHttpException.create(responseCode, responseMessage) ;

            // Other 400 and 500 - errors

            if ( HttpSC.isClientError(responseCode) || HttpSC.isServerError(responseCode) )
                throw JenaHttpException.create(responseCode, responseMessage) ;

            if ( responseCode == HttpSC.NO_CONTENT_204) return null ;
            if ( responseCode == HttpSC.CREATED_201 ) return null ;
           
            if ( responseCode != HttpSC.OK_200 )
            {
                Log.warn(this, "Unexpected status code") ;
                throw JenaHttpException.create(responseCode, responseMessage) ;
            }
           
            // May not have a body.
            String ct = getHeader(response, HttpNames.hContentType) ;
            if ( ct == null )
            {
                HttpEntity entity = response.getEntity() ;
               
                if (entity != null)
                {
                    InputStream instream = entity.getContent() ;
                    // Read to completion?
                    instream.close() ;
                }
                return null ;
            }
           
            // Tidy. See ConNeg / MediaType.
            String x = getHeader(response, HttpNames.hContentType) ;
            String y[] = x.split(";") ;
            String contentType = null ;
            if ( y[0] != null )
                contentType = y[0].trim();
            String charset = null ;
            if ( y.length > 1 && y[1] != null )
                charset = y[1].trim();

            // Get hold of the response entity
            HttpEntity entity = response.getEntity() ;

            if (entity != null)
            {
                InputStream instream = entity.getContent() ;
//                String mimeType = ConNeg.chooseContentType(request, rdfOffer, ConNeg.acceptRDFXML).getAcceptType() ;
//                String charset = ConNeg.chooseCharset(request, charsetOffer, ConNeg.charsetUTF8).getAcceptType() ;
                ts = new TypedInputStream(instream, contentType, charset, null) ;
            }
            Graph graph = GraphFactory.createGraphMem() ;
            if ( processBody )
                readGraph(graph, ts, null) ;
            if ( ts != null )
                ts.close() ;
            Graph graph2 = new UnmodifiableGraph(graph) ;
            return graph2 ;
        } catch (IOException ex)
        {
            httpRequest.abort() ;
View Full Code Here

Examples of org.apache.jena.atlas.web.TypedInputStream

   
    private static void open(StreamManager streamMgr, String dataName, Context context)
    {
        StreamManager.setGlobal(streamMgr) ;
        try {
            TypedInputStream in = ( context != null )
                ? RDFDataMgr.open(dataName, context)
                : RDFDataMgr.open(dataName) ;
            assertNotNull(in) ;
            IO.close(in) ;
        } finally {
View Full Code Here

Examples of org.openjena.atlas.web.TypedInputStream

                    msg = "Accept: "+x+" : Not understood" ;
                SPARQL_ServletBase.error(HttpSC.NOT_ACCEPTABLE_406, msg) ;
            }

            // Force to text/plain?
            TypedInputStream ts = new TypedInputStream(null, mimeType, WebContent.charsetUTF8) ;
            String contentType = ts.getMediaType() ;
            String charset =     ts.getCharset() ;
           
            String forceAccept = ResponseOps.paramForceAccept(request) ;
            if ( forceAccept != null )
            {
                contentType = WebContent.contentTypeTextPlain ;
                charset = WebContent.charsetUTF8 ;
            }
           
            Lang lang = FusekiLib.langFromContentType(ts.getMediaType()) ;
            RDFWriter rdfw = FusekiLib.chooseWriter(lang) ;
                
            if ( rdfw instanceof RDFXMLWriterI )
                rdfw.setProperty("showXmlDeclaration", "true") ;
           
View Full Code Here

Examples of org.openjena.atlas.web.TypedInputStream

            reqEntity.setContentType(WebContent.contentTypeRDFXML) ;
            reqEntity.setContentEncoding(HTTP.UTF_8) ;
            HttpEntity entity = reqEntity ;
            ((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity) ;
        }
        TypedInputStream ts = null ;
        // httpclient.getParams().setXXX
        try {
            HttpResponse response = httpclient.execute(httpRequest) ;

            int responseCode = response.getStatusLine().getStatusCode() ;
            String responseMessage = response.getStatusLine().getReasonPhrase() ;
           
            if ( HttpSC.isRedirection(responseCode) )
                // Not implemented yet.
                throw FusekiRequestException.create(responseCode, responseMessage) ;

            // Other 400 and 500 - errors

            if ( HttpSC.isClientError(responseCode) || HttpSC.isServerError(responseCode) )
                throw FusekiRequestException.create(responseCode, responseMessage) ;

            if ( responseCode == HttpSC.NO_CONTENT_204) return null ;
            if ( responseCode == HttpSC.CREATED_201 ) return null ;
           
            if ( responseCode != HttpSC.OK_200 )
            {
                Log.warn(this, "Unexpected status code") ;
                throw FusekiRequestException.create(responseCode, responseMessage) ;
            }
           
            // May not have a body.
            String ct = getHeader(response, HttpNames.hContentType) ;
            if ( ct == null )
            {
                HttpEntity entity = response.getEntity() ;
               
                if (entity != null)
                {
                    InputStream instream = entity.getContent() ;
                    // Read to completion?
                    instream.close() ;
                }
                return null ;
            }
           
            // Tidy. See ConNeg / MediaType.
            String x = getHeader(response, HttpNames.hContentType) ;
            String y[] = x.split(";") ;
            String contentType = null ;
            if ( y[0] != null )
                contentType = y[0].trim();
            String charset = null ;
            if ( y.length > 1 && y[1] != null )
                charset = y[1].trim();

            // Get hold of the response entity
            HttpEntity entity = response.getEntity() ;

            if (entity != null)
            {
                InputStream instream = entity.getContent() ;
//                String mimeType = ConNeg.chooseContentType(request, rdfOffer, ConNeg.acceptRDFXML).getAcceptType() ;
//                String charset = ConNeg.chooseCharset(request, charsetOffer, ConNeg.charsetUTF8).getAcceptType() ;
                ts = new TypedInputStream(instream, contentType, charset) ;
            }
            Graph graph = GraphFactory.createGraphMem() ;
            if ( processBody )
                readGraph(graph, ts, null) ;
            if ( ts != null )
                ts.close() ;
            Graph graph2 = new UnmodifiableGraph(graph) ;
            return graph2 ;
        } catch (IOException ex)
        {
            httpRequest.abort() ;
View Full Code Here

Examples of org.openjena.atlas.web.TypedInputStream

        readGraph(graph, uri, lang) ;
    }
   
    public static void readGraph(Graph graph, String uri, Lang lang)
    {
        TypedInputStream typedInput = open(uri, lang) ;
        String contentType = typedInput.getMediaType() ;
        lang = chooseLang(contentType, lang) ;

        if ( lang == null )
            throw new RiotException("Can't determine the syntax of <"+uri+"> (media type="+typedInput.getMediaType()+")") ;
       
        Sink<Triple> sink = RiotLoader.graphSink(graph) ;
        try {
            RiotLoader.readTriples(typedInput, lang, uri, sink) ;
        } finally { sink.close() ; }
View Full Code Here

Examples of org.openjena.atlas.web.TypedInputStream

        readDataset(dataset, uri, lang) ;
    }
   
    public static void readDataset(DatasetGraph dataset, String uri, Lang lang)
    {
        TypedInputStream typedInput = open(uri, lang) ;
        String contentType = typedInput.getMediaType() ;
        lang = chooseLang(contentType, lang) ;

        if ( lang == null )
            throw new RiotException("Can't determine the syntax of <"+uri+"> (media type="+typedInput.getMediaType()+")") ;
       
        Sink<Quad> sink = RiotLoader.datasetSink(dataset) ;
        try {
            RiotLoader.readQuads(typedInput, lang, uri, sink) ;
        } finally { sink.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.