Return-Path: X-Original-To: apmail-incubator-jena-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-jena-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF6C6794C for ; Wed, 17 Aug 2011 11:59:04 +0000 (UTC) Received: (qmail 20288 invoked by uid 500); 17 Aug 2011 11:59:04 -0000 Delivered-To: apmail-incubator-jena-commits-archive@incubator.apache.org Received: (qmail 20211 invoked by uid 500); 17 Aug 2011 11:59:03 -0000 Mailing-List: contact jena-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jena-dev@incubator.apache.org Delivered-To: mailing list jena-commits@incubator.apache.org Received: (qmail 19609 invoked by uid 99); 17 Aug 2011 11:59:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 11:59:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 11:58:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EE4492388A5E; Wed, 17 Aug 2011 11:58:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1158646 - in /incubator/jena/Scratch/AFS/trunk: src-dev/dev/RunAFS.java src/riot/comms/ src/riot/web/ Date: Wed, 17 Aug 2011 11:58:38 -0000 To: jena-commits@incubator.apache.org From: andy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110817115838.EE4492388A5E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: andy Date: Wed Aug 17 11:58:38 2011 New Revision: 1158646 URL: http://svn.apache.org/viewvc?rev=1158646&view=rev Log: (empty) Removed: incubator/jena/Scratch/AFS/trunk/src/riot/comms/ incubator/jena/Scratch/AFS/trunk/src/riot/web/ Modified: incubator/jena/Scratch/AFS/trunk/src-dev/dev/RunAFS.java Modified: incubator/jena/Scratch/AFS/trunk/src-dev/dev/RunAFS.java URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/trunk/src-dev/dev/RunAFS.java?rev=1158646&r1=1158645&r2=1158646&view=diff ============================================================================== --- incubator/jena/Scratch/AFS/trunk/src-dev/dev/RunAFS.java (original) +++ incubator/jena/Scratch/AFS/trunk/src-dev/dev/RunAFS.java Wed Aug 17 11:58:38 2011 @@ -18,34 +18,15 @@ package dev; -import java.io.IOException ; -import java.io.InputStream ; -import java.io.OutputStream ; -import java.net.URLEncoder ; -import java.util.ArrayList ; -import java.util.HashMap ; import java.util.Iterator ; -import java.util.List ; -import java.util.Map ; -import org.apache.http.HttpResponse ; -import org.openjena.atlas.iterator.Iter ; -import org.openjena.atlas.lib.StrUtils ; import org.openjena.atlas.logging.Log ; -import org.openjena.atlas.web.MediaType ; -import org.openjena.riot.WebContent ; -import riot.web.HttpOp ; -import riot.web.HttpResponseLib ; import storage.varrecord.VarRecordBuffer ; import com.hp.hpl.jena.iri.IRI ; import com.hp.hpl.jena.iri.IRIFactory ; import com.hp.hpl.jena.iri.Violation ; import com.hp.hpl.jena.iri.ViolationCodes ; -import com.hp.hpl.jena.query.ResultSet ; -import com.hp.hpl.jena.query.ResultSetFactory ; -import com.hp.hpl.jena.query.ResultSetFormatter ; -import com.hp.hpl.jena.sparql.resultset.ResultsFormat ; import com.hp.hpl.jena.tdb.base.record.Record ; public class RunAFS @@ -61,88 +42,8 @@ public class RunAFS public static void main(String ... args) throws Exception { - final String queryString1 = "SELECT * { ?s ?p ?o } LIMIT 1" ; - final String queryString2 = "SELECT * { ?s ?p ?o } LIMIT 10" ; - - // GET graph - Map handlers = new HashMap() ; - // Chnage to one handler for all graph types. - handlers.put(WebContent.contentTypeTurtle, HttpResponseLib.graphReaderTurtle) ; - handlers.put(WebContent.contentTypeRDFXML, HttpResponseLib.graphReaderRDFXML) ; - handlers.put("*", HttpResponseLib.httpDumpResponse) ; - - HttpCaptureResponse captureRS = new HttpCaptureResponse(){ - ResultSet rs = null ; - @Override - public void handle(String contentType, String baseIRI, HttpResponse response) throws IOException - { - MediaType mt = new MediaType(contentType) ; - ResultsFormat fmt = contentTypeToResultSet(contentType) ; - InputStream in = response.getEntity().getContent() ; - rs = ResultSetFactory.load(in, fmt) ; - // Force reading - rs = ResultSetFactory.copyResults(rs) ; - } - - @Override - public ResultSet get() - { - return rs ; - }} ; - - handlers.put(WebContent.contentTypeResultsXML, captureRS) ; - handlers.put(WebContent.contentTypeResultsJSON, captureRS) ; - handlers.put(WebContent.contentTypeTextTSV, captureRS) ; - - List acceptables = new ArrayList() ; - acceptables.add("text/turtle;q=0.8") ; - acceptables.add("application/rdf+xml;q=0.1") ; - String acceptHeader = Iter.asString(acceptables, " , ") ; - - HttpOp.execHttpGet("http://localhost:3030/ds/sparql?query="+URLEncoder.encode(queryString1,"UTF-8"), - acceptHeader, - handlers) ; - - ResultSetFormatter.out(captureRS.get()) ; - - - HttpOp.ContentProducer cp = new HttpOp.ContentProducer() { - - @Override - public void writeTo(OutputStream outstream) throws IOException - { - outstream.write(StrUtils.asUTF8bytes(queryString2)) ; - //outstream.flush() ; - }} ; - - - List acceptResultSets = new ArrayList() ; - acceptResultSets.add(WebContent.contentTypeResultsJSON+";q=0.9") ; - acceptResultSets.add(WebContent.contentTypeResultsXML+";q=0.5") ; - acceptResultSets.add(WebContent.contentTypeTextTSV+";q=0.8") ; - String acceptResultSet = Iter.asString(acceptResultSets, " , ") ; - - HttpOp.execHttpPost("http://localhost:3030/ds/sparql", - WebContent.contentTypeSPARQLQuery, cp, - acceptResultSet, handlers) ; - ResultSetFormatter.out(captureRS.get()) ; - exit(0) ; - - } - - public static ResultsFormat contentTypeToResultSet(String contentType) { return mapContentTypeToResultSet.get(contentType) ; } - static Map mapContentTypeToResultSet = new HashMap() ; - static { - mapContentTypeToResultSet.put(WebContent.contentTypeResultsXML, ResultsFormat.FMT_RS_XML) ; - mapContentTypeToResultSet.put(WebContent.contentTypeResultsJSON, ResultsFormat.FMT_RS_JSON) ; - mapContentTypeToResultSet.put(WebContent.contentTypeTextTSV, ResultsFormat.FMT_RS_TSV) ; } - - static interface HttpCaptureResponse extends HttpOp.HttpResponseHandler - { - public T get() ; - } - + static IRIFactory iriFactory = new IRIFactory(); static { // IRIFactory.iriImplementation() ...