Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
91 lines (53 sloc) 4.55 KB

PayGoo - Pay As You GO data Objects

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



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= | label=a simple container | modified=2012-04-11]

<div>About <a href=''>a simple container</a>, last updated 2012-04-11 containing: <ul><li><a href=''>resource 1</a></li><li><a href=''>resource 2</a></li></ul></div>

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

As plain text:
id=, label=a simple container, modified=2012-04-11, containing: [id=, label=resource 1, modified=2012-04-11id=, label=resource 2, modified=2012-04-11]

As RDF/NTriple:
<> <> <> .
<> <> "" .
<> <> "a simple container" .
<> <> "" .
<> <> "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> <> "container 0" .
<http://localhost:6969/bpc0> <> "http://localhost:6969/res1" .
<http://localhost:6969/bpc0> <> "http://localhost:6969/res2" .
<http://localhost:6969/bpc0> <> "2012-04-11" .
<http://localhost:6969/bpc0> <> <> .

$ 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


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


Public Domain.