0

Hi I have created a java program where I take a ttl file and update the turtle statements. Since I have a web interface that connects to fuseki to query the ttl file, I would like to reupload the ttl file with the new data. Is there a way to do this programatically instead of the Fuseki interface?

What I am trying is to access the command prompt from java and using the s-put command but I am getting a No such file or directory error:

public void updateFuseki() throws IOException{
     Runtime rt = Runtime.getRuntime();
     Process pr = rt.exec("s-put http://localhost:3030/Test/ default Definitions.graph.ttl");
}

I have currently only one dataset called Test in fuseki and Definitions.graph.ttl is in the same package as Jena

Mario
  • 1
  • 3
  • Does that command work if you run it on the command line? And what exactly is the error? – cygri Apr 26 '19 at 12:05
  • It says that s-sput is not found – Mario Apr 26 '19 at 12:21
  • It's `s-put`, not `s-sput`. And it would really help if you copy-pasted error messages instead of paraphrasing them in your own words. Details matter! But anyway, since you're writing a Java program, it's better to use a Java library for the job, instead of calling out to the command line. I've posted a response that shows how to do that. – cygri Apr 26 '19 at 13:44

1 Answers1

2

Fuseki's API for remote-uploading data is the SPARQL Graph Store HTTP Protocol, which is part of the SPARQL standard. The s-put command is a simple client application (written in Ruby) that uses this API.

Since your application is written in Java, it would be better to use a Java client for this API.

You've tagged your question with jena, so I'm assuming your Java app already uses Jena? Jena includes a client library for the Graph Store Protocol. A simple use would be something like this:

String serviceURL = "http://localhost:3030/Test/";
try (RDFConnection conn = RDFConnectionFactory.connect(serviceURL)) {
    conn.put("Definitions.graph.ttl");
}
cygri
  • 9,412
  • 1
  • 25
  • 47