Package org.apache.jena.atlas.web

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


        {
            executeWithParameter(action) ;
            return ;
        }

        MediaType ct = FusekiLib.contentType(request) ;
        String incoming = ct.getContentType() ;
       
        // POST application/sparql-query
        if (WebContent.contentTypeSPARQLQuery.equals(incoming))
        {
            executeBody(action) ;
View Full Code Here


    protected abstract void validateRequest(HttpServletRequest request) ;
   
    /** Helper for validating request */
    protected void validate(HttpServletRequest request, Collection<String> params)
    {
        MediaType ct = FusekiLib.contentType(request) ;
        boolean mustHaveQueryParam = true ;
        if ( ct != null )
        {
            String incoming = ct.getContentType() ;
           
            if ( WebContent.contentTypeSPARQLQuery.equals(incoming) )
            {
                mustHaveQueryParam = false ;
                //error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Unofficial "+WebContent.contentTypeSPARQLQuery+" not supported") ;
View Full Code Here

        HttpActionUpdate action = new HttpActionUpdate(id, desc, request, response, verbose_debug) ;
       
        // WebContent needs to migrate to using ContentType.
        String ctStr ;
        {
            MediaType incoming = FusekiLib.contentType(request) ;
            if ( incoming == null )
                ctStr = WebContent.contentTypeSPARQLUpdate ;
            else
                ctStr = incoming.getContentType() ;
        }

        if (WebContent.contentTypeSPARQLUpdate.equals(ctStr))
        {
            executeBody(action) ;
View Full Code Here

        if ( ! HttpNames.METHOD_POST.equals(request.getMethod().toUpperCase()) )
            errorMethodNotAllowed("SPARQL Update : use POST") ;
       
        String ctStr ;
        {
            MediaType incoming = FusekiLib.contentType(request) ;
            if ( incoming == null )
                ctStr = WebContent.contentTypeSPARQLUpdate ;
            else
                ctStr = incoming.getContentType() ;
        }
        // ----
       
        if ( WebContent.contentTypeSPARQLUpdate.equals(ctStr) )
        {
View Full Code Here

        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

        return mapContentTypeToLang.get(key) ;
    }

    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

    }
   
    @Override
    protected void doGet(HttpAction 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 = RDFLanguages.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(HttpAction 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 = RDFLanguages.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

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.