-
Notifications
You must be signed in to change notification settings - Fork 5
basic interaction
For specification and tests, see here.
Note: this is work in progress!
Start mongo if not already running, for example:
$ mkdir ~/orr-ont-base-directory/mongo-dbpath
$ mongod --dbpath ~/orr-ont-base-directory/mongo-dbpath
Start orr-ont:
$ cd orr-ont
$ ./sbt 'container:start'
Make sure /etc/orront.conf
has the corresponding mongo connection parameters. This file looks like the following for the interaction described below:
admin {
password = "admpw"
}
mongo {
host = localhost
port = 27017
db = orr-ont
// collection names:
ontologies = ontologies
users = users
organizations = organizations
}
files {
baseDirectory = /Users/carueda/orr-ont-base-directory
}
The interaction below is on the command line using httpie. You may want to use a tool like Robomongo to inspect the actual contents of the Mongo collections as you perform the operations.
(if not already in the database, the 'admin' user is automatically created when orr-ont starts)
$ http get http://localhost:8080/user
HTTP/1.1 200 OK
Content-Length: 58
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
[
{
"registered": "2015-01-01T02:09:53Z",
"userName": "admin"
}
]
$ http -a admin:admpw post localhost:8080/user userName=calvin firstName=Cal lastName=Vin password=hobbes
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1las7tn57t38llnd5rl0hzw7g;Path=/
Transfer-Encoding: chunked
{
"registered": "2015-01-01T02:14:29Z",
"userName": "calvin"
}
$ http get http://localhost:8080/user
HTTP/1.1 200 OK
Content-Length: 116
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
[
{
"registered": "2015-01-01T02:09:53Z",
"userName": "admin"
},
{
"registered": "2015-01-01T02:14:29Z",
"userName": "calvin"
}
]
http -a admin:admpw 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: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1el864q41r9mt13dde2otjrbph;Path=/
Transfer-Encoding: chunked
{
"orgName": "mmi",
"registered": "2015-01-01T02:16:15Z"
}
$ 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": "2015-01-01T02:16:15Z"
}
]
$ 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": "2015-01-01T02:16:15Z"
}
$ http -a admin:admpw -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
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=dpof8q8qqolewrjh5pp0chiy;Path=/
Transfer-Encoding: chunked
{
"registered": "2015-01-01T02:18:12Z",
"uri": "http://ont1",
"version": "20141231T181812"
}
$ http -a admin:admpw -f put localhost:8080/ont 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
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=rgxjr8i75wj21nfv0uqi7x0nf;Path=/
Transfer-Encoding: chunked
{
"updated": "2015-01-01T02:22:56Z",
"uri": "http://ont1",
"version": "20141231T182256"
}
$ http get localhost:8080/ont
HTTP/1.1 200 OK
Content-Length: 82
Content-Type: application/json;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
[
{
"name": "",
"uri": "http://ont1",
"versions": [
"20141231T182256",
"20141231T181812"
]
}
]
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
Server: Jetty(8.1.8.v20121106)
@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> .
A self-hosted ontology is simply one whose URI has the service URL as a prefix. For example, if
the service is located at http://mmisw.org/ont/
then an ontology with URI
http://mmisw.org/ont/myontology
will be self-hosted.
http -a admin:admpw -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
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=amzk4xmjpebu1q5blyayp5taa;Path=/
Transfer-Encoding: chunked
{
"registered": "2015-01-01T02:26:18Z",
"uri": "http://localhost:8080/ont/mmi/selfhosted",
"version": "20141231T182618"
}
$ http get http://localhost:8080/ont/mmi/selfhosted
HTTP/1.1 200 OK
Content-Length: 310
Content-Type: application/rdf+xml;charset=UTF-8
Server: Jetty(8.1.8.v20121106)
<?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
Server: Jetty(8.1.8.v20121106)
@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> .
$ http -a admin:admpw -f put localhost:8080/ont uri=http://localhost:8080/ont/mmi/selfhosted version=20141231T182618 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
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1169sqb2i02kyfvl5l0vith6i;Path=/
Transfer-Encoding: chunked
{
"updated": "2015-01-01T02:26:18Z",
"uri": "http://localhost:8080/ont/mmi/selfhosted",
"version": "20141231T182618"
}
$ http -a admin:admpw delete localhost:8080/ont\?uri=http://ont1\&version=20141231T181812\&userName=calvin
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=1orei8lwy7odz4799is90nzia;Path=/
Transfer-Encoding: chunked
{
"removed": "2015-01-01T02:31:12Z",
"uri": "http://ont1",
"version": "20141231T181812"
}
(just omit the version parameter)
$ http -a admin:admpw delete localhost:8080/ont\?uri=http://ont1\&userName=calvin
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
REMOTE_USER: admin
Server: Jetty(8.1.8.v20121106)
Set-Cookie: JSESSIONID=ioyndg7035sejynjtql99hih;Path=/
Transfer-Encoding: chunked
{
"removed": "2015-01-01T02:32:25Z",
"uri": "http://ont1"
}