Author: rvesse
Date: Fri May 31 22:07:24 2013
New Revision: 1488410

URL: http://svn.apache.org/r1488410
Log:
Add additional parameters to Remote Endpoint driver to allow configuring 
request content types

Modified:
    
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
    
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
    
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
    
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
    
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithGraphUris.java
    
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java

Modified: 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java?rev=1488410&r1=1488409&r2=1488410&view=diff
==============================================================================
--- 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
 (original)
+++ 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
 Fri May 31 22:07:24 2013
@@ -72,6 +72,10 @@ import org.apache.jena.jdbc.remote.conne
  * for updates</li>
  * <li>{@code using-named-graph-uri} - Sets a named graph for updates, may be
  * specified multiple times to specify multiple named graphs for the 
dataset</li>
+ * <li>{@code select-results-type} - Sets the format to request {@code SELECT}
+ * results in from the remote endpoint</li>
+ * <li>{@code model-results-type} - Sets the format to request {@code 
CONSTRUCT}
+ * and {@code DESCRIBE} results in from the remote endpoint</li>
  * </ul>
  * <p>
  * The driver also supports the standard JDBC {@code user} and {@code password}
@@ -128,6 +132,19 @@ public class RemoteEndpointDriver extend
     public static final String PARAM_USING_NAMED_GRAPH_URI = 
"using-named-graph-uri";
 
     /**
+     * Constant for the connection URL parameter that sets the results type to
+     * request for {@code SELECT} queries against the remote endpoint
+     */
+    public static final String PARAM_SELECT_RESULTS_TYPE = 
"select-results-type";
+
+    /**
+     * Constant for the connection URL parameter that sets the results type to
+     * request for {@code CONSTRUCT} and {@code DESCRIBE} queries against the
+     * remote endpoint
+     */
+    public static final String PARAM_MODEL_RESULTS_TYPE = "model-results-type";
+
+    /**
      * Creates a new driver
      */
     public RemoteEndpointDriver() {
@@ -135,10 +152,15 @@ public class RemoteEndpointDriver extend
     }
 
     /**
-     * Extension point for derived drivers which allows them to provide 
different version information and driver prefix
-     * @param majorVersion Major version
-     * @param minorVersion Minor version
-     * @param driverPrefix Driver Prefix
+     * Extension point for derived drivers which allows them to provide
+     * different version information and driver prefix
+     * 
+     * @param majorVersion
+     *            Major version
+     * @param minorVersion
+     *            Minor version
+     * @param driverPrefix
+     *            Driver Prefix
      */
     protected RemoteEndpointDriver(int majorVersion, int minorVersion, String 
driverPrefix) {
         super(majorVersion, minorVersion, driverPrefix);
@@ -171,16 +193,20 @@ public class RemoteEndpointDriver extend
         List<String> usingNamedGraphs = this.getValues(props, 
PARAM_USING_NAMED_GRAPH_URI);
 
         // Authentication settings
-        String user = props.getProperty(PARAM_USERNAME);
+        String user = props.getProperty(PARAM_USERNAME, null);
         if (user != null && user.trim().length() == 0)
             user = null;
-        String password = props.getProperty(PARAM_PASSWORD);
+        String password = props.getProperty(PARAM_PASSWORD, null);
         if (password != null && password.trim().length() == 0)
             password = null;
+        
+        // Result Types
+        String selectResultsType = 
props.getProperty(PARAM_SELECT_RESULTS_TYPE, null);
+        String modelResultsType = props.getProperty(PARAM_MODEL_RESULTS_TYPE, 
null);
 
         // Create connection
         return openConnection(queryEndpoint, updateEndpoint, defaultGraphs, 
namedGraphs, usingGraphs, usingNamedGraphs, user,
-                password, JenaConnection.DEFAULT_HOLDABILITY, 
compatibilityLevel);
+                password, JenaConnection.DEFAULT_HOLDABILITY, 
compatibilityLevel, selectResultsType, modelResultsType);
     }
 
     /**
@@ -213,14 +239,19 @@ public class RemoteEndpointDriver extend
      *            Result Set holdability
      * @param compatibilityLevel
      *            JDBC compatibility level, see {@link JdbcCompatibility}
+     * @param selectResultsType
+     *            Results Type for {@code SELECT} results
+     * @param modelResultsType
+     *            Results Type for {@code CONSTRUCT} and {@code DESCRIBE}
+     *            results
      * @return Remote endpoint connection
      * @throws SQLException
      */
     protected RemoteEndpointConnection openConnection(String queryEndpoint, 
String updateEndpoint, List<String> defaultGraphs,
             List<String> namedGraphs, List<String> usingGraphs, List<String> 
usingNamedGraphs, String user, String password,
-            int holdability, int compatibilityLevel) throws SQLException {
+            int holdability, int compatibilityLevel, String selectResultsType, 
String modelResultsType) throws SQLException {
         return new RemoteEndpointConnection(queryEndpoint, updateEndpoint, 
defaultGraphs, namedGraphs, usingGraphs,
-                usingNamedGraphs, user, password, holdability, 
compatibilityLevel);
+                usingNamedGraphs, user, password, holdability, 
compatibilityLevel, selectResultsType, modelResultsType);
     }
 
     @Override
@@ -235,8 +266,8 @@ public class RemoteEndpointDriver extend
 
     @Override
     protected DriverPropertyInfo[] getPropertyInfo(Properties connProps, 
List<DriverPropertyInfo> baseDriverProps) {
-        DriverPropertyInfo[] driverProps = new DriverPropertyInfo[8 + 
baseDriverProps.size()];
-        this.copyBaseProperties(driverProps, baseDriverProps, 8);
+        DriverPropertyInfo[] driverProps = new DriverPropertyInfo[10 + 
baseDriverProps.size()];
+        this.copyBaseProperties(driverProps, baseDriverProps, 10);
 
         // Query Endpoint parameter
         driverProps[0] = new DriverPropertyInfo(PARAM_QUERY_ENDPOINT, 
connProps.getProperty(PARAM_QUERY_ENDPOINT));
@@ -269,12 +300,20 @@ public class RemoteEndpointDriver extend
         driverProps[5] = new DriverPropertyInfo(PARAM_USING_NAMED_GRAPH_URI, 
null);
         driverProps[5].required = false;
         driverProps[5].description = "Sets the URI for a named graph for 
updates, may be specified multiple times to specify multiple named graph which 
should be accessible";
+        
+        // Results Types
+        driverProps[6] = new DriverPropertyInfo(PARAM_SELECT_RESULTS_TYPE, 
connProps.getProperty(PARAM_SELECT_RESULTS_TYPE));
+        driverProps[6].required = false;
+        driverProps[6].description = "Sets the results type for SELECT queries 
that will be requested from the remote endpoint";
+        driverProps[7] = new DriverPropertyInfo(PARAM_MODEL_RESULTS_TYPE, 
connProps.getProperty(PARAM_MODEL_RESULTS_TYPE));
+        driverProps[7].required = false;
+        driverProps[7].description = "Sets the results type for CONSTRUCT and 
DESCRIBE queries that will be requested from the remote endpoint";
 
         // User Name parameter
-        driverProps[6] = new DriverPropertyInfo(PARAM_USERNAME, 
connProps.getProperty(PARAM_USERNAME));
+        driverProps[8] = new DriverPropertyInfo(PARAM_USERNAME, 
connProps.getProperty(PARAM_USERNAME));
 
         // Password parameter
-        driverProps[7] = new DriverPropertyInfo(PARAM_PASSWORD, 
connProps.getProperty(PARAM_PASSWORD));
+        driverProps[9] = new DriverPropertyInfo(PARAM_PASSWORD, 
connProps.getProperty(PARAM_PASSWORD));
 
         return driverProps;
     }

Modified: 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java?rev=1488410&r1=1488409&r2=1488410&view=diff
==============================================================================
--- 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
 (original)
+++ 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
 Fri May 31 22:07:24 2013
@@ -49,6 +49,7 @@ public class RemoteEndpointConnection ex
     private String username;
     private char[] password;
     private DatabaseMetaData metadata;
+    private String selectResultsType, modelResultsType;
 
     /**
      * Creates a new remote connection
@@ -66,7 +67,7 @@ public class RemoteEndpointConnection ex
      */
     public RemoteEndpointConnection(String queryEndpoint, String 
updateEndpoint, int holdability, int compatibilityLevel)
             throws SQLException {
-        this(queryEndpoint, updateEndpoint, null, null, null, null, null, 
null, holdability, compatibilityLevel);
+        this(queryEndpoint, updateEndpoint, null, null, null, null, null, 
null, holdability, compatibilityLevel, null, null);
     }
 
     /**
@@ -92,12 +93,19 @@ public class RemoteEndpointConnection ex
      *            Result Set holdability
      * @param compatibilityLevel
      *            JDBC compatibility level, see {@link JdbcCompatibility}
+     * @param selectResultsType
+     *            Results Type to request for {@code SELECT} queries against 
the
+     *            remote endpoint
+     * @param modelResultsType
+     *            Results Type to request for {@code CONSTRUCT} and
+     *            {@code DESCRIBE} queries against the remote endpoint
      * @throws SQLException
      *             Thrown if there is a problem creating the connection
      */
     public RemoteEndpointConnection(String queryEndpoint, String 
updateEndpoint, List<String> defaultGraphUris,
             List<String> namedGraphUris, List<String> usingGraphUris, 
List<String> usingNamedGraphUris, String username,
-            String password, int holdability, int compatibilityLevel) throws 
SQLException {
+            String password, int holdability, int compatibilityLevel, String 
selectResultsType, String modelResultsType)
+            throws SQLException {
         super(holdability, true, Connection.TRANSACTION_NONE, 
compatibilityLevel);
         if (queryEndpoint == null && updateEndpoint == null)
             throw new SQLException("Must specify one/both of a query endpoint 
and update endpoint");
@@ -111,6 +119,8 @@ public class RemoteEndpointConnection ex
         this.username = username;
         this.password = (password != null) ? password.toCharArray() : null;
         this.metadata = new RemoteEndpointMetadata(this);
+        this.selectResultsType = selectResultsType;
+        this.modelResultsType = modelResultsType;
     }
 
     /**
@@ -167,6 +177,28 @@ public class RemoteEndpointConnection ex
         return this.usingNamedGraphUris;
     }
 
+    /**
+     * Gets the results type that will be requested from the remote endpoint 
for
+     * {@code SELECT} queries
+     * 
+     * @return Select results type if set, otherwise null which indicates that
+     *         the ARQ default will be used
+     */
+    public String getSelectResultsType() {
+        return this.selectResultsType;
+    }
+
+    /**
+     * Gets the results type that will be requested from the remote endpoint 
for
+     * {@code CONSTRUCT} and {@code DESCRIBE} queries.
+     * 
+     * @return Model results type if set, otherwise null which indicates that
+     *         the ARQ default will be used
+     */
+    public String getModelResultsType() {
+        return this.modelResultsType;
+    }
+
     @Override
     protected void closeInternal() throws SQLException {
         this.closed = true;
@@ -181,18 +213,21 @@ public class RemoteEndpointConnection ex
             throw new SQLException("Remote endpoint backed connection do not 
support scroll sensitive result sets");
         if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
             throw new SQLException("Remote endpoint backed connections only 
support read-only result sets");
-        return new RemoteEndpointStatement(this, this.username, this.password, 
resultSetType, ResultSet.FETCH_FORWARD, 0, resultSetHoldability);
+        return new RemoteEndpointStatement(this, this.username, this.password, 
resultSetType, ResultSet.FETCH_FORWARD, 0,
+                resultSetHoldability);
     }
-    
+
     @Override
-    protected JenaPreparedStatement createPreparedStatementInternal(String 
sparql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) 
throws SQLException {
+    protected JenaPreparedStatement createPreparedStatementInternal(String 
sparql, int resultSetType, int resultSetConcurrency,
+            int resultSetHoldability) throws SQLException {
         if (this.isClosed())
             throw new SQLException("Cannot create a statement after the 
connection was closed");
         if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)
             throw new SQLException("Remote endpoint backed connection do not 
support scroll sensitive result sets");
         if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
             throw new SQLException("Remote endpoint backed connections only 
support read-only result sets");
-        return new RemoteEndpointPreparedStatement(sparql, this, 
this.username, this.password, resultSetType, ResultSet.FETCH_FORWARD, 0, 
resultSetHoldability);
+        return new RemoteEndpointPreparedStatement(sparql, this, 
this.username, this.password, resultSetType,
+                ResultSet.FETCH_FORWARD, 0, resultSetHoldability);
     }
 
     @Override
@@ -250,6 +285,7 @@ public class RemoteEndpointConnection ex
 
     /**
      * Gets the username used for HTTP authentication (if any)
+     * 
      * @return Username
      */
     public String getUserName() {

Modified: 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java?rev=1488410&r1=1488409&r2=1488410&view=diff
==============================================================================
--- 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
 (original)
+++ 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointPreparedStatement.java
 Fri May 31 22:07:24 2013
@@ -109,6 +109,14 @@ public class RemoteEndpointPreparedState
         if (this.remoteConn.getNamedGraphURIs() != null) {
             exec.setNamedGraphURIs(this.remoteConn.getNamedGraphURIs());
         }
+        
+        // Set result types
+        if (this.remoteConn.getSelectResultsType() != null) {
+            exec.setSelectContentType(this.remoteConn.getSelectResultsType());
+        }
+        if (this.remoteConn.getModelResultsType() != null) {
+            exec.setModelContentType(this.remoteConn.getModelResultsType());
+        }
 
         // Return execution
         return exec;

Modified: 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java?rev=1488410&r1=1488409&r2=1488410&view=diff
==============================================================================
--- 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
 (original)
+++ 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/statements/RemoteEndpointStatement.java
 Fri May 31 22:07:24 2013
@@ -93,12 +93,12 @@ public class RemoteEndpointStatement ext
 
         // Create basic execution
         QueryEngineHTTP exec = (QueryEngineHTTP) 
QueryExecutionFactory.sparqlService(this.remoteConn.getQueryEndpoint(), q);
-        
+
         // Apply authentication settings
         if (this.username != null && this.password != null) {
             exec.setBasicAuthentication(this.username, this.password);
         }
-        
+
         // Apply default and named graphs if appropriate
         if (this.remoteConn.getDefaultGraphURIs() != null) {
             exec.setDefaultGraphURIs(this.remoteConn.getDefaultGraphURIs());
@@ -106,20 +106,29 @@ public class RemoteEndpointStatement ext
         if (this.remoteConn.getNamedGraphURIs() != null) {
             exec.setNamedGraphURIs(this.remoteConn.getNamedGraphURIs());
         }
-        
+
+        // Set result types
+        if (this.remoteConn.getSelectResultsType() != null) {
+            exec.setSelectContentType(this.remoteConn.getSelectResultsType());
+        }
+        if (this.remoteConn.getModelResultsType() != null) {
+            exec.setModelContentType(this.remoteConn.getModelResultsType());
+        }
+
         // Return execution
         return exec;
     }
 
     @Override
     protected UpdateProcessor createUpdateProcessor(UpdateRequest u) {
-        UpdateProcessRemoteBase proc = (UpdateProcessRemoteBase) 
UpdateExecutionFactory.createRemote(u, this.remoteConn.getUpdateEndpoint());
-        
+        UpdateProcessRemoteBase proc = (UpdateProcessRemoteBase) 
UpdateExecutionFactory.createRemote(u,
+                this.remoteConn.getUpdateEndpoint());
+
         // Apply authentication settings
         if (this.username != null && this.password != null) {
             proc.setAuthentication(this.username, this.password);
         }
-        
+
         // Apply default and named graphs if appropriate
         if (this.remoteConn.getUsingGraphURIs() != null) {
             proc.setDefaultGraphs(this.remoteConn.getUsingGraphURIs());
@@ -127,7 +136,7 @@ public class RemoteEndpointStatement ext
         if (this.remoteConn.getNamedGraphURIs() != null) {
             proc.setNamedGraphs(this.remoteConn.getUsingNamedGraphURIs());
         }
-        
+
         return proc;
     }
 

Modified: 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithGraphUris.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithGraphUris.java?rev=1488410&r1=1488409&r2=1488410&view=diff
==============================================================================
--- 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithGraphUris.java
 (original)
+++ 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/connections/TestRemoteEndpointConnectionWithGraphUris.java
 Fri May 31 22:07:24 2013
@@ -75,7 +75,7 @@ public class TestRemoteEndpointConnectio
     protected JenaConnection getConnection() throws SQLException {
         List<String> defaultGraphs = new ArrayList<String>();
         defaultGraphs.add(DEFAULT_GRAPH_URI);
-        return new RemoteEndpointConnection(BaseServerTest.serviceQuery, 
BaseServerTest.serviceUpdate, defaultGraphs, null, defaultGraphs, null, null, 
null, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT);
+        return new RemoteEndpointConnection(BaseServerTest.serviceQuery, 
BaseServerTest.serviceUpdate, defaultGraphs, null, defaultGraphs, null, null, 
null, JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT, null, 
null);
     }
 
     @Override

Modified: 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
URL: 
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java?rev=1488410&r1=1488409&r2=1488410&view=diff
==============================================================================
--- 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
 (original)
+++ 
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/test/java/org/apache/jena/jdbc/remote/results/TestRemoteEndpointResultsWithGraphUris.java
 Fri May 31 22:07:24 2013
@@ -61,7 +61,7 @@ public class TestRemoteEndpointResultsWi
         
         List<String> defaultGraphUris = new ArrayList<String>();
         defaultGraphUris.add(DEFAULT_GRAPH_URI);
-        connection = new RemoteEndpointConnection(BaseServerTest.serviceQuery, 
BaseServerTest.serviceUpdate, defaultGraphUris, null, null, null, null, null, 
JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT);
+        connection = new RemoteEndpointConnection(BaseServerTest.serviceQuery, 
BaseServerTest.serviceUpdate, defaultGraphUris, null, null, null, null, null, 
JenaConnection.DEFAULT_HOLDABILITY, JdbcCompatibility.DEFAULT, null, null);
         connection.setJdbcCompatibilityLevel(JdbcCompatibility.HIGH);
     }
     


Reply via email to