You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/07/12 16:39:51 UTC
[01/12] jena git commit: Transaction around system database access.
Repository: jena
Updated Branches:
refs/heads/master 5d22a0c90 -> 80dbb451f
Transaction around system database access.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ff732872
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ff732872
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ff732872
Branch: refs/heads/master
Commit: ff732872a9bc4f5debfea069505d08c7ebda601a
Parents: dbdfb92
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:04:59 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:04:59 2015 +0100
----------------------------------------------------------------------
.../apache/jena/fuseki/build/FusekiConfig.java | 45 +++++++++++---------
1 file changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/ff732872/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
index 4fe19ea..8bfa469 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
@@ -43,6 +43,7 @@ import org.apache.jena.fuseki.server.FusekiVocab ;
import org.apache.jena.fuseki.server.SystemState ;
import org.apache.jena.query.Dataset ;
import org.apache.jena.query.QuerySolution ;
+import org.apache.jena.query.ReadWrite ;
import org.apache.jena.query.ResultSet ;
import org.apache.jena.rdf.model.* ;
import org.apache.jena.riot.RDFDataMgr ;
@@ -263,25 +264,29 @@ public class FusekiConfig {
List<DataAccessPoint> refs = new ArrayList<>() ;
- ResultSet rs = FusekiLib.query(qs, ds) ;
-
-// ResultSetFormatter.out(rs);
-// ((ResultSetRewindable)rs).reset();
-
- for ( ; rs.hasNext() ; ) {
- QuerySolution row = rs.next() ;
- Resource s = row.getResource("s") ;
- Resource g = row.getResource("g") ;
- Resource rStatus = row.getResource("status") ;
- //String name = row.getLiteral("name").getLexicalForm() ;
- DatasetStatus status = DatasetStatus.status(rStatus) ;
-
- Model m = ds.getNamedModel(g.getURI()) ;
- // Rebase the resoure of the service description to the containing graph.
- Resource svc = m.wrapAsResource(s.asNode()) ;
- DataAccessPoint ref = Builder.buildDataAccessPoint(svc) ;
- refs.add(ref) ;
- }
- return refs ;
+ ds.begin(ReadWrite.WRITE) ;
+ try {
+ ResultSet rs = FusekiLib.query(qs, ds) ;
+
+ // ResultSetFormatter.out(rs);
+ // ((ResultSetRewindable)rs).reset();
+
+ for ( ; rs.hasNext() ; ) {
+ QuerySolution row = rs.next() ;
+ Resource s = row.getResource("s") ;
+ Resource g = row.getResource("g") ;
+ Resource rStatus = row.getResource("status") ;
+ //String name = row.getLiteral("name").getLexicalForm() ;
+ DatasetStatus status = DatasetStatus.status(rStatus) ;
+
+ Model m = ds.getNamedModel(g.getURI()) ;
+ // Rebase the resoure of the service description to the containing graph.
+ Resource svc = m.wrapAsResource(s.asNode()) ;
+ DataAccessPoint ref = Builder.buildDataAccessPoint(svc) ;
+ refs.add(ref) ;
+ }
+ ds.commit();
+ return refs ;
+ } finally { ds.end() ; }
}
}
[05/12] jena git commit: JENA-980: Switch to configuration directory
for UI created datasets.
Posted by an...@apache.org.
JENA-980: Switch to configuration directory for UI created datasets.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/c0d3b1c4
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/c0d3b1c4
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/c0d3b1c4
Branch: refs/heads/master
Commit: c0d3b1c4f9ef948b5d7888ac9fea98eb57a7dc8a
Parents: 8aa643f
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:09:13 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:17:06 2015 +0100
----------------------------------------------------------------------
.../apache/jena/fuseki/mgt/ActionDatasets.java | 136 +++++++++++++++++--
1 file changed, 121 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/c0d3b1c4/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
index e28c2ba..fd612ca 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse ;
import org.apache.jena.atlas.io.IO ;
import org.apache.jena.atlas.json.JsonBuilder ;
import org.apache.jena.atlas.json.JsonValue ;
+import org.apache.jena.atlas.lib.FileOps ;
import org.apache.jena.atlas.lib.InternalErrorException ;
import org.apache.jena.atlas.lib.StrUtils ;
import org.apache.jena.atlas.web.ContentType ;
@@ -118,6 +119,7 @@ public class ActionDatasets extends ActionContainerItem {
// ---- POST
+ // DB less version
@Override
protected JsonValue execPostContainer(HttpAction action) {
JenaUUID uuid = JenaUUID.generate() ;
@@ -127,9 +129,14 @@ public class ActionDatasets extends ActionContainerItem {
ContentType ct = FusekiLib.getContentType(action) ;
boolean committed = false ;
+ // Also acts as a concurrency lock
system.begin(ReadWrite.WRITE) ;
+ String filename1 = null ;
+ String filename2 = null ;
+
try {
- Model model = system.getNamedModel(gn.getURI()) ;
+ // Where to build the templated service/database.
+ Model model = ModelFactory.createDefaultModel() ;
StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
if ( WebContent.isHtmlForm(ct) )
@@ -139,12 +146,13 @@ public class ActionDatasets extends ActionContainerItem {
else
assemblerFromBody(action, dest) ;
- // Keep a persistent copy.
- String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
- try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+ // Keep a persistent copy imediately. This is not used for
+ // anything other than being "for the record".
+ filename1 = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
+ try ( OutputStream outCopy = IO.openOutputFile(filename1) ) {
RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
}
-
+
Statement stmt = getOne(model, null, pServiceName, null) ;
if ( stmt == null ) {
StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null ) ;
@@ -158,13 +166,13 @@ public class ActionDatasets extends ActionContainerItem {
if ( ! stmt.getObject().isLiteral() )
ServletOps.errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" : Service names are strings, then used to build the external URI") ;
-
+
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 datasetName = object.getLexicalForm() ;
String datasetPath = DataAccessPoint.canonical(datasetName) ;
action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;
@@ -172,27 +180,120 @@ public class ActionDatasets extends ActionContainerItem {
if ( DataAccessPointRegistry.get().isRegistered(datasetPath) )
// And abort.
ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath) ;
-
- model.removeAll(null, pStatus, null) ;
- model.add(subject, pStatus, FusekiVocab.stateActive) ;
+
+ // Copy to the configuration directory for server start up next time.
+ filename2 = datasetPath.substring(1) ; // Without "/"
+ filename2 = FusekiServer.dirConfiguration.resolve(filename2).toString()+".ttl" ;
+ if ( FileOps.exists(filename2) )
+ ServletOps.error(HttpSC.INTERNAL_SERVER_ERROR_500, "Configuration file of that name already exists "+filename2) ;
+
+ try ( OutputStream outCopy = IO.openOutputFile(filename2) ) {
+ RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+ }
+
+ // Currently do nothing with the system database.
+ // In the future ... maybe ...
+// Model modelSys = system.getNamedModel(gn.getURI()) ;
+// modelSys.removeAll(null, pStatus, null) ;
+// modelSys.add(subject, pStatus, FusekiVocab.stateActive) ;
// Need to be in Resource space at this point.
DataAccessPoint ref = Builder.buildDataAccessPoint(subject) ;
DataAccessPointRegistry.register(datasetPath, ref) ;
action.getResponse().setContentType(WebContent.contentTypeTextPlain);
ServletOutputStream out = action.getResponse().getOutputStream() ;
- out.println("That went well") ;
ServletOps.success(action) ;
system.commit();
committed = true ;
} catch (IOException ex) { IO.exception(ex); }
finally {
- if ( ! committed ) system.abort() ;
+ if ( ! committed ) {
+ if ( filename1 != null ) FileOps.deleteSilent(filename1);
+ if ( filename2 != null ) FileOps.deleteSilent(filename2);
+ system.abort() ;
+ }
system.end() ;
}
return null ;
}
+
+// //@Override
+// // The system database version.
+// // Keep for easy replacement until comfortable new way is stable.
+// protected JsonValue execPostContainer1(HttpAction action) {
+// JenaUUID uuid = JenaUUID.generate() ;
+// String newURI = uuid.asURI() ;
+// Node gn = NodeFactory.createURI(newURI) ;
+//
+// ContentType ct = FusekiLib.getContentType(action) ;
+//
+// boolean committed = false ;
+// system.begin(ReadWrite.WRITE) ;
+// try {
+// Model model = system.getNamedModel(gn.getURI()) ;
+// StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
+//
+// if ( WebContent.isHtmlForm(ct) )
+// assemblerFromForm(action, dest) ;
+// else if ( WebContent.isMultiPartForm(ct) )
+// assemblerFromUpload(action, dest) ;
+// else
+// assemblerFromBody(action, dest) ;
+//
+// // Keep a persistent copy.
+// String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
+// try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+// RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+// }
+//
+// Statement stmt = getOne(model, null, pServiceName, null) ;
+// if ( stmt == null ) {
+// StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null ) ;
+// if ( ! sIter.hasNext() )
+// ServletOps.errorBadRequest("No name given in description of Fuseki service") ;
+// sIter.next() ;
+// if ( sIter.hasNext() )
+// ServletOps.errorBadRequest("Multiple names given in description of Fuseki service") ;
+// throw new InternalErrorException("Inconsistent: getOne didn't fail the second time") ;
+// }
+//
+// if ( ! stmt.getObject().isLiteral() )
+// ServletOps.errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" : Service names are strings, then used to build the external URI") ;
+//
+// 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 datasetName = object.getLexicalForm() ;
+// String datasetPath = DataAccessPoint.canonical(datasetName) ;
+// action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;
+//
+// if ( DataAccessPointRegistry.get().isRegistered(datasetPath) )
+// // And abort.
+// ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath) ;
+//
+// model.removeAll(null, pStatus, null) ;
+// model.add(subject, pStatus, FusekiVocab.stateActive) ;
+//
+// // Need to be in Resource space at this point.
+// DataAccessPoint ref = Builder.buildDataAccessPoint(subject) ;
+// DataAccessPointRegistry.register(datasetPath, ref) ;
+// action.getResponse().setContentType(WebContent.contentTypeTextPlain);
+// ServletOutputStream out = action.getResponse().getOutputStream() ;
+// ServletOps.success(action) ;
+// system.commit();
+// committed = true ;
+//
+// } catch (IOException ex) { IO.exception(ex); }
+// finally {
+// if ( ! committed ) system.abort() ;
+// system.end() ;
+// }
+// return null ;
+// }
@Override
protected JsonValue execPostItem(HttpAction action) {
@@ -247,13 +348,18 @@ public class ActionDatasets extends ActionContainerItem {
private void assemblerFromForm(HttpAction action, StreamRDF dest) {
String dbType = action.getRequest().getParameter(paramDatasetType) ;
String dbName = action.getRequest().getParameter(paramDatasetName) ;
+ if ( dbType == null || dbName == null )
+ ServletOps.errorBadRequest("Required parameters: dbName and dbType");
+
Map<String, String> params = new HashMap<>() ;
- params.put(Template.NAME, dbName) ;
+
+ if ( dbName.startsWith("/") )
+ params.put(Template.NAME, dbName.substring(1)) ;
+ else
+ params.put(Template.NAME, dbName) ;
FusekiServer.addGlobals(params);
//action.log.info(format("[%d] Create database : name = %s, type = %s", action.id, dbName, dbType )) ;
- if ( dbType == null || dbName == null )
- ServletOps.errorBadRequest("Required parameters: dbName and dbType");
if ( ! dbType.equals(tDatabasetTDB) && ! dbType.equals(tDatabasetMem) )
ServletOps.errorBadRequest(format("dbType can be only '%s' or '%s'", tDatabasetTDB, tDatabasetMem)) ;
[10/12] jena git commit: Transaction around system database access.
Posted by an...@apache.org.
Transaction around system database access.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/cf25c96f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/cf25c96f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/cf25c96f
Branch: refs/heads/master
Commit: cf25c96f0abb1ed94e5c046d8d953315e968c020
Parents: 5d22a0c
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:04:59 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jul 12 15:35:28 2015 +0100
----------------------------------------------------------------------
.../apache/jena/fuseki/build/FusekiConfig.java | 45 +++++++++++---------
1 file changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/cf25c96f/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
index 4fe19ea..8bfa469 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
@@ -43,6 +43,7 @@ import org.apache.jena.fuseki.server.FusekiVocab ;
import org.apache.jena.fuseki.server.SystemState ;
import org.apache.jena.query.Dataset ;
import org.apache.jena.query.QuerySolution ;
+import org.apache.jena.query.ReadWrite ;
import org.apache.jena.query.ResultSet ;
import org.apache.jena.rdf.model.* ;
import org.apache.jena.riot.RDFDataMgr ;
@@ -263,25 +264,29 @@ public class FusekiConfig {
List<DataAccessPoint> refs = new ArrayList<>() ;
- ResultSet rs = FusekiLib.query(qs, ds) ;
-
-// ResultSetFormatter.out(rs);
-// ((ResultSetRewindable)rs).reset();
-
- for ( ; rs.hasNext() ; ) {
- QuerySolution row = rs.next() ;
- Resource s = row.getResource("s") ;
- Resource g = row.getResource("g") ;
- Resource rStatus = row.getResource("status") ;
- //String name = row.getLiteral("name").getLexicalForm() ;
- DatasetStatus status = DatasetStatus.status(rStatus) ;
-
- Model m = ds.getNamedModel(g.getURI()) ;
- // Rebase the resoure of the service description to the containing graph.
- Resource svc = m.wrapAsResource(s.asNode()) ;
- DataAccessPoint ref = Builder.buildDataAccessPoint(svc) ;
- refs.add(ref) ;
- }
- return refs ;
+ ds.begin(ReadWrite.WRITE) ;
+ try {
+ ResultSet rs = FusekiLib.query(qs, ds) ;
+
+ // ResultSetFormatter.out(rs);
+ // ((ResultSetRewindable)rs).reset();
+
+ for ( ; rs.hasNext() ; ) {
+ QuerySolution row = rs.next() ;
+ Resource s = row.getResource("s") ;
+ Resource g = row.getResource("g") ;
+ Resource rStatus = row.getResource("status") ;
+ //String name = row.getLiteral("name").getLexicalForm() ;
+ DatasetStatus status = DatasetStatus.status(rStatus) ;
+
+ Model m = ds.getNamedModel(g.getURI()) ;
+ // Rebase the resoure of the service description to the containing graph.
+ Resource svc = m.wrapAsResource(s.asNode()) ;
+ DataAccessPoint ref = Builder.buildDataAccessPoint(svc) ;
+ refs.add(ref) ;
+ }
+ ds.commit();
+ return refs ;
+ } finally { ds.end() ; }
}
}
[02/12] jena git commit: Clear configuration directory on server
reset.
Posted by an...@apache.org.
Clear configuration directory on server reset.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/8aa643fb
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/8aa643fb
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/8aa643fb
Branch: refs/heads/master
Commit: 8aa643fb8af609bb590363237411f55357fb7879
Parents: ff73287
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:08:44 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:08:44 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/jena/fuseki/ServerTest.java | 2 +
.../java/org/apache/jena/fuseki/TestAdmin.java | 61 ++++++++++----------
2 files changed, 32 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/8aa643fb/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
index 0aa7cbf..5e916ac 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
@@ -146,6 +146,8 @@ public class ServerTest {
Collection<String> keys = Iter.toList(DataAccessPointRegistry.get().keys().iterator()) ;
for (String k : keys)
DataAccessPointRegistry.get().remove(k) ;
+ // Clear configuration directory.
+ FileOps.clearAll(FusekiServer.dirConfiguration.toFile()) ;
}
public static void resetServer() {
http://git-wip-us.apache.org/repos/asf/jena/blob/8aa643fb/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
index d5e6ddb..29f74c3 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
@@ -53,9 +53,9 @@ import org.apache.jena.riot.WebContent ;
import org.apache.jena.riot.web.HttpOp ;
import org.apache.jena.riot.web.HttpResponseHandler ;
import org.apache.jena.web.HttpSC ;
+import org.junit.After ;
import org.junit.AfterClass ;
import org.junit.Before ;
-import org.junit.BeforeClass ;
import org.junit.Test ;
/** Tests of the admin functionality */
@@ -64,21 +64,19 @@ public class TestAdmin extends BaseTest {
// Name of the dataset in the assembler file.
static String dsTest = "test-ds2" ;
- @BeforeClass
- public static void beforeClass() {
+ @Before public void beforeTest() {
ServerTest.allocServer() ;
ServerTest.resetServer() ;
}
-
- @AfterClass
- public static void afterClass() {
+
+ @After public void afterTest() {
ServerTest.freeServer() ;
}
-
- @Before public void beforeTest() {
- ServerTest.resetServer() ;
+
+ @AfterClass public static void afterClass() {
+ ServerTest.teardownServer() ;
}
-
+
// --- Ping
@Test public void ping_1() {
@@ -139,27 +137,6 @@ public class TestAdmin extends BaseTest {
checkJsonDatasetsOne(v.getAsObject()) ;
}
- private static JsonValue getDatasetDescription(String dsName) {
- try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+dsName) ) {
- assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
- JsonValue v = JSON.parse(in) ;
- return v ;
- }
- }
-
- // -- Add
-
- private static void addTestDataset() {
- File f = new File("testing/config-ds-1.ttl") ;
- org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
- HttpEntity e = new FileEntity(f, ct) ;
- execHttpPost(ServerTest.urlRoot+"$/"+opDatasets, e) ;
- }
-
- private static void deleteDataset(String name) {
- execHttpDelete(ServerTest.urlRoot+"$/"+opDatasets+"/"+name) ;
- }
-
// Specific dataset
@Test public void add_delete_dataset_1() {
checkNotThere(dsTest) ;
@@ -349,6 +326,28 @@ public class TestAdmin extends BaseTest {
}
+ private static JsonValue getDatasetDescription(String dsName) {
+ try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+dsName) ) {
+ assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
+ JsonValue v = JSON.parse(in) ;
+ return v ;
+ }
+}
+
+// -- Add
+
+private static void addTestDataset() {
+ File f = new File("testing/config-ds-1.ttl") ;
+ org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
+ HttpEntity e = new FileEntity(f, ct) ;
+ execHttpPost(ServerTest.urlRoot+"$/"+opDatasets, e) ;
+}
+
+private static void deleteDataset(String name) {
+ execHttpDelete(ServerTest.urlRoot+"$/"+opDatasets+"/"+name) ;
+}
+
+
static class JsonResponseHandler implements HttpResponseHandler {
private JsonValue result = null ;
[07/12] jena git commit: JENA-982 : CME on DatasetGraphMem.clear
Posted by an...@apache.org.
JENA-982 : CME on DatasetGraphMem.clear
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ed30d387
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ed30d387
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ed30d387
Branch: refs/heads/master
Commit: ed30d38718de4a360d931933946773567bf89c01
Parents: bce5e5b
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 08:58:47 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:17:19 2015 +0100
----------------------------------------------------------------------
.../apache/jena/sparql/core/DatasetGraphCollection.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/ed30d387/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCollection.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCollection.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCollection.java
index 7b66d64..49c04d4 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCollection.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCollection.java
@@ -19,10 +19,11 @@
package org.apache.jena.sparql.core;
import java.util.Iterator ;
-import java.util.Objects;
+import java.util.List ;
+import java.util.Objects ;
import org.apache.jena.atlas.iterator.Iter ;
-import org.apache.jena.atlas.iterator.IteratorConcat;
+import org.apache.jena.atlas.iterator.IteratorConcat ;
import org.apache.jena.graph.Graph ;
import org.apache.jena.graph.Node ;
import org.apache.jena.shared.JenaException ;
@@ -91,9 +92,8 @@ public abstract class DatasetGraphCollection extends DatasetGraphBaseFind
// Delete all triples in the default graph
getDefaultGraph().clear() ;
// Now remove the named graphs (but don't clear them - they may be shared).
- Iterator<Node> gnIter = listGraphNodes() ;
- for ( ; gnIter.hasNext(); ) {
- Node gn = gnIter.next() ;
+ List<Node> gnList = Iter.toList(listGraphNodes()) ;
+ for ( Node gn : gnList ) {
removeGraph(gn) ;
}
}
[06/12] jena git commit: Add Trix to the graph and quads output
formats.
Posted by an...@apache.org.
Add Trix to the graph and quads output formats.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/bce5e5b0
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/bce5e5b0
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/bce5e5b0
Branch: refs/heads/master
Commit: bce5e5b05243147b5ff9463c8a2ad7740eea6c20
Parents: c0d3b1c
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Jul 2 19:59:56 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:17:19 2015 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/jena/fuseki/DEF.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/bce5e5b0/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java
index 8d8495a..b419cc6 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java
@@ -37,6 +37,8 @@ public class DEF
contentTypeNTriples,
contentTypeNTriplesAlt,
contentTypeRDFXML,
+ contentTypeTriX,
+ contentTypeTriXxml,
contentTypeJSONLD,
contentTypeRDFJSON,
contentTypeRDFThrift
@@ -48,7 +50,9 @@ public class DEF
contentTypeJSONLD,
contentTypeNQuads,
contentTypeNQuadsAlt1,
- contentTypeNQuadsAlt2
+ contentTypeNQuadsAlt2,
+ contentTypeTriX,
+ contentTypeTriXxml
) ;
// Offer for SELECT
[03/12] jena git commit: Switch to configuration directory for UI
created datasets.
Posted by an...@apache.org.
Switch to configuration directory for UI created datasets.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/dabd3d29
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/dabd3d29
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/dabd3d29
Branch: refs/heads/master
Commit: dabd3d2936c37091d0ecb6b4e28c9a204b0c168a
Parents: 8aa643f
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:09:13 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:09:13 2015 +0100
----------------------------------------------------------------------
.../apache/jena/fuseki/mgt/ActionDatasets.java | 136 +++++++++++++++++--
1 file changed, 121 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/dabd3d29/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
index e28c2ba..fd612ca 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse ;
import org.apache.jena.atlas.io.IO ;
import org.apache.jena.atlas.json.JsonBuilder ;
import org.apache.jena.atlas.json.JsonValue ;
+import org.apache.jena.atlas.lib.FileOps ;
import org.apache.jena.atlas.lib.InternalErrorException ;
import org.apache.jena.atlas.lib.StrUtils ;
import org.apache.jena.atlas.web.ContentType ;
@@ -118,6 +119,7 @@ public class ActionDatasets extends ActionContainerItem {
// ---- POST
+ // DB less version
@Override
protected JsonValue execPostContainer(HttpAction action) {
JenaUUID uuid = JenaUUID.generate() ;
@@ -127,9 +129,14 @@ public class ActionDatasets extends ActionContainerItem {
ContentType ct = FusekiLib.getContentType(action) ;
boolean committed = false ;
+ // Also acts as a concurrency lock
system.begin(ReadWrite.WRITE) ;
+ String filename1 = null ;
+ String filename2 = null ;
+
try {
- Model model = system.getNamedModel(gn.getURI()) ;
+ // Where to build the templated service/database.
+ Model model = ModelFactory.createDefaultModel() ;
StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
if ( WebContent.isHtmlForm(ct) )
@@ -139,12 +146,13 @@ public class ActionDatasets extends ActionContainerItem {
else
assemblerFromBody(action, dest) ;
- // Keep a persistent copy.
- String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
- try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+ // Keep a persistent copy imediately. This is not used for
+ // anything other than being "for the record".
+ filename1 = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
+ try ( OutputStream outCopy = IO.openOutputFile(filename1) ) {
RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
}
-
+
Statement stmt = getOne(model, null, pServiceName, null) ;
if ( stmt == null ) {
StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null ) ;
@@ -158,13 +166,13 @@ public class ActionDatasets extends ActionContainerItem {
if ( ! stmt.getObject().isLiteral() )
ServletOps.errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" : Service names are strings, then used to build the external URI") ;
-
+
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 datasetName = object.getLexicalForm() ;
String datasetPath = DataAccessPoint.canonical(datasetName) ;
action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;
@@ -172,27 +180,120 @@ public class ActionDatasets extends ActionContainerItem {
if ( DataAccessPointRegistry.get().isRegistered(datasetPath) )
// And abort.
ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath) ;
-
- model.removeAll(null, pStatus, null) ;
- model.add(subject, pStatus, FusekiVocab.stateActive) ;
+
+ // Copy to the configuration directory for server start up next time.
+ filename2 = datasetPath.substring(1) ; // Without "/"
+ filename2 = FusekiServer.dirConfiguration.resolve(filename2).toString()+".ttl" ;
+ if ( FileOps.exists(filename2) )
+ ServletOps.error(HttpSC.INTERNAL_SERVER_ERROR_500, "Configuration file of that name already exists "+filename2) ;
+
+ try ( OutputStream outCopy = IO.openOutputFile(filename2) ) {
+ RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+ }
+
+ // Currently do nothing with the system database.
+ // In the future ... maybe ...
+// Model modelSys = system.getNamedModel(gn.getURI()) ;
+// modelSys.removeAll(null, pStatus, null) ;
+// modelSys.add(subject, pStatus, FusekiVocab.stateActive) ;
// Need to be in Resource space at this point.
DataAccessPoint ref = Builder.buildDataAccessPoint(subject) ;
DataAccessPointRegistry.register(datasetPath, ref) ;
action.getResponse().setContentType(WebContent.contentTypeTextPlain);
ServletOutputStream out = action.getResponse().getOutputStream() ;
- out.println("That went well") ;
ServletOps.success(action) ;
system.commit();
committed = true ;
} catch (IOException ex) { IO.exception(ex); }
finally {
- if ( ! committed ) system.abort() ;
+ if ( ! committed ) {
+ if ( filename1 != null ) FileOps.deleteSilent(filename1);
+ if ( filename2 != null ) FileOps.deleteSilent(filename2);
+ system.abort() ;
+ }
system.end() ;
}
return null ;
}
+
+// //@Override
+// // The system database version.
+// // Keep for easy replacement until comfortable new way is stable.
+// protected JsonValue execPostContainer1(HttpAction action) {
+// JenaUUID uuid = JenaUUID.generate() ;
+// String newURI = uuid.asURI() ;
+// Node gn = NodeFactory.createURI(newURI) ;
+//
+// ContentType ct = FusekiLib.getContentType(action) ;
+//
+// boolean committed = false ;
+// system.begin(ReadWrite.WRITE) ;
+// try {
+// Model model = system.getNamedModel(gn.getURI()) ;
+// StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
+//
+// if ( WebContent.isHtmlForm(ct) )
+// assemblerFromForm(action, dest) ;
+// else if ( WebContent.isMultiPartForm(ct) )
+// assemblerFromUpload(action, dest) ;
+// else
+// assemblerFromBody(action, dest) ;
+//
+// // Keep a persistent copy.
+// String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
+// try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+// RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+// }
+//
+// Statement stmt = getOne(model, null, pServiceName, null) ;
+// if ( stmt == null ) {
+// StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null ) ;
+// if ( ! sIter.hasNext() )
+// ServletOps.errorBadRequest("No name given in description of Fuseki service") ;
+// sIter.next() ;
+// if ( sIter.hasNext() )
+// ServletOps.errorBadRequest("Multiple names given in description of Fuseki service") ;
+// throw new InternalErrorException("Inconsistent: getOne didn't fail the second time") ;
+// }
+//
+// if ( ! stmt.getObject().isLiteral() )
+// ServletOps.errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" : Service names are strings, then used to build the external URI") ;
+//
+// 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 datasetName = object.getLexicalForm() ;
+// String datasetPath = DataAccessPoint.canonical(datasetName) ;
+// action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;
+//
+// if ( DataAccessPointRegistry.get().isRegistered(datasetPath) )
+// // And abort.
+// ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath) ;
+//
+// model.removeAll(null, pStatus, null) ;
+// model.add(subject, pStatus, FusekiVocab.stateActive) ;
+//
+// // Need to be in Resource space at this point.
+// DataAccessPoint ref = Builder.buildDataAccessPoint(subject) ;
+// DataAccessPointRegistry.register(datasetPath, ref) ;
+// action.getResponse().setContentType(WebContent.contentTypeTextPlain);
+// ServletOutputStream out = action.getResponse().getOutputStream() ;
+// ServletOps.success(action) ;
+// system.commit();
+// committed = true ;
+//
+// } catch (IOException ex) { IO.exception(ex); }
+// finally {
+// if ( ! committed ) system.abort() ;
+// system.end() ;
+// }
+// return null ;
+// }
@Override
protected JsonValue execPostItem(HttpAction action) {
@@ -247,13 +348,18 @@ public class ActionDatasets extends ActionContainerItem {
private void assemblerFromForm(HttpAction action, StreamRDF dest) {
String dbType = action.getRequest().getParameter(paramDatasetType) ;
String dbName = action.getRequest().getParameter(paramDatasetName) ;
+ if ( dbType == null || dbName == null )
+ ServletOps.errorBadRequest("Required parameters: dbName and dbType");
+
Map<String, String> params = new HashMap<>() ;
- params.put(Template.NAME, dbName) ;
+
+ if ( dbName.startsWith("/") )
+ params.put(Template.NAME, dbName.substring(1)) ;
+ else
+ params.put(Template.NAME, dbName) ;
FusekiServer.addGlobals(params);
//action.log.info(format("[%d] Create database : name = %s, type = %s", action.id, dbName, dbType )) ;
- if ( dbType == null || dbName == null )
- ServletOps.errorBadRequest("Required parameters: dbName and dbType");
if ( ! dbType.equals(tDatabasetTDB) && ! dbType.equals(tDatabasetMem) )
ServletOps.errorBadRequest(format("dbType can be only '%s' or '%s'", tDatabasetTDB, tDatabasetMem)) ;
[08/12] jena git commit: Merge branch 'master' of github.com:afs/jena
Posted by an...@apache.org.
Merge branch 'master' of github.com:afs/jena
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/1e38db5d
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/1e38db5d
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/1e38db5d
Branch: refs/heads/master
Commit: 1e38db5d4723bf108fd6e551d467ebf6bd0626a1
Parents: ed30d38 b7aa28d
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:19:49 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:19:49 2015 +0100
----------------------------------------------------------------------
----------------------------------------------------------------------
[04/12] jena git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/jena
Posted by an...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/jena
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b7aa28db
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b7aa28db
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b7aa28db
Branch: refs/heads/master
Commit: b7aa28db27e1326daf306c35c259f3d6fe091687
Parents: dabd3d2 a3d7609
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:11:09 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jul 3 14:11:09 2015 +0100
----------------------------------------------------------------------
.../apache/jena/sparql/core/DatasetGraphCollection.java | 10 +++++-----
.../src/main/java/org/apache/jena/fuseki/DEF.java | 6 +++++-
2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
[09/12] jena git commit: Clear configuration directory on server
reset.
Posted by an...@apache.org.
Clear configuration directory on server reset.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/66a959d0
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/66a959d0
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/66a959d0
Branch: refs/heads/master
Commit: 66a959d0f983f09f072ac49ff063fc3995fe5cf1
Parents: cf25c96
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:08:44 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jul 12 15:35:28 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/jena/fuseki/ServerTest.java | 2 +
.../java/org/apache/jena/fuseki/TestAdmin.java | 61 ++++++++++----------
2 files changed, 32 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/66a959d0/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
index 0aa7cbf..5e916ac 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/ServerTest.java
@@ -146,6 +146,8 @@ public class ServerTest {
Collection<String> keys = Iter.toList(DataAccessPointRegistry.get().keys().iterator()) ;
for (String k : keys)
DataAccessPointRegistry.get().remove(k) ;
+ // Clear configuration directory.
+ FileOps.clearAll(FusekiServer.dirConfiguration.toFile()) ;
}
public static void resetServer() {
http://git-wip-us.apache.org/repos/asf/jena/blob/66a959d0/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
index d5e6ddb..29f74c3 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAdmin.java
@@ -53,9 +53,9 @@ import org.apache.jena.riot.WebContent ;
import org.apache.jena.riot.web.HttpOp ;
import org.apache.jena.riot.web.HttpResponseHandler ;
import org.apache.jena.web.HttpSC ;
+import org.junit.After ;
import org.junit.AfterClass ;
import org.junit.Before ;
-import org.junit.BeforeClass ;
import org.junit.Test ;
/** Tests of the admin functionality */
@@ -64,21 +64,19 @@ public class TestAdmin extends BaseTest {
// Name of the dataset in the assembler file.
static String dsTest = "test-ds2" ;
- @BeforeClass
- public static void beforeClass() {
+ @Before public void beforeTest() {
ServerTest.allocServer() ;
ServerTest.resetServer() ;
}
-
- @AfterClass
- public static void afterClass() {
+
+ @After public void afterTest() {
ServerTest.freeServer() ;
}
-
- @Before public void beforeTest() {
- ServerTest.resetServer() ;
+
+ @AfterClass public static void afterClass() {
+ ServerTest.teardownServer() ;
}
-
+
// --- Ping
@Test public void ping_1() {
@@ -139,27 +137,6 @@ public class TestAdmin extends BaseTest {
checkJsonDatasetsOne(v.getAsObject()) ;
}
- private static JsonValue getDatasetDescription(String dsName) {
- try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+dsName) ) {
- assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
- JsonValue v = JSON.parse(in) ;
- return v ;
- }
- }
-
- // -- Add
-
- private static void addTestDataset() {
- File f = new File("testing/config-ds-1.ttl") ;
- org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
- HttpEntity e = new FileEntity(f, ct) ;
- execHttpPost(ServerTest.urlRoot+"$/"+opDatasets, e) ;
- }
-
- private static void deleteDataset(String name) {
- execHttpDelete(ServerTest.urlRoot+"$/"+opDatasets+"/"+name) ;
- }
-
// Specific dataset
@Test public void add_delete_dataset_1() {
checkNotThere(dsTest) ;
@@ -349,6 +326,28 @@ public class TestAdmin extends BaseTest {
}
+ private static JsonValue getDatasetDescription(String dsName) {
+ try ( TypedInputStream in = execHttpGet(urlRoot+"$/"+opDatasets+"/"+dsName) ) {
+ assertEqualsIgnoreCase(WebContent.contentTypeJSON, in.getContentType()) ;
+ JsonValue v = JSON.parse(in) ;
+ return v ;
+ }
+}
+
+// -- Add
+
+private static void addTestDataset() {
+ File f = new File("testing/config-ds-1.ttl") ;
+ org.apache.http.entity.ContentType ct = org.apache.http.entity.ContentType.parse(WebContent.contentTypeTurtle+"; charset="+WebContent.charsetUTF8) ;
+ HttpEntity e = new FileEntity(f, ct) ;
+ execHttpPost(ServerTest.urlRoot+"$/"+opDatasets, e) ;
+}
+
+private static void deleteDataset(String name) {
+ execHttpDelete(ServerTest.urlRoot+"$/"+opDatasets+"/"+name) ;
+}
+
+
static class JsonResponseHandler implements HttpResponseHandler {
private JsonValue result = null ;
[11/12] jena git commit: Switch to configuration directory for UI
created datasets.
Posted by an...@apache.org.
Switch to configuration directory for UI created datasets.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f5e281ba
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f5e281ba
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f5e281ba
Branch: refs/heads/master
Commit: f5e281ba0c5d27f66243de9db1588a8e9472d44c
Parents: 66a959d
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jul 3 14:09:13 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jul 12 15:35:28 2015 +0100
----------------------------------------------------------------------
.../apache/jena/fuseki/mgt/ActionDatasets.java | 136 +++++++++++++++++--
1 file changed, 121 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f5e281ba/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
index e28c2ba..fd612ca 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse ;
import org.apache.jena.atlas.io.IO ;
import org.apache.jena.atlas.json.JsonBuilder ;
import org.apache.jena.atlas.json.JsonValue ;
+import org.apache.jena.atlas.lib.FileOps ;
import org.apache.jena.atlas.lib.InternalErrorException ;
import org.apache.jena.atlas.lib.StrUtils ;
import org.apache.jena.atlas.web.ContentType ;
@@ -118,6 +119,7 @@ public class ActionDatasets extends ActionContainerItem {
// ---- POST
+ // DB less version
@Override
protected JsonValue execPostContainer(HttpAction action) {
JenaUUID uuid = JenaUUID.generate() ;
@@ -127,9 +129,14 @@ public class ActionDatasets extends ActionContainerItem {
ContentType ct = FusekiLib.getContentType(action) ;
boolean committed = false ;
+ // Also acts as a concurrency lock
system.begin(ReadWrite.WRITE) ;
+ String filename1 = null ;
+ String filename2 = null ;
+
try {
- Model model = system.getNamedModel(gn.getURI()) ;
+ // Where to build the templated service/database.
+ Model model = ModelFactory.createDefaultModel() ;
StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
if ( WebContent.isHtmlForm(ct) )
@@ -139,12 +146,13 @@ public class ActionDatasets extends ActionContainerItem {
else
assemblerFromBody(action, dest) ;
- // Keep a persistent copy.
- String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
- try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+ // Keep a persistent copy imediately. This is not used for
+ // anything other than being "for the record".
+ filename1 = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
+ try ( OutputStream outCopy = IO.openOutputFile(filename1) ) {
RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
}
-
+
Statement stmt = getOne(model, null, pServiceName, null) ;
if ( stmt == null ) {
StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null ) ;
@@ -158,13 +166,13 @@ public class ActionDatasets extends ActionContainerItem {
if ( ! stmt.getObject().isLiteral() )
ServletOps.errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" : Service names are strings, then used to build the external URI") ;
-
+
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 datasetName = object.getLexicalForm() ;
String datasetPath = DataAccessPoint.canonical(datasetName) ;
action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;
@@ -172,27 +180,120 @@ public class ActionDatasets extends ActionContainerItem {
if ( DataAccessPointRegistry.get().isRegistered(datasetPath) )
// And abort.
ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath) ;
-
- model.removeAll(null, pStatus, null) ;
- model.add(subject, pStatus, FusekiVocab.stateActive) ;
+
+ // Copy to the configuration directory for server start up next time.
+ filename2 = datasetPath.substring(1) ; // Without "/"
+ filename2 = FusekiServer.dirConfiguration.resolve(filename2).toString()+".ttl" ;
+ if ( FileOps.exists(filename2) )
+ ServletOps.error(HttpSC.INTERNAL_SERVER_ERROR_500, "Configuration file of that name already exists "+filename2) ;
+
+ try ( OutputStream outCopy = IO.openOutputFile(filename2) ) {
+ RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+ }
+
+ // Currently do nothing with the system database.
+ // In the future ... maybe ...
+// Model modelSys = system.getNamedModel(gn.getURI()) ;
+// modelSys.removeAll(null, pStatus, null) ;
+// modelSys.add(subject, pStatus, FusekiVocab.stateActive) ;
// Need to be in Resource space at this point.
DataAccessPoint ref = Builder.buildDataAccessPoint(subject) ;
DataAccessPointRegistry.register(datasetPath, ref) ;
action.getResponse().setContentType(WebContent.contentTypeTextPlain);
ServletOutputStream out = action.getResponse().getOutputStream() ;
- out.println("That went well") ;
ServletOps.success(action) ;
system.commit();
committed = true ;
} catch (IOException ex) { IO.exception(ex); }
finally {
- if ( ! committed ) system.abort() ;
+ if ( ! committed ) {
+ if ( filename1 != null ) FileOps.deleteSilent(filename1);
+ if ( filename2 != null ) FileOps.deleteSilent(filename2);
+ system.abort() ;
+ }
system.end() ;
}
return null ;
}
+
+// //@Override
+// // The system database version.
+// // Keep for easy replacement until comfortable new way is stable.
+// protected JsonValue execPostContainer1(HttpAction action) {
+// JenaUUID uuid = JenaUUID.generate() ;
+// String newURI = uuid.asURI() ;
+// Node gn = NodeFactory.createURI(newURI) ;
+//
+// ContentType ct = FusekiLib.getContentType(action) ;
+//
+// boolean committed = false ;
+// system.begin(ReadWrite.WRITE) ;
+// try {
+// Model model = system.getNamedModel(gn.getURI()) ;
+// StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
+//
+// if ( WebContent.isHtmlForm(ct) )
+// assemblerFromForm(action, dest) ;
+// else if ( WebContent.isMultiPartForm(ct) )
+// assemblerFromUpload(action, dest) ;
+// else
+// assemblerFromBody(action, dest) ;
+//
+// // Keep a persistent copy.
+// String filename = FusekiServer.dirFileArea.resolve(uuid.asString()).toString() ;
+// try ( OutputStream outCopy = new FileOutputStream(filename) ) {
+// RDFDataMgr.write(outCopy, model, Lang.TURTLE) ;
+// }
+//
+// Statement stmt = getOne(model, null, pServiceName, null) ;
+// if ( stmt == null ) {
+// StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null ) ;
+// if ( ! sIter.hasNext() )
+// ServletOps.errorBadRequest("No name given in description of Fuseki service") ;
+// sIter.next() ;
+// if ( sIter.hasNext() )
+// ServletOps.errorBadRequest("Multiple names given in description of Fuseki service") ;
+// throw new InternalErrorException("Inconsistent: getOne didn't fail the second time") ;
+// }
+//
+// if ( ! stmt.getObject().isLiteral() )
+// ServletOps.errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" : Service names are strings, then used to build the external URI") ;
+//
+// 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 datasetName = object.getLexicalForm() ;
+// String datasetPath = DataAccessPoint.canonical(datasetName) ;
+// action.log.info(format("[%d] Create database : name = %s", action.id, datasetPath)) ;
+//
+// if ( DataAccessPointRegistry.get().isRegistered(datasetPath) )
+// // And abort.
+// ServletOps.error(HttpSC.CONFLICT_409, "Name already registered "+datasetPath) ;
+//
+// model.removeAll(null, pStatus, null) ;
+// model.add(subject, pStatus, FusekiVocab.stateActive) ;
+//
+// // Need to be in Resource space at this point.
+// DataAccessPoint ref = Builder.buildDataAccessPoint(subject) ;
+// DataAccessPointRegistry.register(datasetPath, ref) ;
+// action.getResponse().setContentType(WebContent.contentTypeTextPlain);
+// ServletOutputStream out = action.getResponse().getOutputStream() ;
+// ServletOps.success(action) ;
+// system.commit();
+// committed = true ;
+//
+// } catch (IOException ex) { IO.exception(ex); }
+// finally {
+// if ( ! committed ) system.abort() ;
+// system.end() ;
+// }
+// return null ;
+// }
@Override
protected JsonValue execPostItem(HttpAction action) {
@@ -247,13 +348,18 @@ public class ActionDatasets extends ActionContainerItem {
private void assemblerFromForm(HttpAction action, StreamRDF dest) {
String dbType = action.getRequest().getParameter(paramDatasetType) ;
String dbName = action.getRequest().getParameter(paramDatasetName) ;
+ if ( dbType == null || dbName == null )
+ ServletOps.errorBadRequest("Required parameters: dbName and dbType");
+
Map<String, String> params = new HashMap<>() ;
- params.put(Template.NAME, dbName) ;
+
+ if ( dbName.startsWith("/") )
+ params.put(Template.NAME, dbName.substring(1)) ;
+ else
+ params.put(Template.NAME, dbName) ;
FusekiServer.addGlobals(params);
//action.log.info(format("[%d] Create database : name = %s, type = %s", action.id, dbName, dbType )) ;
- if ( dbType == null || dbName == null )
- ServletOps.errorBadRequest("Required parameters: dbName and dbType");
if ( ! dbType.equals(tDatabasetTDB) && ! dbType.equals(tDatabasetMem) )
ServletOps.errorBadRequest(format("dbType can be only '%s' or '%s'", tDatabasetTDB, tDatabasetMem)) ;
[12/12] jena git commit: Merge commit 'refs/pull/85/head' of
github.com:apache/jena
Posted by an...@apache.org.
Merge commit 'refs/pull/85/head' of github.com:apache/jena
This closes #85.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/80dbb451
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/80dbb451
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/80dbb451
Branch: refs/heads/master
Commit: 80dbb451f7b35e96a887f06b01e93ace28d9c0a2
Parents: f5e281b 1e38db5
Author: Andy Seaborne <an...@apache.org>
Authored: Sun Jul 12 15:36:24 2015 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sun Jul 12 15:36:24 2015 +0100
----------------------------------------------------------------------
----------------------------------------------------------------------