Package org.openjena.atlas.web

Examples of org.openjena.atlas.web.MediaType


    public static void doResponseModel(Model model, HttpServletRequest request, HttpServletResponse response)
        {
            String mimeType = null ;        // Header request type
           
            // TODO Use MediaType throughout.
            MediaType i = ConNeg.chooseContentType(request, DEF.rdfOffer, DEF.acceptRDFXML) ;
            if ( i != null )
                mimeType = i.getContentType() ;
           
            String outputField = ResponseOps.paramOutput(request, shortNamesModel) ;
            if ( outputField != null )
                mimeType = outputField ;
           
View Full Code Here


//        } catch (IOException ex) { errorOccurred(ex) ; return null ; }
//    }

    protected static MediaType contentNegotationRDF(HttpActionREST action)
    {
        MediaType mt = ConNeg.chooseContentType(action.request, DEF.rdfOffer, DEF.acceptRDFXML) ;
        if ( mt == null )
            return null ;
        if ( mt.getContentType() != null )
            action.response.setContentType(mt.getContentType());
        if ( mt.getCharset() != null )
        action.response.setCharacterEncoding(mt.getCharset()) ;
        return mt ;
    }
View Full Code Here

            throw new FusekiException("Both result set and boolean result are set") ;
        }

        // Content negotiation
        String mimeType = null ;
        MediaType i = ConNeg.chooseContentType(request, DEF.rsOffer, DEF.acceptRSXML) ;
        if ( i != null )
            mimeType = i.getContentType() ;
       
        // Override content type
        // Does &output= override?
        // Requested output type by the web form or &output= in the request.
        String outputField = ResponseOps.paramOutput(request, shortNamesResultSet) ;    // Expands short names
View Full Code Here

                log.debug(format("[%d] %s %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                throw new HttpException(statusLine.getStatusCode()+" "+statusLine.getReasonPhrase()) ;
            }

            String contentType = response.getFirstHeader(HttpNames.hContentType).getValue() ;
            MediaType mt = new MediaType(contentType) ;
            String ct = mt.getContentType() ;
            if ( log.isDebugEnabled() )
                log.debug(format("[%d] %d %s :: %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase() , mt)) ;

            HttpResponseHandler handler = handlers.get(ct) ;
            if ( handler == null )
View Full Code Here

                log.debug(format("[%d] %s %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                throw new HttpException(statusLine.getStatusCode()+" "+statusLine.getReasonPhrase()) ;
            }

            String ct = "*" ;
            MediaType mt = null ;
            if ( statusLine.getStatusCode() == 200 )
            {
                String contentType = response.getFirstHeader(HttpNames.hContentType).getValue() ;
                if ( contentType != null )
                {
                    mt = MediaType.create(contentType) ;
                    ct = mt.getContentType() ;
                    if ( log.isDebugEnabled() )
                        log.debug(format("[%d] %d %s :: %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase() , mt)) ;
                }
                else
                {
View Full Code Here

        final public void handle(String contentType, String baseIRI, HttpResponse response)
        {
            try {
                Graph g = GraphFactory.createDefaultGraph() ;
                HttpEntity entity = response.getEntity() ;
                MediaType mt = MediaType.create(response.getFirstHeader(HttpNames.hContentType).getValue()) ;
                mt.getCharset() ;
                Sink<Triple> sink = new SinkTriplesToGraph(g) ;
                InputStream in = entity.getContent() ;
                LangRIOT parser = createParser(in, baseIRI, sink) ;
                parser.parse() ;
                in.close() ;
View Full Code Here

    {   
        ResultSet rs = null ;
        @Override
        public void handle(String contentType, String baseIRI, HttpResponse response) throws IOException
        {
            MediaType mt = MediaType.create(contentType) ;
            ResultsFormat fmt = mapContentTypeToResultSet.get(contentType) ; // contentTypeToResultSet(contentType) ;
            InputStream in = response.getEntity().getContent() ;
            rs = ResultSetFactory.load(in, fmt) ;
            // Force reading
            rs = ResultSetFactory.copyResults(rs) ;
View Full Code Here

        final public void handle(String contentType, String baseIRI, HttpResponse response)
        {
            try {
                Graph g = GraphFactory.createDefaultGraph() ;
                HttpEntity entity = response.getEntity() ;
                MediaType mt = new MediaType(response.getFirstHeader(HttpNames.hContentType).getValue()) ;
                mt.getCharset() ;
                Sink<Triple> sink = new SinkTriplesToGraph(g) ;
                InputStream in = entity.getContent() ;
                LangRIOT parser = createParser(in, baseIRI, sink) ;
                parser.parse() ;
                in.close() ;
View Full Code Here

    {   
        ResultSet rs = null ;
        @Override
        public void handle(String contentType, String baseIRI, HttpResponse response) throws IOException
        {
            MediaType mt = new MediaType(contentType) ;
            ResultsFormat fmt = mapContentTypeToResultSet.get(contentType) ; // contentTypeToResultSet(contentType) ;
            InputStream in = response.getEntity().getContent() ;
            rs = ResultSetFactory.load(in, fmt) ;
            // Force reading
            rs = ResultSetFactory.copyResults(rs) ;
View Full Code Here

                log.debug(format("[%d] %s %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                throw new HttpException(statusLine.getStatusCode()+" "+statusLine.getReasonPhrase()) ;
            }

            String ct = "*" ;
            MediaType mt = null ;
            if ( statusLine.getStatusCode() == 200 )
            {
                String contentType = response.getFirstHeader(HttpNames.hContentType).getValue() ;
                if ( contentType != null )
                {
                    mt = new MediaType(contentType) ;
                    if ( log.isDebugEnabled() )
                        log.debug(format("[%d] %d %s :: %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase() , mt)) ;
                }
                else
                {
View Full Code Here

TOP

Related Classes of org.openjena.atlas.web.MediaType

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.