Package org.apache.jena.atlas.web

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


     * @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

     * @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

        }

        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

            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

   
    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

   
    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

        if ( uri.startsWith("ftp://") ) {
            try {
                URL url = new URL(uri) ;
                InputStream in = url.openStream() ;
                ContentType ct = RDFLanguages.guessContentType(uri) ;
                return new TypedInputStream(in, ct) ;
            }
            catch (MalformedURLException ex) {
                throw new RiotException("Bad FTP URL: "+uri, ex) ;
            }
            catch (IOException ex) {
View Full Code Here

           
            if ( StreamManager.logAllLookups  && log.isTraceEnabled() )
                log.trace("Found: "+filenameOrURI) ;
           
            ContentType ct = RDFLanguages.guessContentType(filenameOrURI) ;
            return new TypedInputStream(in, ct, filenameOrURI) ;
        }
        catch (IOException ex)
        {
            log.warn("IO Exception opening zip entry: " + filenameOrURI);
            return null;
View Full Code Here

public class LocatorStdin implements Locator {
    @Override
    public TypedInputStream open(String uri) {
        if ( uri.equals("-") )
            return new TypedInputStream(System.in) ;
        return null ;
    }
View Full Code Here

TOP

Related Classes of org.apache.jena.atlas.web.TypedInputStream

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.