Package org.apache.jena.atlas.web

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


        } finally { action.endWrite() ; }
    }
   
    private static void incomingData(HttpAction action, StreamRDF dest) {
        String base = wholeRequestURL(action.request) ;
        ContentType ct = FusekiLib.getContentType(action) ;
        Lang lang = RDFLanguages.contentTypeToLang(ct.getContentType()) ;
        if ( lang == null ) {
            errorBadRequest("Unknown content type for triples: " + ct) ;
            return ;
        }
        InputStream input = null ;
        try { input = action.request.getInputStream() ; }
        catch (IOException ex) { IO.exception(ex) ; }
   
        int len = action.request.getContentLength() ;
        if ( action.verbose ) {
            if ( len >= 0 )
                log.info(format("[%d]   Body: Content-Length=%d, Content-Type=%s, Charset=%s => %s", action.id, len,
                                ct.getContentType(), ct.getCharset(), lang.getName())) ;
            else
                log.info(format("[%d]   Body: Content-Type=%s, Charset=%s => %s", action.id, ct.getContentType(),
                                ct.getCharset(), lang.getName())) ;
        }
   
        parse(action, dest, input, lang, base) ;
    }
View Full Code Here


       
    @Test public void syntaxDetermination()
    { test(url, contentType, hintLang, expected) ; }
   
    static void test(String url, String ct, Lang hint, Lang expected) {
        ContentType x = RDFDataMgr.determineCT(url, ct, hint) ;
        Lang lang = RDFDataMgr.determineLang(url, ct, hint) ;
        assertEquals(expected, lang) ;
    }
View Full Code Here

        {
            executeWithParameter(action) ;
            return ;
        }

        ContentType ct = FusekiLib.getContentType(action) ;
        String incoming = ct.getContentType() ;

        // POST application/sparql-query
        if (WebContent.contentTypeSPARQLQuery.equals(incoming))
        {
            executeBody(action) ;
View Full Code Here

    protected abstract void validateRequest(HttpAction action) ;
   
    /** Helper for validating request */
    protected void validateParams(HttpServletRequest request, Collection<String> params)
    {
        ContentType ct = FusekiLib.getContentType(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

    public TypedInputStream performOpen(String uri) {
        if ( uri.startsWith("ftp://") ) {
            try {
                URL url = new URL(uri) ;
                InputStream in = url.openStream() ;
                ContentType ct = RDFLanguages.guessContentType(uri) ;
                return new TypedInputStream(in, ct) ;
            }
            catch (MalformedURLException ex) {
                throw new RiotException("Bad FTP URL: "+uri, ex) ;
            }
View Full Code Here

            }
           
            if ( StreamManager.logAllLookups  && log.isTraceEnabled() )
                log.trace("Found: "+filenameOrURI) ;
           
            ContentType ct = RDFLanguages.guessContentType(filenameOrURI) ;
            return new TypedInputStream(in, ct, filenameOrURI) ;
        }
        catch (IOException ex)
        {
            log.warn("IO Exception opening zip entry: " + filenameOrURI);
View Full Code Here

       
    @Test public void syntaxDetermination()
    { test(url, contentType, hintLang, expected) ; }
   
    static void test(String url, String ct, Lang hint, Lang expected) {
        ContentType x = RDFDataMgr.determineCT(url, ct, hint) ;
        Lang lang = RDFDataMgr.determineLang(url, ct, hint) ;
        assertEquals(expected, lang) ;
    }
View Full Code Here

            InputStream in = IO.openFileEx(fn) ;

            if ( StreamManager.logAllLookups && log.isTraceEnabled() )
                log.trace("Found: "+filenameIRI+thisDirLogStr) ;
           
            ContentType ct = RDFLanguages.guessContentType(filenameIRI) ;
            return new TypedInputStream(in, ct, filenameIRI) ;
        } catch (IOException ioEx)
        {
            // Includes FileNotFoundException
            // We already tested whether the file exists or not.
View Full Code Here

        }
       
        if ( StreamManager.logAllLookups  && log.isTraceEnabled() )
            log.trace("Found: "+resourceName) ;
       
        ContentType ct = RDFLanguages.guessContentType(resourceName) ;
        // No sensible base URI.
        return new TypedInputStream(in, ct, null) ;
    }
View Full Code Here

    protected void perform(HttpAction action)
    {
        // WebContent needs to migrate to using ContentType.
        String ctStr ;
        {
            ContentType ct = FusekiLib.getContentType(action) ;
            if ( ct == null )
                ctStr = WebContent.contentTypeSPARQLUpdate ;
            else
                ctStr = ct.getContentType() ;
        }

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

TOP

Related Classes of org.apache.jena.atlas.web.ContentType

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.