Virtuoso and LODRefine – more vicious than virtuous pair (part 2)

First…

there was a big black hole (BBH). And then it got bigger. Seriously. At this point in my life I realized that more I learn more is there to learn.

Failure is success if we live to learn from it.
(Malcolm Forbes and me)

Second…

Chewing through the virtuoso documentation made me realize that using /sparql endpoint for updating graphs (i.e. inserting triples into it) is not  a particularly good idea. One has to have some security, right? I said to the SPARQL user that it has the right to return error on any non-SELECT demand. I found out that there are three possibilities of securing your virtuoso endpoint:

There is good news…

Implementing  digest authentication into LODRefine was easy peasy (after I found the right library that is). I used Apache HTTP Client for this:


...
import org.apache.http.client.params.AuthPolicy;
import org.apache.http.NameValuePair;
import org.apache.http.auth.AuthScope;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.auth.UsernamePasswordCredentials;
...
...
...
  DefaultHttpClient client = new DefaultHttpClient();
  client.getCredentialsProvider().setCredentials(
	new AuthScope(endpoint.getHost(),endpoint.getPort()),
		      new UsernamePasswordCredentials(properties.get("username"), properties.get("password"))
		     );
  client.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, AuthPolicy.DIGEST);
  HttpPost httpPost = new HttpPost(endpoint.toURI());  try {
        List  nvps = new ArrayList ();
        nvps.add(new BasicNameValuePair("query", query));
        httpPost.setEntity(new UrlEncodedFormEntity(nvps));
        HttpResponse response = client.execute(httpPost);
        ...
      }
  ...
  ...

Nice and simple, if only the virtuoso endpoint you are trying to use supports this kind of authentication – if it does, it is accessible at /sparql-auth. I had to enable it on my local virtuoso instance. I also created a new user with SPARQL UPDATE rights. For more details see Virtuoso guide.

… and there is oh-not-so-good news …

In LOD2 we decided to use WebID authentication. This will definitely not be a walk in the park. You’ll have to wait for part 3 to see, whether I survived this dangerous endeavor.

Avoiding danger is no safer in the long run than outright exposure. The fearful are caught as often as the bold. Especially if they don’t run fast enough.
(Hellen Keller and me)

Virtuoso and LODRefine – viciously virtuous pair (part 1)

Disclaimer

I’m assuming that you :

  • are familiar with the notion of linked data (triples, SPARQL endpoints)
  • have heard about Virtuoso Universal Server,
  • want to give LODRefine a chance and,
  • don’t mind waiting for part 2 of this post.

The beginning…

They: “We want to upload triples directly from LODRefine to Virtuoso.
Me: “A wha?

… and the (almost) joke

A Virtuoso, SPARQL, and SPARUL enter the bar.
Bartender: “Hey guys, what can I get you?
They: “Select ?drink where {?drink <http://www.w3.org/1999/02/22-rdf-syntax-ns#label “Martini (Coctail)” }
Bartender (puzzled): “Gesundheit!? 

But seriously!

If you are familiar with LODRefine, then you know you can transform your data to triples using RDF extension (thanks to Fadi Richard from DERI!). Now what? You can export triples to file and then upload this file to some triple store.

Imagine you could insert triples directly from LODRefine. Guess what? This is exactly what I’m working on right now. Yay me! :)

I started with installing Virtuoso Open-Source Edition (OS X 10.7) and (fortunately) had no problems building, configuring and installing it according to the instructions. After adding SPARQL_UPDATE rights to the SPARQL user I was ready to insert some triples. And I did… insert some triples via /sparql endpoint. Lovely!

At this point (not endpoint) I learned about SPARUL (could be a name of a villain in the next Batman movie) and figured out how to delete all named graphs containing a specific substring in their name. Why I wanted to do this? Because I installed demo, sparql demo and what-not … and shortly after realized I would be much happier person without all these graphs in my virtuoso instance and that I don’t want to click on each and every one of them to remove them.

[In Vonnegut’s  Breakfast of Champions style…]

This is how you can remove all the graphs containing specific substring in IRI:


DELETE {GRAPH ?g {?s ?p ?o}} 
WHERE {
   GRAPH ?g {?s ?p ?o}  
   FILTER( contains(str(?g), "your substring here"))
}

Level 1: install instance of Virtuoso locally finished.

Next level: add “Upload data to triplestore” to LODRefine…

 

 

Enhanced by Zemanta