jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sal...@apache.org
Subject svn commit: r1346187 - in /jena/Experimental/jena-client/src/main/java/org/apache/jena/client: ./ graph/ http/ service/
Date Mon, 04 Jun 2012 22:44:41 GMT
Author: sallen
Date: Mon Jun  4 22:44:40 2012
New Revision: 1346187

URL: http://svn.apache.org/viewvc?rev=1346187&view=rev
Log:
jena-client - removed org.apache.client.service package.

Removed:
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphService.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryService.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdateService.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/service/
Modified:
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphRepository.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdater.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpRepository.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdater.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/QuadIteratorEntity.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/TripleIteratorEntity.java
    jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/UpdateRemote.java

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java (original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/Connection.java Mon
Jun  4 22:44:40 2012
@@ -18,9 +18,6 @@
 
 package org.apache.jena.client;
 
-import org.apache.jena.client.service.QueryService;
-import org.apache.jena.client.service.Service;
-import org.apache.jena.client.service.UpdateService;
 import org.openjena.atlas.lib.Closeable;
 
 import com.hp.hpl.jena.query.Query;

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/UpdateStatementBase.java
Mon Jun  4 22:44:40 2012
@@ -1,6 +1,5 @@
 package org.apache.jena.client;
 
-import java.util.concurrent.TimeUnit;
 
 public abstract class UpdateStatementBase extends ParameterizerBase implements UpdateStatement
 {

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphConnection.java
Mon Jun  4 22:44:40 2012
@@ -8,15 +8,15 @@ import org.apache.jena.client.Updater;
 
 import com.hp.hpl.jena.query.Query;
 import com.hp.hpl.jena.query.ReadWrite;
+import com.hp.hpl.jena.sparql.core.DatasetGraph;
 import com.hp.hpl.jena.update.Update;
 
 public class DatasetGraphConnection extends ConnectionBase
 {
     private final DatasetGraphRepository repo;
+    private final DatasetGraph dsg;
     
-    private DatasetGraphService activeService;
-    
-    DatasetGraphConnection(DatasetGraphRepository repo, DatasetGraphService service)
+    DatasetGraphConnection(DatasetGraphRepository repo, DatasetGraph dsg)
     {
         if (null == repo)
         {
@@ -24,7 +24,7 @@ public class DatasetGraphConnection exte
         }
         
         this.repo = repo;
-        this.activeService = service;
+        this.dsg = dsg;
         
     }
     
@@ -37,7 +37,7 @@ public class DatasetGraphConnection exte
     @Override
     protected Updater doCreateBulkUpdater()
     {
-        DatasetGraphUpdater updater = new DatasetGraphUpdater(activeService);
+        DatasetGraphUpdater updater = new DatasetGraphUpdater(dsg);
         updater.open();
         return updater;
     }
@@ -51,7 +51,7 @@ public class DatasetGraphConnection exte
     @Override
     public QueryStatement createQueryStatement(String queryString)
     {
-        return new DatasetGraphQueryStatement(queryString, activeService, this);
+        return new DatasetGraphQueryStatement(queryString, dsg, this);
     }
 
     @Override

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphQueryStatement.java
Mon Jun  4 22:44:40 2012
@@ -9,28 +9,29 @@ import com.hp.hpl.jena.graph.Triple;
 import com.hp.hpl.jena.query.QueryExecution;
 import com.hp.hpl.jena.query.QueryExecutionFactory;
 import com.hp.hpl.jena.query.ResultSet;
+import com.hp.hpl.jena.sparql.core.DatasetGraph;
 import com.hp.hpl.jena.sparql.core.DatasetImpl;
 
 class DatasetGraphQueryStatement extends QueryStatementBase implements QueryStatement
 {
     private final String queryString;
-    private final DatasetGraphService queryService;
+    private final DatasetGraph dsg;
     
     private Object lock = new Object();
     private QueryExecution qe;
     
-    DatasetGraphQueryStatement(String queryString, DatasetGraphService queryService, DatasetGraphConnection
connection)
+    DatasetGraphQueryStatement(String queryString, DatasetGraph dsg, DatasetGraphConnection
connection)
     {
         super(connection);
         this.queryString = queryString;
-        this.queryService = queryService;
+        this.dsg = dsg;
     }
     
     private QueryExecution createQueryExecution()
     {
         // TODO Handle Query object in addition to QueryString
         String sparql = toString();
-        QueryExecution qe = QueryExecutionFactory.create(sparql, DatasetImpl.wrap(queryService.getDatasetGraph()));
+        QueryExecution qe = QueryExecutionFactory.create(sparql, DatasetImpl.wrap(dsg));
         // TODO Set the options on qe, such as timeouts
         synchronized (lock)
         {

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphRepository.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphRepository.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphRepository.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphRepository.java
Mon Jun  4 22:44:40 2012
@@ -7,17 +7,17 @@ import com.hp.hpl.jena.sparql.core.Datas
 
 public class DatasetGraphRepository implements Repository
 {
-    private final DatasetGraphService service;
+    private final DatasetGraph dsg;
     
     public DatasetGraphRepository(DatasetGraph dsg)
     {
-        this.service = new DatasetGraphService(dsg);
+        this.dsg = dsg;
     }
 
     @Override
     public Connection getConnection()
     {
-        return new DatasetGraphConnection(this, service);
+        return new DatasetGraphConnection(this, dsg);
     }
     
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdater.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdater.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdater.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/graph/DatasetGraphUpdater.java
Mon Jun  4 22:44:40 2012
@@ -13,19 +13,17 @@ import com.hp.hpl.jena.update.UpdateRequ
 // TODO This is not atomic!  But the underlying DatasetGraph isn't atomic anyway...
 public class DatasetGraphUpdater extends UpdaterBase
 {
-    private final DatasetGraphService service;
+    private final DatasetGraph dsg;
     
-    private DatasetGraph dsg;
     private boolean opened = false;
     
-    public DatasetGraphUpdater(DatasetGraphService service)
+    public DatasetGraphUpdater(DatasetGraph dsg)
     {
-        this.service = service;
+        this.dsg = dsg;
     }
     
     public void open()
     {
-        dsg = service.getDatasetGraph();
         opened = true;
     }
     
@@ -76,7 +74,6 @@ public class DatasetGraphUpdater extends
     {
         if (opened)
         {
-            dsg = null;
             opened = false;
         }
     }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpConnection.java
Mon Jun  4 22:44:40 2012
@@ -14,10 +14,10 @@ public class HttpConnection extends Conn
 {
     private final HttpRepository repo;
     
-    private HttpQueryService activeQueryService;
-    private HttpUpdateService activeUpdateService;
+    private String queryEndpoint;
+    private String updateEndpoint;
     
-    HttpConnection(HttpRepository repo, HttpQueryService queryService, HttpUpdateService
updateService)
+    HttpConnection(HttpRepository repo, String queryEndpoint, String updateEndpoint)
     {
         if (null == repo)
         {
@@ -25,9 +25,8 @@ public class HttpConnection extends Conn
         }
         
         this.repo = repo;
-        this.activeQueryService = queryService;
-        this.activeUpdateService = updateService;
-        
+        this.queryEndpoint = queryEndpoint;
+        this.updateEndpoint = updateEndpoint;
     }
     
     @Override
@@ -39,7 +38,7 @@ public class HttpConnection extends Conn
     @Override
     protected Updater doCreateBulkUpdater()
     {
-        HttpUpdater updater = new HttpUpdater(activeUpdateService);
+        HttpUpdater updater = new HttpUpdater(updateEndpoint);
         updater.open();
         return updater;
     }
@@ -72,7 +71,7 @@ public class HttpConnection extends Conn
     @Override
     public QueryStatement createQueryStatement(String queryString)
     {
-        return new HttpQueryStatement(queryString, activeQueryService, this);
+        return new HttpQueryStatement(queryString, queryEndpoint, this);
     }
 
     @Override

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpQueryStatement.java
Mon Jun  4 22:44:40 2012
@@ -12,20 +12,20 @@ import com.hp.hpl.jena.sparql.engine.htt
 class HttpQueryStatement extends QueryStatementBase implements QueryStatement
 {
     private final String queryString;
-    private final HttpQueryService queryService;
+    private final String queryEndpoint;
     
-    HttpQueryStatement(String queryString, HttpQueryService queryService, HttpConnection
connection)
+    HttpQueryStatement(String queryString, String queryEndpoint, HttpConnection connection)
     {
         super(connection);
         this.queryString = queryString;
-        this.queryService = queryService;
+        this.queryEndpoint = queryEndpoint;
     }
     
     private QueryEngineHTTP createQueryExecution()
     {
         // TODO Handle Query object in addition to QueryString
         String sparql = toString();
-        QueryEngineHTTP qe = new QueryEngineHTTP(queryService.getEndpointUrl(), sparql);
+        QueryEngineHTTP qe = new QueryEngineHTTP(queryEndpoint, sparql);
         // TODO Set the options on qe, such as timeouts
         return qe;
     }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpRepository.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpRepository.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpRepository.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpRepository.java
Mon Jun  4 22:44:40 2012
@@ -5,20 +5,20 @@ import org.apache.jena.client.Repository
 
 public class HttpRepository implements Repository
 {
-    private final HttpQueryService defaultQueryService;
-    private final HttpUpdateService defaultUpdateService;
+    private final String queryEndpoint;
+    private final String updateEndpoint;
     
     
     public HttpRepository(String queryEndpoint, String updateEndpoint)
     {
-        this.defaultQueryService = new HttpQueryService(queryEndpoint);
-        this.defaultUpdateService = new HttpUpdateService(updateEndpoint);
+        this.queryEndpoint = queryEndpoint;
+        this.updateEndpoint = updateEndpoint;
     }
 
     @Override
     public Connection getConnection()
     {
-        return new HttpConnection(this, defaultQueryService, defaultUpdateService);
+        return new HttpConnection(this, queryEndpoint, updateEndpoint);
     }
     
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdater.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdater.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdater.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/HttpUpdater.java
Mon Jun  4 22:44:40 2012
@@ -1,11 +1,13 @@
 package org.apache.jena.client.http;
 
+import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URLEncoder;
 import java.util.Iterator;
 
 import org.apache.jena.client.UpdaterBase;
@@ -20,7 +22,7 @@ import com.hp.hpl.jena.update.UpdateExce
 
 public class HttpUpdater extends UpdaterBase
 {
-    private final HttpUpdateService updateService;
+    private final String updateEndpoint;
     private final SerializationContext sCxt;
     
     private HttpURLConnection conn;
@@ -28,14 +30,18 @@ public class HttpUpdater extends Updater
     private UpdateWriter writer;
     private boolean opened = false;
     
-    public HttpUpdater(HttpUpdateService updateService)
+    public HttpUpdater(String updateEndpoint)
     {
-        this(updateService, null);
+        this(updateEndpoint, null);
     }
     
-    public HttpUpdater(HttpUpdateService updateService, SerializationContext sCxt)
+    public HttpUpdater(String updateEndpoint, SerializationContext sCxt)
     {
-        this.updateService = updateService;
+        if (null == updateEndpoint) {
+            throw new IllegalArgumentException("updateEndpoint must be specified if performing
update operations");
+        }
+        
+        this.updateEndpoint = updateEndpoint;
         this.sCxt = sCxt;
     }
     
@@ -44,7 +50,7 @@ public class HttpUpdater extends Updater
         URL url;
         try
         {
-            url = new URL(updateService.getEndpointUrl());
+            url = new URL(updateEndpoint);
             URLConnection urlConn = url.openConnection();
             if (!(urlConn instanceof HttpURLConnection))
             {
@@ -53,8 +59,8 @@ public class HttpUpdater extends Updater
             conn = (HttpURLConnection)urlConn;
             conn.setDoOutput(true);
             conn.setRequestMethod("POST");
-            conn.setRequestProperty("Content-Type", WebContent.contentTypeSPARQLUpdate);
-            //conn.setRequestProperty("Content-Type", WebContent.contentTypeForm);
+            //conn.setRequestProperty("Content-Type", WebContent.contentTypeSPARQLUpdate);
+            conn.setRequestProperty("Content-Type", WebContent.contentTypeForm);
             // TODO Potential optimization: allow gzip when we know we're dealing with Fuseki
(also update Fuseki to allow this!)
             //conn.setRequestProperty("Content-Encoding", "gzip");
             conn.setChunkedStreamingMode(4096);
@@ -63,8 +69,10 @@ public class HttpUpdater extends Updater
             out = conn.getOutputStream();
             //out = new GZIPOutputStream(conn.getOutputStream());
             
-            IndentedWriter iw = new IndentedWriter(out);
-            //iw.print("update=");
+            //IndentedWriter iw = new IndentedWriter(out);
+            out.write("update=".getBytes("UTF-8"));
+            IndentedWriter iw = new IndentedWriter(new URLEncoderOutputStream(out));
+            
             
             writer = new UpdateWriter(iw, sCxt);
             writer.open();
@@ -143,4 +151,21 @@ public class HttpUpdater extends Updater
             }
         }
     }
+    
+    
+    // TODO this is not efficient.  And is it even correct?  Will it properly escape UTF
codepoints over a byte in size?
+    private class URLEncoderOutputStream extends FilterOutputStream
+    {
+        public URLEncoderOutputStream(OutputStream out)
+        {
+            super(out);
+        }
+        
+        @Override
+        public void write(int b) throws IOException
+        {
+            String enc = URLEncoder.encode(new String(new byte[] { (byte)b }), "UTF-8");
+            out.write(enc.getBytes("UTF-8"));
+        }
+    }
 }

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/QuadIteratorEntity.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/QuadIteratorEntity.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/QuadIteratorEntity.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/QuadIteratorEntity.java
Mon Jun  4 22:44:40 2012
@@ -15,6 +15,7 @@ import com.hp.hpl.jena.sparql.modify.req
 import com.hp.hpl.jena.sparql.modify.request.UpdateDataWriter.UpdateMode;
 import com.hp.hpl.jena.sparql.serializer.SerializationContext;
 
+// TODO Not used
 class QuadIteratorEntity extends AbstractHttpEntity
 {
     private final UpdateMode mode;

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/TripleIteratorEntity.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/TripleIteratorEntity.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/TripleIteratorEntity.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/TripleIteratorEntity.java
Mon Jun  4 22:44:40 2012
@@ -15,6 +15,7 @@ import com.hp.hpl.jena.sparql.modify.req
 import com.hp.hpl.jena.sparql.modify.request.UpdateDataWriter.UpdateMode;
 import com.hp.hpl.jena.sparql.serializer.SerializationContext;
 
+// TODO Not used
 class TripleIteratorEntity extends AbstractHttpEntity
 {
     private final UpdateMode mode;

Modified: jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/UpdateRemote.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/UpdateRemote.java?rev=1346187&r1=1346186&r2=1346187&view=diff
==============================================================================
--- jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/UpdateRemote.java
(original)
+++ jena/Experimental/jena-client/src/main/java/org/apache/jena/client/http/UpdateRemote.java
Mon Jun  4 22:44:40 2012
@@ -45,6 +45,7 @@ import com.hp.hpl.jena.update.Update ;
 import com.hp.hpl.jena.update.UpdateException ;
 import com.hp.hpl.jena.update.UpdateRequest ;
 
+// TODO Not used
 class UpdateRemote
 {
     private final String serviceURL;



Mime
View raw message