Package org.apache.jena.atlas.web

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


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

            log.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

    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

        boolean isForm                  = WebContent.contentTypeForm.equalsIgnoreCase(request.getContentType()) ;

        String ct = request.getContentType() ;
        String charset = request.getCharacterEncoding() ;
       
        MediaType mt = null ;
        if ( ct != null )
            mt = MediaType.create(ct, charset) ;
       
        DatasetRef desc = DatasetRegistry.get().get(dsname) ;
        // The servlets create their own, subclass, action, but it's
View Full Code Here

   
   
    protected static MediaType contentNegotationQuads(HttpAction action)
    {
        MediaType mt = ConNeg.chooseContentType(action.request, DEF.quadsOffer, DEF.acceptNQuads) ;
        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

                choice = m ; 
            }
        }
        if ( choice == null )
            return null ;
        return new MediaType(choice);
    }
View Full Code Here

    }
    public static String mapLangToContentType(Lang lang) { return mapLangToContentType.get(lang) ; }
   
    public static String getCharsetForContentType(String contentType)
    {
        MediaType ct = MediaType.create(contentType) ;
        if ( ct.getCharset() != null )
            return ct.getCharset() ;
       
        String mt = ct.getContentType() ;
        if ( contentTypeNTriples.equals(mt) )       return charsetUTF8 ;
        if ( contentTypeNTriplesAlt.equals(mt) )    return charsetASCII ;
        if ( contentTypeNQuads.equals(mt) )         return charsetUTF8 ;
        if ( contentTypeNQuadsAlt1.equals(mt) )      return charsetASCII ;
        if ( contentTypeNQuadsAlt2.equals(mt) )      return charsetASCII ;
View Full Code Here

    /** Match a single media type against a header string */
    public static String match(String headerString, String mediaRangeStr)
    {
        AcceptList l = new AcceptList(headerString) ;
        MediaRange aItem = new MediaRange(mediaRangeStr) // MediaType
        MediaType m = l.match(aItem) ;
        if ( m == null )
            return null ;
        return m.toHeaderString() ;
    }
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.