afs commented on code in PR #3184:
URL: https://github.com/apache/jena/pull/3184#discussion_r2276623981


##########
jena-arq/src/main/java/org/apache/jena/http/auth/AuthLib.java:
##########
@@ -29,17 +29,24 @@
 import java.nio.charset.StandardCharsets;
 import java.util.Base64;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 import org.apache.jena.atlas.lib.Bytes;
 import org.apache.jena.atlas.web.AuthScheme;
 import org.apache.jena.atlas.web.HttpException;
+import org.apache.jena.http.AsyncHttpRDF;
 import org.apache.jena.http.HttpLib;
 import org.apache.jena.riot.web.HttpNames;
 import org.apache.jena.web.HttpSC;
 
 public class AuthLib {
+    /** @see #authExecuteAsync */

Review Comment:
   Please put in the javadoc, tweaking it with
   
   > `Call {@link HttpClient} after applying an active {@link 
AuthRequestModifier}`



##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Endpoint.java:
##########
@@ -59,7 +59,8 @@ private Endpoint(Operation operation, ValidString 
endpointName, AuthPolicy reque
         // Canonicalise to "" for dataset-level operations.
         this.endpointName = endpointName==null? DatasetEP : endpointName;
         this.authPolicy = requestAuth;
-        this.context = context;
+        // Always provide a context so that e.g. fmods can store data.
+        this.context = context != null ? context : Context.create() ;

Review Comment:
   Endpoints come from Endpoint.Builder - e.g. 
FusekiServer.serviceEndpointOperation - this decision could be in the builder.
   



##########
jena-arq/src/main/java/org/apache/jena/http/sys/ExecHTTPBuilder.java:
##########
@@ -44,7 +45,7 @@ public abstract class ExecHTTPBuilder<X, Y> {
     protected String serviceURL = null;
     private Query query = null;
     protected String queryString = null;
-    protected boolean parseCheck = true;
+    protected Boolean parseCheck = null;

Review Comment:
   `Optional`?



##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryExceptionHTTP.java:
##########
@@ -44,12 +46,16 @@ public static QueryExceptionHTTP rewrap(HttpException 
httpEx) {
         // Therefore we need to wrap appropriately
         int responseCode = httpEx.getStatusCode();
         if (responseCode != -1) {
-            // Was an actual HTTP error
-            String responseLine = httpEx.getStatusLine() != null ? 
httpEx.getStatusLine() : HttpSC.getMessage(responseCode);
+            // Was an actual HTTP error. Enrich the message with the first 
line of the HTTP response.
+            String responseLine
+                = (httpEx.getStatusLine() != null ? httpEx.getStatusLine() : 
HttpSC.getMessage(responseCode))
+                + extractResponseLine(": ", httpEx.getResponse())
+                ;

Review Comment:
   This line wraps at odd points. IMO Splitting at `?` and `:` shows the 
structure.
   
   One way:
   ```suggestion
               String responseLine = (httpEx.getStatusLine() != null 
                   ? httpEx.getStatusLine()
                   : HttpSC.getMessage(responseCode)) + extractResponseLine(": 
", httpEx.getResponse()) ;
   ```



##########
jena-arq/src/main/java/org/apache/jena/http/HttpLib.java:
##########
@@ -640,25 +650,53 @@ public static HttpResponse<InputStream> 
executeJDK(HttpClient httpClient, HttpRe
      * @return HttpResponse
      */
     public static <T> HttpResponse<T> executeJDK(HttpClient httpClient, 
HttpRequest httpRequest, BodyHandler<T> bodyHandler) {
-        try {
-            // This is the one place all HTTP requests go through.
-            logRequest(httpRequest);
-            HttpResponse<T> httpResponse = httpClient.send(httpRequest, 
bodyHandler);
-            logResponse(httpResponse);
-            return httpResponse;
-        //} catch (HttpTimeoutException ex) {
-        } catch (IOException | InterruptedException ex) {
-            if ( ex.getMessage() != null ) {
-                // This is silly.
-                // Rather than an HTTP exception, bad authentication becomes 
IOException("too many authentication attempts");
-                // or IOException("No credentials provided") if the 
authenticator decides to return null.
-                if ( ex.getMessage().contains("too many authentication 
attempts") ||
-                     ex.getMessage().contains("No credentials provided") ) {
-                    throw new HttpException(401, HttpSC.getMessage(401));
+        return AsyncHttpRDF.getOrElseThrow(executeJDKAsync(httpClient, 
httpRequest, bodyHandler));
+    }
+
+    /**
+     * Execute request and return a {@code HttpResponse<InputStream>} response.
+     * Status codes have not been handled. The response can be passed to
+     * {@link #handleResponseInputStream(HttpResponse)} which will convert 
non-2xx
+     * status code to {@link HttpException HttpExceptions}.
+     *
+     * @param httpClient
+     * @param httpRequest
+     * @return HttpResponse
+     */
+    public static CompletableFuture<HttpResponse<InputStream>> 
executeJDKAsync(HttpClient httpClient, HttpRequest httpRequest) {

Review Comment:
   I don't think we need this.
   
   `executeJDK*` is a system primitive and havign one operation (+ non-async) 
makes that clearer IMO.



##########
jena-arq/src/main/java/org/apache/jena/riot/system/StreamRDFOps.java:
##########
@@ -104,6 +104,11 @@ public static void sendGraphToStream(Graph graph, 
StreamRDF stream, String baseU
             stream.base(baseURI);
         if ( prefixMap != null )
             sendPrefixesToStream(prefixMap, stream) ;
+        sendGraphTriplesToStream(graph, stream);
+    }
+
+    /** Send only the triples of graph to a StreamRDF */
+    public static void sendGraphTriplesToStream(Graph graph, StreamRDF stream) 
{

Review Comment:
   This duplictates `sendTriplesToStream`.
   
   Suggestion - move the triples sending code to `sendTriplesToStream`, call 
`sendTriplesToStream` from `sendGraphToStream(graph, stream, base, prefixes)` 
and drop `sendGraphToStream(graph, stream)`.
   
   To me, `sendGraphToStream(graph, stream)` does implies all the graph is sent 
- but the prefixes aren't which is why its `sendTriplesToStream`.



##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/dispatch/ChainingQueryDispatcher.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine.dispatch;
+
+import org.apache.jena.query.Query;
+import org.apache.jena.query.Syntax;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.util.Context;
+
+public interface ChainingQueryDispatcher {

Review Comment:
   Some explantory jaavdoc, please.



##########
jena-examples/src/main/java/arq/examples/ExampleDBpediaViaRemoteDataset.java:
##########
@@ -0,0 +1,43 @@
+package arq.examples;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.jena.rdflink.RDFLinkHTTP;
+import org.apache.jena.rdflink.dataset.DatasetGraphOverRDFLink;
+import org.apache.jena.sparql.algebra.Table;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.engine.dispatch.SparqlDispatcherRegistry;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.RowSetOps;
+
+/**
+ * An example that sends a query to the DBpedia endpoint via the {@link 
DatasetGraphOverRDFLink} abstraction.
+ * Technically, the query is passed through Jena's default {@link 
SparqlDispatcherRegistry}.
+ */
+public class ExampleDBpediaViaRemoteDataset {
+    public static void main(String... argv) {
+        // The query string is sent to the DBpedia endpoint as is (without 
parsing).
+        // By default, Jena would fail to parse it because of the undeclared 
prefixes.

Review Comment:
   > By default it makes sense to apply parse check immediately when a 
conventional Jena dataset is involved.
   
   Right - `QueryExec.queryString` could default to calling `QueryExec.query`, 
while the remote case has bypass behaviour.
   
   At sometime (!!) maybe there'll be different local query engines.
   



##########
jena-arq/src/main/java/org/apache/jena/sparql/engine/dispatch/ChainingUpdateDispatcher.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.engine.dispatch;
+
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.exec.UpdateExec;
+import org.apache.jena.sparql.util.Context;
+import org.apache.jena.update.UpdateRequest;
+
+public interface ChainingUpdateDispatcher {

Review Comment:
   Some explantory jaavdoc, please.



##########
jena-rdfconnection/src/test/java/org/apache/jena/rdflink/TestGraphOverRDFLink.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.rdflink;
+
+import java.util.Iterator;
+
+import org.apache.jena.atlas.iterator.Iter;
+import org.apache.jena.rdflink.dataset.DatasetGraphOverRDFLink;
+import org.apache.jena.sparql.algebra.Table;
+import org.apache.jena.sparql.algebra.TableFactory;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.exec.QueryExec;
+import org.apache.jena.sparql.exec.RowSet;
+
+/** TODO Get rid of dependency to external service. */
+public class TestGraphOverRDFLink {

Review Comment:
   Feel free to remove it.



##########
jena-arq/src/main/java/org/apache/jena/sparql/modify/UpdateProcessorBase.java:
##########
@@ -70,6 +71,17 @@ public UpdateProcessorBase(UpdateRequest request,
         }
     }
 
+    @Override
+    public UpdateRequest getUpdateRequest() {
+        // XXX Return a copy for safety?

Review Comment:
   Decide on the contract!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to