Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-598

SPARQL Load requires correct http content-type, should fall back to file ending

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • Fuseki 1.0.0
    • Jena 2.11.1, Fuseki 1.0.1
    • Jena
    • None

    Description

      A SPARQL Update query with a LOAD command requires a correct HTTP content-type (mime-type) to be returned with the GET request when downloading the file.

      Should have 2 failovers:

      1. Attempt to use file ending. .ttl == TTL .xml == RDF/XML and so on
      2. Attempt to read the file with a different language (eg. if TTL fails, try RDF/XML)

      The code for this seems to be here: https://svn.apache.org/repos/asf/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java

      @Override
      public void visit(UpdateLoad update)
      {
      String source = update.getSource() ;
      Node dest = update.getDest() ;
      try {
      // Read into temporary storage to protect against parse errors.
      TypedInputStream s = RDFDataMgr.open(source) ;
      Lang lang = RDFLanguages.contentTypeToLang(s.getContentType()) ; //--- THIS IS WHERE THE BUG IS ---//
      if ( RDFLanguages.isTriples(lang) )

      { // Triples Graph g = GraphFactory.createGraphMem() ; StreamRDF stream = StreamRDFLib.graph(g) ; RDFDataMgr.parse(stream, s, source) ; Graph g2 = graph(graphStore, dest) ; GraphUtil.addInto(g2, g) ; }

      else {
      // Quads
      if ( dest != null )
      throw new UpdateException("Attempt to load quads into a graph") ;
      DatasetGraph dsg = DatasetGraphFactory.createMem() ;
      StreamRDF stream = StreamRDFLib.dataset(dsg) ;
      RDFDataMgr.parse(stream, s, source) ;
      Iterator<Quad> iter = dsg.find() ;
      for ( ; iter.hasNext() ; )

      { Quad q = iter.next() ; graphStore.add(q) ; }

      }
      } catch (RuntimeException ex)
      {
      if ( ! update.getSilent() )

      { if ( ex instanceof UpdateException ) throw (UpdateException)ex ; throw new UpdateException("Failed to LOAD '"+source+"'", ex) ; }

      }
      }

      Attachments

        Activity

          People

            andy Andy Seaborne
            hmottestad HÃ¥vard Ottestad
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 6h
                6h
                Remaining:
                Remaining Estimate - 6h
                6h
                Logged:
                Time Spent - Not Specified
                Not Specified