Skip to content
This repository

An object-orient implementation of 'Linked Data Basic Profile'-compliant containers/resources.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 bp-vocab.ttl
Octocat-spinner-32 info.paygoo.core.scala
Octocat-spinner-32 info.paygoo.server.scala
Octocat-spinner-32 info.paygoo.vocab.scala
README.md

PayGoo - Pay As You GO data Objects

An object-orient implementation of 'Linked Data Basic Profile'-compliant containers/resources.

Usage

Bare-bone

After you got the source somewhere local (via git clone or download facility) you want to compile it:

scalac -cp lib/scardf-0.6-SNAPSHOT.jar:lib/joda-time-1.6.jar info.paygoo.core.scala

Then you can run the built-in test like so:

scala -cp lib/scardf-0.6-SNAPSHOT.jar:lib/joda-time-1.6.jar info.paygoo.core.PayGooContainer

... which should yield something like the following:

[PayGooContainer: id=http://data.example.com/#container | label=a simple container | modified=2012-04-11]

As HTML:
<div>About <a href='http://data.example.com/#container'>a simple container</a>, last updated 2012-04-11 containing: <ul><li><a href='http://data.example.com/#res1'>resource 1</a></li><li><a href='http://data.example.com/#res2'>resource 2</a></li></ul></div>

As JSON:
{"container" : {"id" : "http:\/\/data.example.com\/#container", "label" : "a simple container", "modified" : "2012-04-11"}, "members" : ["http:\/\/data.example.com\/#res1", "http:\/\/data.example.com\/#res2"]}

As plain text:
id=http://data.example.com/#container, label=a simple container, modified=2012-04-11, containing: [id=http://data.example.com/#res1, label=resource 1, modified=2012-04-11id=http://data.example.com/#res2, label=resource 2, modified=2012-04-11]

As RDF/NTriple:
<http://data.example.com/#container> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://open-services.net/ns/basicProfile#Container> .
<http://data.example.com/#container> <http://www.w3.org/2000/01/rdf-schema#member> "http://data.example.com/#res2" .
<http://data.example.com/#container> <http://purl.org/dc/terms/title> "a simple container" .
<http://data.example.com/#container> <http://www.w3.org/2000/01/rdf-schema#member> "http://data.example.com/#res1" .
<http://data.example.com/#container> <http://purl.org/dc/terms/modified> "2012-04-11" .

RESTful interaction

Now to something more fun. Some RESTful interaction. Compile the server like so:

scalac -cp lib/scardf-0.6-SNAPSHOT.jar:lib/joda-time-1.6.jar info.paygoo.server.scala

And then run it with:

scala -cp lib/scardf-0.6-SNAPSHOT.jar:lib/joda-time-1.6.jar info.paygoo.server.PayGooServer

After that, point your Web browser to http://localhost:6969/bpc0 and you should see an HTML rendering. If you prefer some command-line noodling using curl, here you go:

$ curl -H "Accept:application/json" http://localhost:6969/bpc0

{"container" : {"id" : "http:\/\/localhost:6969\/bpc0", "label" : "container 0", "modified" : "2012-04-11"}, "members" : ["http:\/\/localhost:6969\/res1", "http:\/\/localhost:6969\/res2"]}

$ curl http://localhost:6969/bpc0?ntriple

<http://localhost:6969/bpc0> <http://purl.org/dc/terms/title> "container 0" .
<http://localhost:6969/bpc0> <http://www.w3.org/2000/01/rdf-schema#member> "http://localhost:6969/res1" .
<http://localhost:6969/bpc0> <http://www.w3.org/2000/01/rdf-schema#member> "http://localhost:6969/res2" .
<http://localhost:6969/bpc0> <http://purl.org/dc/terms/modified> "2012-04-11" .
<http://localhost:6969/bpc0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://open-services.net/ns/basicProfile#Container> .

$ curl -H "Accept:application/json" http://localhost:6969/bpc0?html

<div>About <a href='http://localhost:6969/bpc0'>container 0</a>, last updated 2012-04-11 containing: <ul><li><a href='http://localhost:6969/res1'>resource 1</a></li><li><a href='http://localhost:6969/res2'>resource 2</a></li></ul></div>

You get the idea, right? Either you tell the PayGooServer via conneg what format you prefer or you can specify it explicitly by appending a query parameter ?xxx where xxx can be one of the following: json, html or ntriple which overwrites the conneg.

And now let's create a new resource in an existing container:

curl -H "Content-Type: text/plain" -X POST --data "@test/res3.nt" http://localhost:6969/bpc0

RESTful action mappings:

method  BPC               BPR
------------------------------------------
GET     200:JSON/NT/HTML  200:JSON/NT/HTML    
POST    201:JSON/NT       501
PUT     409               200:JSON/NT
DELETE  200               200

Dependencies

  • Tested against Scala 2.9.1
  • Using scardf for RDF parsing and serialisation

License

Public Domain.

Something went wrong with that request. Please try again.