Package org.apache.jena.atlas.web

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


        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


    }
    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

        SystemARQ.sync(dsg) ;
    }
   
    public static MediaType contentNegotationRDF(HttpAction 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

        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.equalsIgnoreCase(request.getMethod()) )
            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

    @Override
    protected void doGet(HttpActionREST action)
    {
        // Assume success - do the set up before grabbing the lock.
        // Sets content type.
        MediaType mediaType = HttpAction.contentNegotationRDF(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 ( action.verbose )
            log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s",
                                  action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;

        action.beginRead() ;
        try {
            if ( log.isDebugEnabled() )
                log.debug("GET->"+action.getTarget()) ;
View Full Code Here

            if ( ! action.getTarget().exists() )
            {
                successNotFound(action) ;
                return ;
            }
            MediaType mediaType = HttpAction.contentNegotationRDF(action) ;
            success(action) ;
        } finally { action.endRead() ; }
    }
View Full Code Here

        {
            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

            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.