Skip to content
carueda edited this page Dec 30, 2014 · 15 revisions

mongo

$ mkdir ~/orr-ont-base-directory/mongo-dbpath
$ mongod --dbpath ~/orr-ont-base-directory/mongo-dbpath

build & test##

$ cd orr-ont
$ ./sbt test

run

$ cd orr-ont
$ ./sbt 'container:start'

some manual interaction

Using httpie

users

Create a user:

$ http post localhost:8080/user userName=calvin firstName=Cal lastName=Vin password=hobbes
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
Transfer-Encoding: chunked

{
    "registered": "2014-12-30T01:36:44Z",
    "userName": "calvin"
}

Get all users:

$ http get localhost:8080/user
HTTP/1.1 200 OK
Content-Length: 59
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)

[
    {
        "registered": "2014-12-30T01:36:44Z",
        "userName": "calvin"
    }
]

Check user login:

$ http post localhost:8080/user/chkpw userName=calvin password=hobbes
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
Transfer-Encoding: chunked

{
    "userName": "calvin"
}

organizations

Create an organization:

$ http post localhost:8080/org orgName=mmi name="mmi project"  members:='["calvin"]'
HTTP/1.1 401 Unauthorized
Content-Length: 15
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
WWW-Authenticate: Basic realm="orr-ont realm"

Unauthenticated

Organization creation requires authentication:

$ http -a calvin:hobbes post localhost:8080/org orgName=mmi name="mmi project"  members:='["calvin"]'
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
REMOTE_USER: calvin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=j7caoidfw7p41nu7m121hrlmj;Path=/
Transfer-Encoding: chunked

{
    "orgName": "mmi",
    "registered": "2014-12-30T01:48:59Z"
}

Get all organizations:

$ http get  localhost:8080/org
HTTP/1.1 200 OK
Content-Length: 76
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)

[
    {
        "name": "mmi project",
        "orgName": "mmi",
        "registered": "2014-12-30T01:48:59Z"
    }
]

Get an organization:

$ http get  localhost:8080/org/mmi
HTTP/1.1 200 OK
Content-Length: 74
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)

{
    "name": "mmi project",
    "orgName": "mmi",
    "registered": "2014-12-30T01:48:59Z"
}

ontologies

Register a new ontology:

$ http -f post localhost:8080/ont uri=http://ont1 name=example orgName=mmi userName=calvin file@src/test/resources/test.rdf format=rdf
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=q6qy3sixki24qflehoco6qmi;Path=/
Transfer-Encoding: chunked

{
    "registered": "2014-12-30T01:52:22Z",
    "uri": "http://ont1",
    "version": "20141229T175222"
}

Register a new version of the ontology above:

$ http -f post localhost:8080/ont/version uri=http://ont1 userName=calvin file@src/test/resources/test.rdf format=rdf
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1wq8817zwbymb2lz3rtyz32ua;Path=/
Transfer-Encoding: chunked

{
    "updated": "2014-12-30T01:54:45Z",
    "uri": "http://ont1",
    "version": "20141229T175445"
}
$ http get  localhost:8080/ont
HTTP/1.1 200 OK
Content-Length: 116
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=19emqgufcdmqq51aazhcnb2sv;Path=/

[
    {
        "name": "",
        "uri": "http://ont1",
        "versions": [
            "20141229T175222",
            "20141229T175445"
        ]
    }
]

Get an ontology in N3:

$ http get localhost:8080/ont\?uri=http://ont1\&format=n3
HTTP/1.1 200 OK
Content-Length: 268
Content-Type: text/n3;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=a4z6g92prvbvkmz7uvn4zz0l;Path=/

@base          <http://ont1> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix myont: <http://localhost:8080/ont/myorg/myont/> .

<myont:hobbes>  a  <Character> .

<myont:calvin>  a        <Character> ;
        myont:hasFriend  <myont:hobbes> .

Post a self-hosted ontology:

$ http -f post localhost:8080/ont uri=http://localhost:8080/ont/mmi/selfhosted name="self-hosted entry" orgName=mmi userName=calvin file@src/test/resources/test.rdf format=rdf
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=163fxgr4lrk572xkcpj8mbcmx;Path=/
Transfer-Encoding: chunked

{
    "registered": "2014-12-30T02:10:02Z",
    "uri": "http://localhost:8080/ont/mmi/selfhosted",
    "version": "20141229T181002"
}

Get a self-hosted ontology:

$ http get http://localhost:8080/ont/mmi/selfhosted
HTTP/1.1 200 OK
Content-Length: 310
Content-Type: application/rdf+xml;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1q99q7ra3iopnkdutd8woockh;Path=/

<?xml version="1.0" ?>
<rdf:RDF xmlns:myont="http://localhost:8080/ont/myorg/myont/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <Character rdf:about="myont:calvin">
        <myont:hasFriend rdf:resource="myont:hobbes"/>
    </Character>
    <Character rdf:about="myont:hobbes">
    </Character>
</rdf:RDF>

#### Get self-hosted ontology in a particular format:
$ http get http://localhost:8080/ont/mmi/selfhosted\?format\=n3
HTTP/1.1 200 OK
Content-Length: 297
Content-Type: text/n3;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=172usf1ouibw31mttfjl785xz1;Path=/

@base          <http://localhost:8080/ont/mmi/selfhosted> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix myont: <http://localhost:8080/ont/myorg/myont/> .

<myont:hobbes>  a  <Character> .

<myont:calvin>  a        <Character> ;
        myont:hasFriend  <myont:hobbes> .

Change name of a version of an ontology:

$ http -f put localhost:8080/ont/version uri=http://localhost:8080/ont/mmi/selfhosted version=20141229T181002 userName=calvin name="self-hosted entry (renamed)"
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=b92jjqwg9gu6g9hwh0oy6c3l;Path=/
Transfer-Encoding: chunked

{
    "updated": "2014-12-30T02:10:02Z",
    "uri": "http://localhost:8080/ont/mmi/selfhosted",
    "version": "20141229T181002"
}

Unregister whole ontology entry:

$ http delete localhost:8080/ont\?uri=http://localhost:8080/ont/selfhosted\&userName=calvin
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1jzzp8f6f0sv7w8h0z7pawudd;Path=/
Transfer-Encoding: chunked

{
    "removed": "2014-12-30T02:36:24Z",
    "uri": "http://localhost:8080/ont/selfhosted"
}

Unregister a particular ontology version:

http delete localhost:8080/ont/version\?uri=http://ont1\&version=20141229T175445\&userName=calvin
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=9mdqu3j5qraz158paz6mnd629;Path=/
Transfer-Encoding: chunked

{
    "removed": "2014-12-30T02:39:11Z",
    "uri": "http://ont1",
    "version": "20141229T175445"
}

Get all registered ontologies:

$ http get localhost:8080/ont
HTTP/1.1 200 OK
Content-Length: 190
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1axq2kdvs3wle1wukxxffrf1pl;Path=/

[
    {
        "name": "example",
        "uri": "http://ont1",
        "versions": [
            "20141229T175222"
        ]
    },
    {
        "name": "self-hosted entry (renamed)",
        "uri": "http://localhost:8080/ont/mmi/selfhosted",
        "versions": [
            "20141229T181002"
        ]
    }
]
Clone this wiki locally