Reputation: 307
I want to upload jena-fuseki's dataset in a linux shell script before running unit test set.
I've tried the following commands:
~/jena_for_unit_testing/apache-jena-fuseki-3.13.1> ./fuseki-server --update --file ds_2024-04-25_13-58-06.nq.gz --port 3031 /test
~/jena_for_unit_testing/apache-jena-fuseki-3.13.1> ./fuseki-server --config run/config.ttl --update --file ds_2024-04-25_13-58-06.nq.gz --port 3031
~/jena_for_unit_testing/apache-jena-fuseki-3.13.1> ./fuseki-server --config run/config.ttl --update --port 3031
config.ttl:
# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
## Fuseki Server configuration file.
@prefix : <#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
<#service1> rdf:type fuseki:Service ;
fuseki:name "ds" ;
fuseki:endpoint [ fuseki:operation fuseki:query ;];
fuseki:endpoint [ fuseki:operation fuseki:query ; fuseki:name "sparql" ];
fuseki:endpoint [ fuseki:operation fuseki:query ; fuseki:name "query" ];
fuseki:endpoint [ fuseki:operation fuseki:update ; ];
fuseki:endpoint [ fuseki:operation fuseki:update ; fuseki:name "update" ];
fuseki:endpoint [ fuseki:operation fuseki:gsp-r ; fuseki:name "get" ];
fuseki:endpoint [ fuseki:operation fuseki:gsp-rw ; ] ;
fuseki:endpoint [ fuseki:operation fuseki:gsp-rw ; fuseki:name "data" ];
fuseki:endpoint [ fuseki:operation fuseki:upload ; fuseki:name "upload" ] ;
fuseki:dataset <#test>
.
<#test> rdf:type ja:RDFDataset .
In 1) I cannot update my dataset (Error 404: No endpoint: /test/update)
In 2) I get the error: Dataset specified on the command line but a configuration file also given.
In 3) I can update my dataset, but I don't know how to upload ds_2024-04-25_13-58-06.nq.gz from command line before starting unit tests.
Edit:
Based on answers below I've also tried upload data using command: curl -i -XPOST "http://localhost:3031/ds" --data-binary ds_2024-04-25_13-58-06.nq --header "Content-type: application/n-quads"
where my nq-file looks like this:
~/jena_for_unit_testing/apache-jena-fuseki-3.13.1> head ds_2024-04-25_13-58-06.nq
<http://www.<myOrg>.fi/tilasto/tilastot_slv> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_teul> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_ton> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_ttvi> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_khki> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_sijk> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_ktps> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_klv> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_adopt> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
<http://www.<myOrg>.fi/tilasto/tilastot_plv> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.<myOrg>.fi/rdf/ontologies/pxproNG> .
Now apache-jena-fuseki complains:
[2024-05-03 06:05:43] Fuseki INFO [1] 400 Parse error: [line: 1, col: 26] Premature end of file: [EOF] (13 ms)
I don't understand where the parse error comes from as the nq-file is created as a backup by the same version of jena-fuseki.
Upvotes: 0
Views: 110
Reputation: 16700
If you want to load a dataset, use /ds/data endpoint and PUT, or POST for adding data, using curl
.
The Content-type header should be set.
curl -T D.ttl --header "Content-type: text/turtle" http://localhost:3030/ds
Another way, from Java, is to use the GSP (Graph) and DSP (Dataset) classes. (not 3.13.1)
Upvotes: 1