You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "afs (via GitHub)" <gi...@apache.org> on 2024/04/08 21:39:34 UTC

[PR] GH-2392: Fuseki context setting [jena]

afs opened a new pull request, #2406:
URL: https://github.com/apache/jena/pull/2406

   A few things got mixed together. For consistency, this is one PR.
   
   GitHub issue resolved #2392 -- allow setting on contextPath
   GitHub issue resolved #2393 -- remove the unused system database
   
   Default TDB database to TDB2 which makes it follow what the UI does.
   Clearing up in passing.
   
   ----
   
   By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
   


-- 
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-unsubscribe@jena.apache.org

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


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


Re: [PR] GH-2392: Fuseki context setting [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2406:
URL: https://github.com/apache/jena/pull/2406#discussion_r1557912035


##########
jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java:
##########
@@ -136,110 +125,111 @@ protected JsonValue execPostContainer(HttpAction action) {
 
         boolean committed = false;
         // Also acts as a concurrency lock
-        system.begin(ReadWrite.WRITE);
-        String systemFileCopy = null;
-        String configFile = null;
-
-        try {
-            // Where to build the templated service/database.
-            Model modelData = ModelFactory.createDefaultModel();
-            StreamRDF dest = StreamRDFLib.graph(modelData.getGraph());
-
-            if ( hasParams || WebContent.isHtmlForm(ct) )
-                assemblerFromForm(action, dest);
-            else if ( WebContent.isMultiPartForm(ct) )
-                assemblerFromUpload(action, dest);
-            else
-                assemblerFromBody(action, dest);
-
-            Model model = ModelFactory.createDefaultModel();
-            model.add(modelData);
-            AssemblerUtils.addRegistered(model);
-
-            // ----
-            // Keep a persistent copy immediately.  This is not used for
-            // anything other than being "for the record".
-            systemFileCopy = FusekiWebapp.dirSystemFileArea.resolve(uuid.toString()).toString();
-            try ( OutputStream outCopy = IO.openOutputFile(systemFileCopy) ) {
-                RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
-            }
-            // ----
-            // Process configuration.
-
-            // Returns the "service fu:name NAME" statement
-            Statement stmt = findService(model);
-
-            Resource subject = stmt.getSubject();
-            Literal object = stmt.getObject().asLiteral();
-
-            if ( object.getDatatype() != null && ! object.getDatatype().equals(XSDDatatype.XSDstring) )
-                action.log.warn(format("[%d] Service name '%s' is not a string", action.id, FmtUtils.stringForRDFNode(object)));
-
-            String datasetPath;
-            {   // Check the name provided.
-                String datasetName = object.getLexicalForm();
-                // This duplicates the code FusekiBuilder.buildDataAccessPoint to give better error messages and HTTP status code."
-
-                // ---- Check and canonicalize name.
-                if ( datasetName.isEmpty() )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, "Empty dataset name");
-                if ( StringUtils.isBlank(datasetName) )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, format("Whitespace dataset name: '%s'", datasetName));
-                if ( datasetName.contains(" ") )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name (contains spaces) '%s'",datasetName));
-                if ( datasetName.equals("/") )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name '%s'",datasetName));
-                datasetPath = DataAccessPoint.canonical(datasetName);
-                // ---- Check whether it already exists
-                if ( action.getDataAccessPointRegistry().isRegistered(datasetPath) )
-                    // And abort.
-                    ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath);
-            }
+        synchronized(lock) {
+            String systemFileCopy = null;
+            String configFile = null;
 
-            action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath));
+            try {
+                // Where to build the templated service/database.
+                Model modelData = ModelFactory.createDefaultModel();
+                StreamRDF dest = StreamRDFLib.graph(modelData.getGraph());
+
+                if ( hasParams || WebContent.isHtmlForm(ct) )
+                    assemblerFromForm(action, dest);
+                else if ( WebContent.isMultiPartForm(ct) )
+                    assemblerFromUpload(action, dest);
+                else
+                    assemblerFromBody(action, dest);
+
+                Model model = ModelFactory.createDefaultModel();
+                model.add(modelData);
+                AssemblerUtils.addRegistered(model);
+
+                // ----
+                // Keep a persistent copy immediately.  This is not used for
+                // anything other than being "for the record".
+                systemFileCopy = FusekiWebapp.dirSystemFileArea.resolve(uuid.toString()).toString();
+                try ( OutputStream outCopy = IO.openOutputFile(systemFileCopy) ) {
+                    RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
+                }
+                // ----
+                // Process configuration.
+
+                // Returns the "service fu:name NAME" statement
+                Statement stmt = findService(model);
+
+                Resource subject = stmt.getSubject();
+                Literal object = stmt.getObject().asLiteral();
+
+                if ( object.getDatatype() != null && ! object.getDatatype().equals(XSDDatatype.XSDstring) )
+                    action.log.warn(format("[%d] Service name '%s' is not a string", action.id, FmtUtils.stringForRDFNode(object)));
+
+                String datasetPath;
+                {   // Check the name provided.
+                    String datasetName = object.getLexicalForm();
+                    // This duplicates the code FusekiBuilder.buildDataAccessPoint to give better error messages and HTTP status code."
+
+                    // ---- Check and canonicalize name.
+                    if ( datasetName.isEmpty() )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, "Empty dataset name");
+                    if ( StringUtils.isBlank(datasetName) )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, format("Whitespace dataset name: '%s'", datasetName));
+                    if ( datasetName.contains(" ") )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name (contains spaces) '%s'",datasetName));
+                    if ( datasetName.equals("/") )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name '%s'",datasetName));
+                    datasetPath = DataAccessPoint.canonical(datasetName);
+                    // ---- Check whether it already exists
+                    if ( action.getDataAccessPointRegistry().isRegistered(datasetPath) )
+                        // And abort.
+                        ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath);
+                }
 
-            configFile = FusekiWebapp.generateConfigurationFilename(datasetPath);
-            List<String> existing = FusekiWebapp.existingConfigurationFile(datasetPath);
-            if ( ! existing.isEmpty() )
-                ServletOps.error(HttpSC.CONFLICT_409, "Configuration file for '"+datasetPath+"' already exists");
+                action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath));
 
-            // Write to configuration directory.
-            try ( OutputStream outCopy = IO.openOutputFile(configFile) ) {
-                RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
-            }
+                configFile = FusekiWebapp.generateConfigurationFilename(datasetPath);
+                List<String> existing = FusekiWebapp.existingConfigurationFile(datasetPath);
+                if ( ! existing.isEmpty() )
+                    ServletOps.error(HttpSC.CONFLICT_409, "Configuration file for '"+datasetPath+"' already exists");
 
-            // Currently do nothing with the system database.
-            // In the future ... maybe ...
+                // Write to configuration directory.
+                try ( OutputStream outCopy = IO.openOutputFile(configFile) ) {
+                    RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
+                }
+
+                // Currently do nothing with the system database.
+                // In the future ... maybe ...

Review Comment:
   Yes - removed.



-- 
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-unsubscribe@jena.apache.org

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


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


Re: [PR] GH-2392: Fuseki context setting [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2406:
URL: https://github.com/apache/jena/pull/2406#discussion_r1557914418


##########
jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java:
##########
@@ -381,10 +331,8 @@ protected void execDeleteItem(HttpAction action) {
             if  ( configurationFiles.size() > 1 ) {
                 // -- This should not happen.
                 action.log.warn(format("[%d] There are %d configuration files, not one.", action.id, configurationFiles.size()));
-                ServletOps.errorOccurred(
-                    format(
-                        "There are %d configuration files, not one. Delete not performed; clearup of the filesystem needed.",
-                        configurationFiles.size()));
+                ServletOps.errorOccurred(format("There are %d configuration files, not one. Delete not performed; clearup of the filesystem needed.",

Review Comment:
   Done as part of final prepartion.



-- 
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-unsubscribe@jena.apache.org

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


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


Re: [PR] GH-2392: Fuseki context setting [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs merged PR #2406:
URL: https://github.com/apache/jena/pull/2406


-- 
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-unsubscribe@jena.apache.org

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


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


Re: [PR] GH-2392: Fuseki context setting [jena]

Posted by "rvesse (via GitHub)" <gi...@apache.org>.
rvesse commented on code in PR #2406:
URL: https://github.com/apache/jena/pull/2406#discussion_r1557288647


##########
jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java:
##########
@@ -381,10 +331,8 @@ protected void execDeleteItem(HttpAction action) {
             if  ( configurationFiles.size() > 1 ) {
                 // -- This should not happen.
                 action.log.warn(format("[%d] There are %d configuration files, not one.", action.id, configurationFiles.size()));
-                ServletOps.errorOccurred(
-                    format(
-                        "There are %d configuration files, not one. Delete not performed; clearup of the filesystem needed.",
-                        configurationFiles.size()));
+                ServletOps.errorOccurred(format("There are %d configuration files, not one. Delete not performed; clearup of the filesystem needed.",

Review Comment:
   ```suggestion
                   ServletOps.errorOccurred(format("There are %d configuration files, not one. Delete not performed; manual clean up of the filesystem needed.",
   ```



##########
jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java:
##########
@@ -136,110 +125,111 @@ protected JsonValue execPostContainer(HttpAction action) {
 
         boolean committed = false;
         // Also acts as a concurrency lock
-        system.begin(ReadWrite.WRITE);
-        String systemFileCopy = null;
-        String configFile = null;
-
-        try {
-            // Where to build the templated service/database.
-            Model modelData = ModelFactory.createDefaultModel();
-            StreamRDF dest = StreamRDFLib.graph(modelData.getGraph());
-
-            if ( hasParams || WebContent.isHtmlForm(ct) )
-                assemblerFromForm(action, dest);
-            else if ( WebContent.isMultiPartForm(ct) )
-                assemblerFromUpload(action, dest);
-            else
-                assemblerFromBody(action, dest);
-
-            Model model = ModelFactory.createDefaultModel();
-            model.add(modelData);
-            AssemblerUtils.addRegistered(model);
-
-            // ----
-            // Keep a persistent copy immediately.  This is not used for
-            // anything other than being "for the record".
-            systemFileCopy = FusekiWebapp.dirSystemFileArea.resolve(uuid.toString()).toString();
-            try ( OutputStream outCopy = IO.openOutputFile(systemFileCopy) ) {
-                RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
-            }
-            // ----
-            // Process configuration.
-
-            // Returns the "service fu:name NAME" statement
-            Statement stmt = findService(model);
-
-            Resource subject = stmt.getSubject();
-            Literal object = stmt.getObject().asLiteral();
-
-            if ( object.getDatatype() != null && ! object.getDatatype().equals(XSDDatatype.XSDstring) )
-                action.log.warn(format("[%d] Service name '%s' is not a string", action.id, FmtUtils.stringForRDFNode(object)));
-
-            String datasetPath;
-            {   // Check the name provided.
-                String datasetName = object.getLexicalForm();
-                // This duplicates the code FusekiBuilder.buildDataAccessPoint to give better error messages and HTTP status code."
-
-                // ---- Check and canonicalize name.
-                if ( datasetName.isEmpty() )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, "Empty dataset name");
-                if ( StringUtils.isBlank(datasetName) )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, format("Whitespace dataset name: '%s'", datasetName));
-                if ( datasetName.contains(" ") )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name (contains spaces) '%s'",datasetName));
-                if ( datasetName.equals("/") )
-                    ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name '%s'",datasetName));
-                datasetPath = DataAccessPoint.canonical(datasetName);
-                // ---- Check whether it already exists
-                if ( action.getDataAccessPointRegistry().isRegistered(datasetPath) )
-                    // And abort.
-                    ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath);
-            }
+        synchronized(lock) {
+            String systemFileCopy = null;
+            String configFile = null;
 
-            action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath));
+            try {
+                // Where to build the templated service/database.
+                Model modelData = ModelFactory.createDefaultModel();
+                StreamRDF dest = StreamRDFLib.graph(modelData.getGraph());
+
+                if ( hasParams || WebContent.isHtmlForm(ct) )
+                    assemblerFromForm(action, dest);
+                else if ( WebContent.isMultiPartForm(ct) )
+                    assemblerFromUpload(action, dest);
+                else
+                    assemblerFromBody(action, dest);
+
+                Model model = ModelFactory.createDefaultModel();
+                model.add(modelData);
+                AssemblerUtils.addRegistered(model);
+
+                // ----
+                // Keep a persistent copy immediately.  This is not used for
+                // anything other than being "for the record".
+                systemFileCopy = FusekiWebapp.dirSystemFileArea.resolve(uuid.toString()).toString();
+                try ( OutputStream outCopy = IO.openOutputFile(systemFileCopy) ) {
+                    RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
+                }
+                // ----
+                // Process configuration.
+
+                // Returns the "service fu:name NAME" statement
+                Statement stmt = findService(model);
+
+                Resource subject = stmt.getSubject();
+                Literal object = stmt.getObject().asLiteral();
+
+                if ( object.getDatatype() != null && ! object.getDatatype().equals(XSDDatatype.XSDstring) )
+                    action.log.warn(format("[%d] Service name '%s' is not a string", action.id, FmtUtils.stringForRDFNode(object)));
+
+                String datasetPath;
+                {   // Check the name provided.
+                    String datasetName = object.getLexicalForm();
+                    // This duplicates the code FusekiBuilder.buildDataAccessPoint to give better error messages and HTTP status code."
+
+                    // ---- Check and canonicalize name.
+                    if ( datasetName.isEmpty() )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, "Empty dataset name");
+                    if ( StringUtils.isBlank(datasetName) )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, format("Whitespace dataset name: '%s'", datasetName));
+                    if ( datasetName.contains(" ") )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name (contains spaces) '%s'",datasetName));
+                    if ( datasetName.equals("/") )
+                        ServletOps.error(HttpSC.BAD_REQUEST_400, format("Bad dataset name '%s'",datasetName));
+                    datasetPath = DataAccessPoint.canonical(datasetName);
+                    // ---- Check whether it already exists
+                    if ( action.getDataAccessPointRegistry().isRegistered(datasetPath) )
+                        // And abort.
+                        ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath);
+                }
 
-            configFile = FusekiWebapp.generateConfigurationFilename(datasetPath);
-            List<String> existing = FusekiWebapp.existingConfigurationFile(datasetPath);
-            if ( ! existing.isEmpty() )
-                ServletOps.error(HttpSC.CONFLICT_409, "Configuration file for '"+datasetPath+"' already exists");
+                action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath));
 
-            // Write to configuration directory.
-            try ( OutputStream outCopy = IO.openOutputFile(configFile) ) {
-                RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
-            }
+                configFile = FusekiWebapp.generateConfigurationFilename(datasetPath);
+                List<String> existing = FusekiWebapp.existingConfigurationFile(datasetPath);
+                if ( ! existing.isEmpty() )
+                    ServletOps.error(HttpSC.CONFLICT_409, "Configuration file for '"+datasetPath+"' already exists");
 
-            // Currently do nothing with the system database.
-            // In the future ... maybe ...
+                // Write to configuration directory.
+                try ( OutputStream outCopy = IO.openOutputFile(configFile) ) {
+                    RDFDataMgr.write(outCopy, modelData, Lang.TURTLE);
+                }
+
+                // Currently do nothing with the system database.
+                // In the future ... maybe ...

Review Comment:
   Leftover system database reference needs removal?



-- 
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-unsubscribe@jena.apache.org

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


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