Skip to end of metadata
Go to start of metadata

Represents the default version of the RESTful API distributed with ModeShape 3. It provides the following methods:


1. Retrieve a list of available repositories

URL: http://<host>:<port>/<context>

HTTP Method: GET

Produces: application/json; text/html; text/plain;

Default Output: text/html

Response Code (if successful): OK

Response Format:


2. Retrieve a list of workspaces for a repository

URL: http://<host>:<port>/<context>/<repository_name>

HTTP Method: GET

Produces: application/json; text/html; text/plain;

Default Output: text/html

Response Code (if successful): OK

Response Format:


3. Retrieve a node or a property

Retrieves an item at a given path.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<item_path>

HTTP Method: GET

Produces: application/json; text/html; text/plain;

Default Output: text/html

Response Code (if successful): OK

Optional Query Parameters:

  • depth - a numeric value indicating how many level of children should be retrieved under the node located at path. A  negative value indicates all children

Response Format:


4. Create a node

Creates a node at the given path, using the body of request as JSON content

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<node_path>

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Default Output: application/json

Request Content-Type: application/json

Response Code (if successful): CREATED

Request Format:

Response Format:

Multiple properties with the same name
The different JSON specs that are out there have conflicting views on whether multiple keys with the same name should be allowed or not. See this for more information.

ModeShape's REST service follows the ECMA JSON specification, which allows multiple keys with the same name, the effective behavior being that the last key always wins.


5. Update a node or a property

Updates a node or a property at the given path, using the body of request as JSON content

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<item_path>

HTTP Method: PUT

Produces: application/json; text/html; text/plain;

Default Output: application/json

Request Content-Type: application/json

Response Code (if successful): OK

Request Format:

Node: same as the one used when creating

Property:

Response Format:

Node: same as one used when creating

Property:


6. Delete a node or a property

Deletes the node or the property at the given path. If a node is being deleted, this will also delete all of its descendants.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<item_path>

HTTP Method: DELETE

Produces: none

Response Code (if successful): NO_CONTENT


7. Retrieve a node by its identifier

Retrieves a node with a specified identifier. This is equivalent to the Session.getNodeByIdentifier(String) method, where the identifier is obtained from the "id" field (or the "jcr:uuid" field if the node is mix:referenceable) in a previous response. Remember that node identifiers are generated by the repository, are opaque (and are not always UUIDs), and always remains the same for a given node (even when moved or renamed) until the node is destroyed.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/nodes/<node_id>

HTTP Method: GET

Produces: application/json; text/html; text/plain;

Default Output: text/html

Response Code (if successful): OK

Optional Query Parameters:

  • depth - a numeric value indicating how many level of children should be retrieved under the node located at path. A  negative value indicates all children

Response Format:


8. Update a node by its identifier

Updates a node with the given identifier, using the body of request as JSON content. The identifier must be obtained from the "id" field in a previous response.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/nodes/<node_id>

HTTP Method: PUT

Produces: application/json; text/html; text/plain;

Default Output: application/json

Request Content-Type: application/json

Response Code (if successful): OK

Request Format:

Node: same as the one used when creating a node

Property:

Response Format:

Node: same as one used when creating a node

Property:


9. Delete a node by its identifier

Deletes the node with the given identifier, and all of its descendants. The identifier must be obtained from the "id" field in a previous response.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/nodes/<node_id>

HTTP Method: DELETE

Produces: none

Response Code (if successful): NO_CONTENT


10. Execute a JCR query

Executes a JCR query in either: XPath, SQL or SQL2 format, returning a JSON object in response.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/query

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Request Content-Type: application/jcr+sql; application/jcr+xpath; application/jcr+sql2; application/jcr+search

Default Output: application/json

Response Code (if successful): OK

Optional Query Parameters:

  • offset - the index in the result set where to start the retrieval of data
  • limit - the maximum number of rows to return

Response Format:


11. Create multiple nodes

Creates multiple nodes (bulk operation) in the repository, using a single session. If any of the nodes cannot be created, the entire operation fails.

URL: _http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Default Output: application/json

Request Content-Type: application/json

Response Code (if successful): OK

Request Format:

Response Format:


12. Update multiple items

Updates multiple nodes and/or properties (bulk operation) in the repository, using a single session. If any of the items cannot be updated, the entire operation fails.

URL: _http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items

HTTP Method: PUT

Produces: application/json; text/html; text/plain;

Default Output: application/json

Request Content-Type: application/json

Response Code (if successful): OK

Request Format: same as the one used when creating multiple nodes.

Response Format: same as the one used when creating multiple nodes.


13. Delete multiple items

Deletes multiple items (bulk operation) in the repository, using a single session. If any of the items cannot be removed, the entire operation fails.

URL: _http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items

HTTP Method: DELETE

Produces: none;

Request Content-Type: application/json

Response Code (if successful): OK

Request Format:


14. Retrieve a node type

Retrieves the information about a registered node type in the repository.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/nodetypes/node_type_name

HTTP Method: GET

Produces: application/json; text/html; text/plain;

Default Output: text/html

Response Code (if successful): OK

Response Format:


15. Import a CND file (via request content)

Imports a CND file into the Repository, using the entire request body stream as the content of the CND. If you were using curl, this would be the equivalent of curl -d

URL: _http://<host>:<port>/<context>/<repository_name>/<workspace_name>/nodetypes

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Default Output: application/json

Response Code (if successful): OK

Response Format:


16. Import a CND file (via "multipart/form-data")

Imports a CND file into the Repository when the CND file came from a form submission, where the name of the HTML element is file. If you were using curl, this would be the equivalent of curl -F

URL: _http://<host>:<port>/<context>/<repository_name>/<workspace_name>/nodetypes

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Request Content-Type: multipart/form-data

Default Output: application/json

Response Code (if successful): OK

Response Format: the same as when importing a CND via the request body.


17. Retrieve a binary property

Retrieves the content of a binary property from the repository, at a given path, by streaming it to the response.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/binary/binary_property_path

HTTP Method: GET

Produces: the mime-type of the binary, or a default mime-type

Response Code (if successful): OK

Optional Query Parameters:

  • mimeType - a string which can be provided by the client, in case it already knows the expected mimetype of the binary stream. Otherwise, ModeShape will try to detect the mimetype using its own detectors mechanism
  • contentDisposition - a string which will be returned as the Content-Disposition response header. If none provide, the default is: attachment;filename=property_parent_name

18. Create a binary property (via request content)

Creates a new binary property in the repository, at the given path, using the entire request body stream as the content of the binary. If you were using curl, this would be the equivalent of curl -d

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/binary/binary_property_path

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Default Output: application/json

Response Code (if successful): OK

Response Format:


19. Update a binary property (via request content)

Updates the content of a binary property in the repository, at the given path, using the entire request body stream as the content of the binary. If you were using curl, this would be the equivalent of curl -d

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/binary/binary_property_path

HTTP Method: POST, PUT

Produces: application/json; text/html; text/plain;

Default Output: application/json

Response Code (if successful): OK

Response Format: the same as in the case when creating a new binary property


20. Create/Update a binary property (via "multipart/form-data")

Creates or updates the content of a binary property in the repository, at the given path, when the content came from a form submission, where the name of the HTML element is file.
If you were using curl, this would be the equivalent of curl -F

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/binary/binary_property_path

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Default Output: application/json

Request Content-Type: multipart/form-data

Response Code (if successful): OK

Response Format: the same as in the case when creating a new binary property


21. Obtain a query plan for a JCR query

Obtain the query plan for an XPath, SQL or SQL2 query, returning the string representation of the query plan.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/queryPlan

HTTP Method: POST

Produces: application/json; text/html; text/plain;

Default Output: text/plain

Request Content-Type: application/jcr+sql; application/jcr+xpath; application/jcr+sql2; application/jcr+search

Response Code (if successful): OK

Optional Query Parameters:

  • offset - the index in the result set where to start the retrieval of data
  • limit - the maximum number of rows to return

Response Format (as "application/json"):

Note that the JSON response contains several fields, including the original query statement, the language, the abstract query model (or AQM, which is always equivalent to the JCR-SQL2 form of the query), and the query plan (as an array of strings).

Response Format (as "text/plain"):

The text response only contains the string representation of the query plan.


22. Reordering nodes

Assuming you create a parent node POSTing the following request:

Then you can reorder its children by issuing a PUT request with the following format:


23. Moving nodes

In order to move a node using the REST service, 2 steps are required:

  1. Retrieve the node which should be moved and store its ID (the id member of the JSON response)
  2. Edit the parent-to-be node (aka. the new parent) via a PUT request which contains the ID of the node:
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.