Package org.apache.jena.atlas.web

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


        HttpServletResponse response = action.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


    }
   
    @Override
    protected void doGet(HttpActionREST action)
    {
        MediaType mediaType = HttpAction.contentNegotationQuads(action) ;
        ServletOutputStream output ;
        try { output = action.response.getOutputStream() ; }
        catch (IOException ex) { errorOccurred(ex) ; output = null ; }
       
        TypedOutputStream out = new TypedOutputStream(output, mediaType) ;
        Lang lang = WebContent.contentTypeToLang(mediaType.getContentType()) ;
        if ( lang == null )
            lang = RDFLanguages.TRIG ;

        if ( action.verbose )
            log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s",
                                  action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;
        if ( ! RDFLanguages.isQuads(lang) )
            errorBadRequest("Not a quads format: "+mediaType) ;
       
        action.beginRead() ;
        try {
View Full Code Here

    @Override
    protected void doHead(HttpActionREST action)
    {
        action.beginRead() ;
        try {
            MediaType mediaType = HttpAction.contentNegotationQuads(action) ;
            success(action) ;
        } finally { action.endRead() ; }
    }
View Full Code Here

        // Not necessarily good code.
        String x = action.request.getContentType() ;
        if ( x == null )
            errorBadRequest("Content-type required for data format") ;
       
        MediaType mediaType = MediaType.create(x) ;
        Lang lang = WebContent.contentTypeToLang(mediaType.getContentType()) ;
        if ( lang == null )
            lang = RDFLanguages.TRIG ;

        if ( action.verbose )
            log.info(format("[%d]   Post: Content-Type=%s, Charset=%s => %s",
                                  action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;
       
        if ( RDFLanguages.isQuads(lang) )
            doPostQuads(action, lang) ;
        else if ( gspMode && RDFLanguages.isTriples(lang) )
            doPostTriplesGSP(action, lang) ;
View Full Code Here

                choice = m ; 
            }
        }
        if ( choice == null )
            return null ;
        return new MediaType(choice);
    }
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() ;
                StreamRDF dest = StreamRDFLib.graph(g) ;
                InputStream in = entity.getContent() ;
                LangRIOT parser = createParser(in, baseIRI, dest) ;
                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

                if ( log.isDebugEnabled() )
                    log.debug(format("[%d] %d %s :: (empty)",id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                return null ;
            }
               
            MediaType mt = MediaType.create(entity.getContentType().getValue()) ;
            if ( log.isDebugEnabled() )
                log.debug(format("[%d] %d %s :: %s",id, statusLine.getStatusCode(), statusLine.getReasonPhrase() , mt)) ;
               
            return new TypedInputStreamHttp(entity.getContent(), mt,
                                       httpclient.getConnectionManager()) ;
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 = null ;
                Header ctHeader = response.getFirstHeader(HttpNames.hContentType) ;
                if (ctHeader == null)
                    log.info(format("[%d] %d %s :: No Content-Type in response", id, statusLine.getStatusCode(), statusLine.getReasonPhrase())) ;
                else
                {
                    contentType = ctHeader.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
                    {
                        if (log.isDebugEnabled()) log.debug(format("[%d] %d %s :: (no content type: header but no value)", id,
View Full Code Here

            xlog.warn("doResponseResult: Both result set and boolean result are set") ;
            throw new FusekiException("Both result set and boolean result are set") ;
        }

        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

TOP

Related Classes of org.apache.jena.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.