Aklakan commented on code in PR #3027:
URL: https://github.com/apache/jena/pull/3027#discussion_r2060331368


##########
jena-fuseki2/jena-fuseki-mod-geosparql/src/main/java/org/apache/jena/fuseki/mod/geosparql/FMod_SpatialIndexer.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.fuseki.mod.geosparql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.auth.AuthPolicy;
+import org.apache.jena.fuseki.main.FusekiServer;
+import org.apache.jena.fuseki.main.sys.FusekiAutoModule;
+import org.apache.jena.fuseki.server.DataAccessPoint;
+import org.apache.jena.fuseki.server.DataAccessPointRegistry;
+import org.apache.jena.fuseki.server.DataService;
+import org.apache.jena.fuseki.server.Endpoint;
+import org.apache.jena.fuseki.server.Operation;
+import org.apache.jena.rdf.model.Model;
+
+public class FMod_SpatialIndexer implements FusekiAutoModule {
+
+    private Operation spatialOperation = null;
+
+    public Operation getOperation() {
+        if (spatialOperation == null) {
+            synchronized (this) {
+                if (spatialOperation == null) {
+                    Fuseki.configLog.info(name() + ": Add spatial indexer 
operation into global registry.");
+                    spatialOperation = 
Operation.alloc("http://org.apache.jena/spatial-index-service";,
+                            "spatial-indexer",
+                            "Spatial index computation service");
+                }
+            }
+        }
+        return spatialOperation;
+    }
+
+    public FMod_SpatialIndexer() {
+        super();
+    }
+
+    @Override
+    public String name() {
+        return "Spatial Indexer";
+    }
+
+    @Override
+    public void start() {
+    }
+
+    @Override
+    public void prepare(FusekiServer.Builder builder, Set<String> 
datasetNames, Model configModel) {
+        Fuseki.configLog.info(name() + ": Module adds spatial index servlet");
+        Operation op = getOperation();
+        builder.registerOperation(op, new SpatialIndexComputeService());
+
+        // This does not appear to do anything - datasetNames may be empty but 
data access points may exist.
+        // datasetNames.forEach(name -> builder.addEndpoint(name, "spatial", 
op));
+        // datasetNames.forEach(name -> builder.addEndpoint(name, 
"spatial-events", op));
+    }
+
+    /**
+     * The indexer is only created if there is a SPARQL update endpoint. The 
update endpoint's auth policy is inherited.
+     */
+    @Override
+    public void configured(FusekiServer.Builder serverBuilder, 
DataAccessPointRegistry dapRegistry, Model configModel) {

Review Comment:
   One important point is how to handle authentication to the spatial indexer 
servlet as to prevent service disruption by index recomputation requests. The 
logic below only registers the indexer servlet for a data access point if there 
are update endpoints with at most 1 auth policy. The auth policy is then 
inherited for the spatial indexer.
   
   In other words, multiple update endpoints with multiple auth policies 
prevent spatial indexer registration. In this case, the indexer would have to 
be manually configured in the fuseki config. Alternatively, for each update 
endpoint there could be a updateName-spatial endpoint which inherits that 
update's endpoint auth policy.
   
   
   



-- 
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: pr-unsubscr...@jena.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org
For additional commands, e-mail: pr-h...@jena.apache.org

Reply via email to