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: [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]