# Joseki: Publishing a Model

This section goes through the basic steps needed to publish an RDF model. Other sections provide greater detail – see:

- The configuration file
- Running a Joseki server

Two things are needed to get an existing RDF model to be published using Joseki – first, add it to the configuration file so it is one of the models the server is hosting; second, restart the server.

But first note that, to publish a small RDF model, all you need is a web server – any web server – you can just put the file up for people to access like a web page. Joseki adds the ability to use queries to access published data so you don't need to transfer the whole copy and it also adds the ability to change the model for a collaboration between applications. This can be useful when models are big; where the information is frequently changing or where several applications are exchanging information via a shared model.

## Adding a model to the configuration file

Suppose we have a RDF model in the file "stuff.xml" and want it to appear as `http://example.com/myRDF`:

    <http://server/myRDF>
        a   joseki:AttachedModel ;
        joseki:attachedModel        <file:stuff.xml> ;
        joseki:hasQueryOperation    joseki:BindingRDQL ;
        joseki:hasQueryOperation    joseki:BindingGET ;
        joseki:hasOperation         joseki:BindingQueryModel ;
        joseki:hasOperation         joseki:BindingPing ;
        joseki:isImmutable          "true" ;
        .

We have used N3 here because it produces more readable RDF - the configuration file can be in RDF/XML, or even N-triples, and the file extension is used to determine the file type (.n3 for N3, .nt for N-Triples, .xml or .rdf for RDF/XML). Just don't forget the dot at the end!

What we have done is to add some metadata to the configuration model, saying what we are adding (an attached model), where the data is (in the file:) and what operations can be performed. Here, clients can query the model with HTTP GET and with RDQL over HTTP GET or HTTP POST. Also, the model allows OPTIONS and a Ping operation. This set of query and other operations forms the usual needed. We also told the server that the model is immutable – none of the queries or operations change the model either explicitly or implicitly – some operations (like GET) use this information for efficiency.

## Running the Server

Once the configuration file is done, you need to restart the server; you can check the log file to see that the new model has been picked up. The simplest way to run the server is as a standalone program:

    java -cp ... joseki.rdfserver configFile.n3

Further details on running a Joseki server.

## Database-backed RDF Models

A Jena RDF model held in a database can also be added: the URI for the data is just the the JDBC URL:

    <http://server/myLargePersistentRDF>
        a   joseki:AttachedModel ;
        joseki:attachedModel      <jdbc:mysql://host/db> ;
        joseki:user               "test" ;
        joseki:password           "password" ;
        joseki:dbModelName        "model_name" ;
        joseki:dbType             "MySQL" ;
        joseki:dbDriver           "com.mysql.jdbc.Driver" ;
        joseki:hasQueryOperation  joseki:BindingRDQL ;
        joseki:hasOperation       joseki:BindingPing ;
        joseki:hasOperation       joseki:BindingQueryModel ;
        .

We have not allowed plain GET because it is a large model (it does not stop an RDQL query that asks for the entire database). Because of variation in JDBC URLs, we pass user and password information separately.

## See Also

- The configuration file
- Running a server