Operating with contents of documents
Method
- URL: /content/docs
- Method: GET
- Query parameters:
- numResults - max number of results to be returned (default: -1)
- startFrom - starting from N-th result
- Returns: text/xml
- Description: returns all XML documents in the TNTBase repository as an aggregated document wrapped into results tags. Note that this method returns only the root element of documents.
Example
- URL: http://alpha.tntbase.mathweb.org:8080/tntbase/ai-mashup/restful/content/docs?numResults=1
- Method: GET
- Result: The whole documen, in the result item you can see the name of a document
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns" numResults="1"> <tnt:doc name="/omstd/calculus1.omdoc"> <omdoc xmlns="http://www.mathweb.org/omdoc" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:id="calculus1-omdoc"> <metadata> <dc:title>The OpenMath Content Dictionary calculus1.ocd in OMDoc form</dc:title> <dc:creator role="ant">The OpenMath Society</dc:creator> // ... more content goes here </tnt:doc> </tnt:results>
Method
- URL: /content/docs/{path in the repository}
- Method: GET
- Query parameters:
- numResults - max number of results to be returned (default: -1)
- startFrom - starting from N-th result (default: 1)
- recursive (true or false): whether we want to go to the child directories of the {path in the repository} (default: false)
- Returns: text/xml
- Description: returns XML documents in the TNTBase repository as an aggregated document wrapped into results tags. If recursive parameter is set to false, then we can use simple regexp expressions, like *,? or which stands for all child directories. If recursive is set to true then TNTBase returns all documents in a folder and its subfolders
Example
- URL: http://alpha.tntbase.mathweb.org:8080/tntbase/ai-mashup/restful/content/docs/dmath?recursive=true&numResults=1&startFrom=2
- Method: GET
- Result: Returns documents (actually only one due to the numResults query parameter) from dmath folder and its subfolders recursevely. Can be substituted by regexp like omstd, but will be not so efficient.
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns" numResults="1"> <tnt:doc name="/omstd/calculus1.omdoc"> <omdoc xmlns="http://www.mathweb.org/omdoc" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:id="calculus1-omdoc"> <metadata> <dc:title>The OpenMath Content Dictionary calculus1.ocd in OMDoc form</dc:title> <dc:creator role="ant">The OpenMath Society</dc:creator> // ... more content goes here </tnt:doc> </tnt:results>
Method
- URL: /content/docs/{path in the repository}
- Method: PUT
- Query parameters:
- recursive (true or false): whether we want to go to the child directories of the {path in the repository} (default: false)
- rev: files revision we want to be cached (default: -1)
- Returns: text/xml
- Description: Caches documents of the specified revision. The path is provided in the url. This path tells TNTBase which documents should be cached. One should not provide a HEAD revision (i.e. -1), because this files are stored in TNTBase anyway. However you can cache the current HEAD revision by providing the revision number of it. Then cached files will be persistent regardles of whether one commited new changes to TNTBase or not.
Example
- URL: http://alpha.tntbase.mathweb.org:8080/tntbase/ai-mashup/restful/content/docs/dmath/en?recursive=true&rev=1
- Method: PUT
- Result: Caches all documents in the /dmath/en folder of revision 1.
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns">
<execution>
<code>7</code>
<message>DOCUMENTS_CACHED :: The documents added to cache :: 27 documents were cached of revision 1</message>
</execution>
</tnt:results>
Method
- URL: /content/docs/{path in the repository}
- Method: DELETE
- Query parameters:
- recursive (true or false): whether we want to go to the child directories of the {path in the repository} (default: false)
- rev: files revision we want to be cached (default: -1)
- Returns: text/xml
- Description: Deletes cached files of the specified revision according to the path in the URL. Files of HEAD revision (-1) can not be deleted from TNTBase
Example
Coming soon
Method
- URL: /content/doc/{{path to file in the repository}}
- Method: GET
- Query parameters:
- wrap (true or false): whether we want to retrieve a wrapped document or not (default: false)
- rev - the revision number of document we want to receive. Default is -1 which means the HEAD revision. Note that you can't retrieve HEAD revision of file other than providing -1. There are some reasons behind it (conceptual, but not technical).
- Returns: text/xml
- Description: returns an XML document. If there is no such a document in TNTBase, then XML wrapper with error code will be returned
Example
- URL:
- Method: GET
- Result: returns the concrete document from TNTBase, or XML error if document does not exist.
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns"> <error> <code>1</code> <message> DOCUMENT_NOT_FOUND :: No such document in database :: /lectures/doc_which_not_exists.omdoc </message> </error> </tnt:results>
Method
- URL: /content/doc/{{path to file in the repository}}
- Method: PUT
- Query parameters:
- rev - revision of a document
- Accepts: application/xml or text/xml
- Returns: text/xml
- Description: Adds or updates an XML document to TNTBase repository and adds svn:mime-type property as text/xml to it. The XML execution result wrapper is returned in case of success, and 403 Forbidden response otherwise. If the rev parameter differs from -1, then the corresponding revision of a document is cached in TNTBase.
Example
- URL: http://localhost:8080/TNTBase/restful/content/doc/examples/induction.omdoc
- Method: PUT
- Request body:
<omdoc xmlns="http://you/should/know/it/by/heart.org"> //There comes weird, but cool OMDOC stuff </omdoc>
- Result: Just an XML execution code. Note that you will receive a 403 FORBIDDEN response if document is not well-formed. This method adds svn:mime-type property which equals to "text/xml" that internally says xSVN that the content should go to TNTBase, thus to be a well-formed document. Generally, if you commit a bunch of XML files one of which is not well-formed, then none of files will be commited (which conforms to SVN ideology, and many others). Note that message element also represents a revision at what it was commited.
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns"> <execution><code>2</code> <message> DOCUMENT_ADDED :: The document was added :: /examples/induction.omdoc Commit info: r35 at Thu Mar 05 00:29:26 CET 2009 </message> </execution> </tnt:results>
Method
- URL: /content/doc/{{path to file in the repository}}
- Method: DELETE
- Query parameters:
- rev - revision of a document
- Returns: text/xml
- Description: Deletes an XML document from TNTBase repository. The execution result wrapper is returned in case of success, and 403 Forbidden response otherwise. If revision parameter is -1, then a document is deleted from HEAD revision, otherwise a cached revision of that document is deleted (if it exists).
Example
- URL: http://localhost:8080/TNTBase/restful/content/doc/examples/induction.omdoc
- Method: DELETE
- Result: The document is deleted, and as the evidence, the XML execution code is sent.
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns"> <execution> <code>1</code> <message> DOCUMENT_DELETED :: The document was deleted :: /examples/induction.omdoc Commit info: r36 at Thu Mar 05 00:37:52 CET 2009 </message> </execution> </tnt:results>
Method
- URL: /content/commit
- Method: PUT
- Returns: text/xml - a new revision number
- Description: Commits multiple files in one request. Uses multipart requests
Example
- URL: https://tnt.kwarc.info/tntbase/stc/restful/content/commit
- Method: PUT
- Request headers:
Content-Type: multipart/mixed; boundary="frontier"
- Request Body:
This is a message with multiple parts in MIME format. --frontier Content-Type: text/xml path: /test/dir/file.omdoc <omdoc> Test </omdoc> --frontier Content-Type: text/plain path: /test/dir/stex.tex Test content a+b --frontier--
- Result: Commits two files: /test/dir/file.omdoc and /test/dir/stex.tex
<tnt:results xmlns:tnt="http://tntbase.mathweb.org/ns"> <tnt:revision>979</tnt:revision> </tnt:results>
