JBoss Community Archive (Read Only)

ModeShape 5

REST Service

Represents the latest version of the RESTful API distributed with ModeShape 5.4.1.Final. 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:

{
    "repositories":[
        {
            "name":"repo",
            "workspaces":"http://localhost:8090/resources/repo",
            "metadata":{
                "custom.rep.name":"repo",
                "custom.rep.workspace.names":"default",}
                .....
            }
         }
     ]
}

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:

{
    "workspaces":[
        {
            "name":"default",
            "repository":"http://localhost:8090/resources/repo",
            "items":"http://localhost:8090/resources/repo/default/items",
            "query":"http://localhost:8090/resources/repo/default/query",
            "binary":"http://localhost:8090/resources/repo/default/binary",
            "nodeTypes":"http://localhost:8090/resources/repo/default/nodetypes"
        }
    ]
}

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:

{
    "self":"http://localhost:8090/resources/repo/default/items/someNode",
    "up":"http://localhost:8090/resources/repo/default/items/",
    "id":"319a0554-3504-4984-b54b-3a9367caac92",
    "jcr:primaryType":"{http://www.modeshape.org/1.0}root",
    "jcr:uuid":"319a0554-3504-4984-b54b-3a9367caac92",
    "children":{
        "jcr:system":{
            "self":"http://localhost:8090/resources/repo/default/items/jcr:system",
            "up":"http://localhost:8090/resources/repo/default/items/",
            "id": "0a851519-e87d-4e02-b399-0503aa70ab3f"
        }
    }
}

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:

{
    "jcr:primaryType":"nt:unstructured",
    "testProperty":"testValue",
    "multiValuedProperty":["value1", "value2"],
    "children":{
        "childNode":{
            "nestedProperty":"nestedValue"
        }
    }
}

Response Format:

{
    "self":"http://localhost:8090/resources/repo/default/items/testNode",
    "up":"http://localhost:8090/resources/repo/default/items/",
    "id":"bf171df0-daa2-481d-a48a-b3965cd69d9c",
    "jcr:primaryType":"{http://www.jcp.org/jcr/nt/1.0}unstructured",
    "multiValuedProperty":[
        "value1",
        "value2"
    ],
    "testProperty":"testValue",
    "children":{
        "childNode":{
            "self":"http://localhost:8090/resources/repo/default/items/testNode/childNode",
            "up":"http://localhost:8090/resources/repo/default/items/testNode",
            "id":"113e6eea-cbd2-4837-8344-5b28bbfd695c",
        }
    }
} 
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.

Same Name Siblings

Because of the above, creating SNS children in a request cannot be done using a JSON object format for the children element. The REST service supports an alternative, array-based format:

{
    "children": [
        {
            "foo": {
                "property": "first"
            }
        },
        {
            "foo": {
                "property": "second"
            }
        }
    ]
}

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:

{"testProperty":"some_new_value"}

Response Format:

Node: same as one used when creating

Property:

{"testProperty":"some_new_value"}

Same Name Siblings

When updating the SNS children of a given node, 2 requests format are available:

  1. An array-based format similar to the one described for the "create" case:

    {
        "children": [
            {
                "foo": {
                    "property": "editedFirst"
                }
            },
            {
                "foo": {
                    "property": "editedSecond"
                }
            }
        ]
    }
  2. An object format where the name of each SNS contains its index:

     {
        "children": {
            "foo": {
                "property": "editedFirst"
            },
            "foo[2]": {
                "property": "editedSecond"
            }
        }
    }

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:

{
    "self":"http://localhost:8090/resources/repo/default/items/someNode",
    "up":"http://localhost:8090/resources/repo/default/items/",
    "id":"319a0554-3504-4984-b54b-3a9367caac92",
    "jcr:primaryType":"{http://www.modeshape.org/1.0}root",
    "jcr:uuid":"319a0554-3504-4984-b54b-3a9367caac92",
    "children":{
        "jcr:system":{
            "self":"http://localhost:8090/resources/repo/default/items/jcr:system",
            "up":"http://localhost:8090/resources/repo/default/items/",
            "id": "0a851519-e87d-4e02-b399-0503aa70ab3f"
        }
    }
}

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:

{"testProperty":"some_new_value"}

Response Format:

Node: same as one used when creating a node

Property:

{"testProperty":"some_new_value"}

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:

{
    "columns":{
        "jcr:path":"STRING",
        "jcr:score":"DOUBLE",
        "foo":"STRING"
    },
    "rows":[
        {
            "jcr:path":"/{}testNode/{}child[2]",
            "jcr:score":"0.8575897812843323",
            "foo":"value",
            "mode:uri":"http://localhost:8090/resources/repo/default/items/testNode/child[2]"
        },
        {
            "jcr:path":"/{}testNode/{}child[3]",
            "jcr:score":"0.8575897812843323",
            "foo":"value",
            "mode:uri":"http://localhost:8090/resources/repo/default/items/testNode/child[3]"
        }
    ]
}

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:

{
    "testNode/child/subChild" : {
        "jcr:primaryType":"nt:unstructured",
        "testProperty":"testValue",
        "multiValuedProperty":["value1", "value2"]
    },
    "testNode/child" : {
        "jcr:primaryType":"nt:unstructured",
        "testProperty":"testValue",
        "multiValuedProperty":["value1", "value2"]
    },
    "testNode/otherChild" : {
        "jcr:primaryType":"nt:unstructured",
        "testProperty":"testValue",
        "multiValuedProperty":["value1", "value2"],
        "children":{
            "otherSubChild":{
                "nestedProperty":"nestedValue"
            }
        }
    }
}

Response Format:

[
    {
        "self":"http://localhost:8090/resources/repo/default/items/testNode/child",
        "up":"http://localhost:8090/resources/repo/default/items/testNode",
        "id":"0ef2edc9-c873-4a2f-805e-2950b98225c6",
        "jcr:primaryType":"{http://www.jcp.org/jcr/nt/1.0}unstructured",
        "multiValuedProperty":[
            "value1",
            "value2"
        ],
        "testProperty":"testValue"
    },
    {
        "self":"http://localhost:8090/resources/repo/default/items/testNode/child/subChild",
        "up":"http://localhost:8090/resources/repo/default/items/testNode/child",
        "id":"fb6f4d82-33e1-4bc1-8048-d1f9a685779b",
        "jcr:primaryType":"{http://www.jcp.org/jcr/nt/1.0}unstructured",
        "multiValuedProperty":[
            "value1",
            "value2"
        ],
        "testProperty":"testValue"
    },
    {
        "self":"http://localhost:8090/resources/repo/default/items/testNode/otherChild",
        "up":"http://localhost:8090/resources/repo/default/items/testNode",
        "id":"da12f5f9-4ab9-48d7-a159-07144e378d54",
        "jcr:primaryType":"{http://www.jcp.org/jcr/nt/1.0}unstructured",
        "multiValuedProperty":[
            "value1",
            "value2"
        ],
        "testProperty":"testValue",
        "children":{
            "otherSubChild":{
                "self":"http://localhost:8090/resources/repo/default/items/testNode/otherChild/otherSubChild",
                "up":"http://localhost:8090/resources/repo/default/items/testNode/otherChild"
                "id":"21ea01f5-e41c-4aea-9087-e241e02a4b2d",
            }
        }
    }
]

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:

["testNode/otherChild", "testNode/child",  "testNode/child/subChild"]

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:

{
    "nt:base":{
        "mixin":false,
        "abstract":true,
        "queryable":true,
        "hasOrderableChildNodes":false,
        "propertyDefinitions":[
            {
                "jcr:primaryType":{
                    "requiredType":"Name",
                    "declaringNodeTypeName":"nt:base",
                    "mandatory":true,
                    "multiple":false,
                    "autocreated":true,
                    "protected":true,
                    "fullTextSearchable":true,
                    "onParentVersion":"COMPUTE"
                }
            },
            {
                "jcr:mixinTypes":{
                    "requiredType":"Name",
                    "declaringNodeTypeName":"nt:base",
                    "mandatory":false,
                    "multiple":true,
                    "autocreated":false,
                    "protected":true,
                    "fullTextSearchable":true,
                    "onParentVersion":"COMPUTE"
                }
            }
        ],
        "subTypes":[
            "http://localhost:8090/resources/repo/default/nodetypes/mode:lock",
            "http://localhost:8090/resources/repo/default/nodetypes/mode:locks",
             ....
        ]
    }
}

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:

[
    {
        "nt:base":{
            "mixin":false,
            "abstract":true,
            "queryable":true,
            "hasOrderableChildNodes":false,
            "propertyDefinitions":[
                {
                    "jcr:primaryType":{
                        "requiredType":"Name",
                        "declaringNodeTypeName":"nt:base",
                        "mandatory":true,
                        "multiple":false,
                        "autocreated":true,
                        "protected":true,
                        "fullTextSearchable":true,
                        "onParentVersion":"COMPUTE"
                    }
                },
                {
                    "jcr:mixinTypes":{
                        "requiredType":"Name",
                        "declaringNodeTypeName":"nt:base",
                        "mandatory":false,
                        "multiple":true,
                        "autocreated":false,
                        "protected":true,
                        "fullTextSearchable":true,
                        "onParentVersion":"COMPUTE"
                    }
                }
            ],
            "subTypes":[
                "http://localhost:8090/resources/repo/default/nodetypes/mode:lock",
                ...
            ]
        }
    },
    {
        "nt:unstructured":{
            "mixin":false,
            "abstract":false,
            "queryable":true,
            "hasOrderableChildNodes":true,
            "propertyDefinitions":[
                {
                    "*":{
                        "requiredType":"undefined",
                        "declaringNodeTypeName":"nt:unstructured",
                        "mandatory":false,
                        "multiple":true,
                        "autocreated":false,
                        "protected":false,
                        "fullTextSearchable":true,
                        "onParentVersion":"COPY"
                    }
                },
                {
                    "*":{
                        "requiredType":"undefined",
                        "declaringNodeTypeName":"nt:unstructured",
                        "mandatory":false,
                        "multiple":false,
                        "autocreated":false,
                        "protected":false,
                        "fullTextSearchable":true,
                        "onParentVersion":"COPY"
                    }
                }
            ],
            "superTypes":[
                "http://localhost:8090/resources/repo/default/nodetypes/nt:base"
            ]
        }
    },
    {
        "mix:created":{
            "mixin":true,
            "abstract":false,
            "queryable":true,
            "hasOrderableChildNodes":false,
            "propertyDefinitions":[
                {
                    "jcr:created":{
                        "requiredType":"Date",
                        "declaringNodeTypeName":"mix:created",
                        "mandatory":false,
                        "multiple":false,
                        "autocreated":false,
                        "protected":true,
                        "fullTextSearchable":true,
                        "onParentVersion":"COPY"
                    }
                },
                {
                    "jcr:createdBy":{
                        "requiredType":"String",
                        "declaringNodeTypeName":"mix:created",
                        "mandatory":false,
                        "multiple":false,
                        "autocreated":false,
                        "protected":true,
                        "fullTextSearchable":true,
                        "onParentVersion":"COPY"
                    }
                }
            ],
            "subTypes":[
                "http://localhost:8090/resources/repo/default/nodetypes/nt:hierarchyNode"
            ]
        }
    }
]

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:

{
    "testProperty":"http://localhost:8090/resources/repo/default/binary/testNode/testProperty",
    "self":"http://localhost:8090/resources/repo/default/items/testNode/testProperty",
    "up":"http://localhost:8090/resources/repo/default/items/testNode"
}

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"):

{
    "statement":"SELECT * FROM [nt:unstructured] WHERE ISCHILDNODE('\/testNode')",
    "language":"JCR-SQL2",
    "abstractQueryModel":"SELECT * FROM [nt:unstructured] WHERE ISCHILDNODE([nt:unstructured],'\/testNode')",
    "queryPlan": [
         "Access [nt:unstructured]",
         "  Project [nt:unstructured] <PROJECT_COLUMNS=[[nt:unstructured].[jcr:primaryType] AS [nt:unstructured.jcr:primaryType], [nt:unstructured].[jcr:mixinTypes] AS [nt:unstructured.jcr:mixinTypes], [nt:unstructured].[jcr:path] AS [nt:unstructured.jcr:path], [nt:unstructured].[jcr:name] AS [nt:unstructured.jcr:name], [nt:unstructured].[jcr:score] AS [nt:unstructured.jcr:score], [nt:unstructured].[mode:localName] AS [nt:unstructured.mode:localName], [nt:unstructured].[mode:depth] AS [nt:unstructured.mode:depth]], PROJECT_COLUMN_TYPES=[STRING, STRING, STRING, STRING, DOUBLE, STRING, LONG]>",
         "    Select [nt:unstructured] <SELECT_CRITERIA=ISCHILDNODE([nt:unstructured],'\/testNode')>",
         "      Select [nt:unstructured] <SELECT_CRITERIA=[nt:unstructured].[jcr:primaryType] = 'nt:unstructured'>",
         "        Source [nt:unstructured] <SOURCE_NAME=__ALLNODES__, SOURCE_COLUMNS=[jcr:frozenUuid(STRING), mode:sharedUuid(REFERENCE), mode:sessionScope(BOOLEAN), jcr:defaultValues(STRING), mode:projectedNodeKey(STRING), jcr:mixinTypes(STRING), jcr:frozenPrimaryType(STRING), jcr:defaultPrimaryType(STRING), jcr:statement(STRING), jcr:lastModifiedBy(STRING), jcr:mimeType(STRING), jcr:hasOrderableChildNodes(BOOLEAN), jcr:etag(STRING), jcr:encoding(STRING), jcr:root(REFERENCE), jcr:supertypes(STRING), jcr:successors(REFERENCE), jcr:primaryItemName(STRING), jcr:hold(STRING), jcr:workspace(STRING), jcr:description(STRING), jcr:primaryType(STRING), mode:externalNodeKey(STRING), mode:derivedFrom(STRING), mode:isHeldBySession(BOOLEAN), jcr:baseVersion(REFERENCE), jcr:lastModified(DATE), jcr:mergeFailed(REFERENCE), mode:derivedAt(DATE), jcr:requiredPrimaryTypes(STRING), jcr:multiple(BOOLEAN), mode:generated(BOOLEAN), jcr:activityTitle(STRING), jcr:lifecyclePolicy(REFERENCE), jcr:isMixin(BOOLEAN), jcr:availableQueryOperators(STRING), jcr:childVersionHistory(REFERENCE), jcr:content(REFERENCE), jcr:autoCreated(BOOLEAN), mode:alias(STRING), jcr:createdBy(STRING), jcr:isFullTextSearchable(BOOLEAN), jcr:uuid(STRING), jcr:onParentVersion(STRING), mode:expirationDate(DATE), jcr:lockIsDeep(BOOLEAN), jcr:copiedFrom(REFERENCE), jcr:isDeep(BOOLEAN), jcr:title(STRING), jcr:versionableUuid(STRING), jcr:versionHistory(REFERENCE), jcr:isAbstract(BOOLEAN), jcr:predecessors(REFERENCE), jcr:lockOwner(STRING), mode:sha1(STRING), jcr:repository(STRING), jcr:created(DATE), jcr:frozenMixinTypes(STRING), mode:lockedKey(STRING), jcr:text(STRING), jcr:host(STRING), jcr:configuration(REFERENCE), jcr:port(STRING), mode:workspace(STRING), jcr:nodeTypeName(STRING), jcr:data(BINARY), jcr:isQueryable(BOOLEAN), jcr:language(STRING), jcr:isQueryOrderable(BOOLEAN), jcr:mandatory(BOOLEAN), jcr:isCheckedOut(BOOLEAN), jcr:protected(BOOLEAN), jcr:sameNameSiblings(BOOLEAN), jcr:requiredType(STRING), jcr:protocol(STRING), mode:lockingSession(STRING), jcr:messageId(STRING), jcr:id(REFERENCE), mode:uri(STRING), jcr:valueConstraints(STRING), jcr:retentionPolicy(REFERENCE), jcr:activity(REFERENCE), jcr:currentLifecycleState(STRING), jcr:path(STRING), jcr:name(STRING), jcr:score(DOUBLE), mode:localName(STRING), mode:depth(LONG)], SOURCE_ALIAS=nt:unstructured>"
        ]
}

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"):

Access [nt:unstructured]
  Project [nt:unstructured] <PROJECT_COLUMNS=[[nt:unstructured].[jcr:primaryType] AS [nt:unstructured.jcr:primaryType], [nt:unstructured].[jcr:mixinTypes] AS [nt:unstructured.jcr:mixinTypes], [nt:unstructured].[jcr:path] AS [nt:unstructured.jcr:path], [nt:unstructured].[jcr:name] AS [nt:unstructured.jcr:name], [nt:unstructured].[jcr:score] AS [nt:unstructured.jcr:score], [nt:unstructured].[mode:localName] AS [nt:unstructured.mode:localName], [nt:unstructured].[mode:depth] AS [nt:unstructured.mode:depth]], PROJECT_COLUMN_TYPES=[STRING, STRING, STRING, STRING, DOUBLE, STRING, LONG]>
    Select [nt:unstructured] <SELECT_CRITERIA=ISCHILDNODE([nt:unstructured],'/testNode')>
      Select [nt:unstructured] <SELECT_CRITERIA=[nt:unstructured].[jcr:primaryType] = 'nt:unstructured'>
        Source [nt:unstructured] <SOURCE_ALIAS=nt:unstructured, SOURCE_NAME=__ALLNODES__, SOURCE_COLUMNS=[jcr:frozenUuid(STRING), mode:sharedUuid(REFERENCE), mode:sessionScope(BOOLEAN), jcr:defaultValues(STRING), mode:projectedNodeKey(STRING), jcr:mixinTypes(STRING), jcr:frozenPrimaryType(STRING), jcr:defaultPrimaryType(STRING), jcr:statement(STRING), jcr:lastModifiedBy(STRING), jcr:mimeType(STRING), jcr:hasOrderableChildNodes(BOOLEAN), jcr:etag(STRING), jcr:encoding(STRING), jcr:root(REFERENCE), jcr:supertypes(STRING), jcr:successors(REFERENCE), jcr:primaryItemName(STRING), jcr:hold(STRING), jcr:workspace(STRING), jcr:description(STRING), jcr:primaryType(STRING), mode:externalNodeKey(STRING), mode:derivedFrom(STRING), mode:isHeldBySession(BOOLEAN), jcr:baseVersion(REFERENCE), jcr:lastModified(DATE), jcr:mergeFailed(REFERENCE), mode:derivedAt(DATE), jcr:requiredPrimaryTypes(STRING), jcr:multiple(BOOLEAN), mode:generated(BOOLEAN), jcr:activityTitle(STRING), jcr:lifecyclePolicy(REFERENCE), jcr:isMixin(BOOLEAN), jcr:availableQueryOperators(STRING), jcr:childVersionHistory(REFERENCE), jcr:content(REFERENCE), jcr:autoCreated(BOOLEAN), mode:alias(STRING), jcr:createdBy(STRING), jcr:isFullTextSearchable(BOOLEAN), jcr:uuid(STRING), jcr:onParentVersion(STRING), mode:expirationDate(DATE), jcr:lockIsDeep(BOOLEAN), jcr:copiedFrom(REFERENCE), jcr:isDeep(BOOLEAN), jcr:title(STRING), jcr:versionableUuid(STRING), jcr:versionHistory(REFERENCE), jcr:isAbstract(BOOLEAN), jcr:predecessors(REFERENCE), jcr:lockOwner(STRING), mode:sha1(STRING), jcr:repository(STRING), jcr:created(DATE), jcr:frozenMixinTypes(STRING), mode:lockedKey(STRING), jcr:text(STRING), jcr:host(STRING), jcr:configuration(REFERENCE), jcr:port(STRING), mode:workspace(STRING), jcr:nodeTypeName(STRING), jcr:data(BINARY), jcr:isQueryable(BOOLEAN), jcr:language(STRING), jcr:isQueryOrderable(BOOLEAN), jcr:mandatory(BOOLEAN), jcr:isCheckedOut(BOOLEAN), jcr:protected(BOOLEAN), jcr:sameNameSiblings(BOOLEAN), jcr:requiredType(STRING), jcr:protocol(STRING), mode:lockingSession(STRING), jcr:messageId(STRING), jcr:id(REFERENCE), mode:uri(STRING), jcr:valueConstraints(STRING), jcr:retentionPolicy(REFERENCE), jcr:activity(REFERENCE), jcr:currentLifecycleState(STRING), jcr:path(STRING), jcr:name(STRING), jcr:score(DOUBLE), mode:localName(STRING), mode:depth(LONG)]>

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:

{
    "jcr:primaryType":"nt:unstructured",
    "children":{
        "child1":{
            "prop":"child1"
        },
        "child2":{
            "prop":"child2"
        },
        "child3":{
            "prop":"child3"
        }
    }
}

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

{
    "children":{
        "child3":{
        },
        "child2":{
        },
        "child1":{
        }
    }
}

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:

    {
        "children":{
            "child1":{
            },
            "child2":{
            },
            "child3":{
            },
            "41e666ff-0997-4ee0-9eb8-b41319f9f403": {
            }
        }
    }

24. Upload a binary (via request content) under a hierarchy of nodes

Uploads (create/updates) a binary property of a node as part of a hierarchy using the entire request body stream as the content of the binary, creating missing parts of the hierarchy. If you were using curl, this would be the equivalent of curl -d.
If any segment of the hierarchy does not exist, it will be created as an [nt:folder] node, while the last segment in the hierarchy, if it does not exist, will be created as an [nt:file] node.

If any segment in the hierarchy does exist it will not be created, but the binary value is always uploaded & added as property named [jcr:data] under a [jcr:content] child of the last node in the hierarchy.

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/upload/<path>

HTTP Method: POST

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

Default Output: application/json

Response Code (if successful): OK (if the binary property existed previously and was updated) or CREATED (if the binary property is created)

Example: executing POST http://localhost:8080/modeshape-rest/repo/default/upload/node1/node2/node3 on an empty repository, will create the hierarchy node1(nt:folder)/node2(nt:folder)/node3(nt:file)/jcr:content(nt:resource) under the root node and set the value of the jcr:data property of node3/jcr:content to the binary content read from the request body.

If this hierarchy existed previously with the same node types, the request will update the property replacing its binary content. If this hierarchy existed previously but with different node types, it is expected that node3 allows a child named [jcr:content] with a [jcr:data] property.

Using CURL: curl -X POST --data-binary @image.png --user admin:admin http://localhost:8080/modeshape-rest/sample/default/upload/image.png

25. Upload a binary (via "multipart/form-data") under a hierarchy of nodes

Uploads (create/updates) a binary property of a node as part of a hierarchy when the binary content comes from a form submission and the name of the HTML element is file, creating missing parts of the hierarchy.
If you were using curl, this would be the equivalent of curl -F

URL: http://<host>:<port>/<context>/<repository_name>/<workspace_name>/upload/<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 (if the binary property existed previously and was updated) or CREATED (if the binary property is created)

The behavior is identical to that of the previous method (see above), the only difference being the content type of the request.

Using CURL: curl -X POST -F "file=@image.png" --user admin:admin http://localhost:8080/modeshape-rest/sample/default/upload/image.png

26. Backup a repository

Performs a repository backup on the server into one of the following locations (the first available one will be used):

  1. the backupLocation servlet context parameter, if defined in the web.xml configuration file of the web application which contains the REST Service

  2. the value of the jboss.domain.data.dir system property (is normally available when running a JBoss Application Server in domain mode). If available defaults to ${JBOSS_HOME}/domain/data.

  3. the value of the jboss.standalone.data.dir system property (is normally available when running a JBoss Application Server in standalone mode). If available defaults to ${JBOSS_HOME}/standalone/data.

  4. the value of the user.home system property

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

HTTP Method: POST

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

Default Output: application/json

Response Code (if successful): CREATED

Using CURL: curl -X POST --user dnauser:password http://localhost:8090/resources/repo/backup will produce:

{ "name":"modeshape_43-SNAPSHOT_repo_backup_07042015_111243",
  "url":"file:\/.../web\/modeshape-web-jcr-rest-war\/target\/modeshape_43-SNAPSHOT_repo_backup_07042015_111243\/"

There are also a number of optional request parameters which can be passed to control the backup behavior:

Parameter

Default

Description

includeBinaries

true

Whether binary values should be included in the backup or not. If your repository has a large amount of binary values, you may want to exclude them since it can cause the backup to take a very long time

documentsPerFile

100000

The number of documents (i.e. entries stored by ModeShape in Infinispan) to be included in each backup file

compress

true

Whether or not each file containing documents should be compressed or not

batchSize

10000

The number of documents which should be read and stored in the backup in a single batch

27. Restore a repository

Performs a repository restore on the server by using the name of the given backup folder and searching for it into one of the following locations (the first available one will be used):

  1. the backupLocation servlet context parameter, if defined in the web.xml configuration file of the web application which contains the REST Service

  2. the value of the jboss.domain.data.dir system property (is normally available when running a JBoss Application Server in domain mode). If available defaults to ${JBOSS_HOME}/domain/data.

  3. the value of the jboss.standalone.data.dir system property (is normally available when running a JBoss Application Server in standalone mode). If available defaults to ${JBOSS_HOME}/standalone/data.

  4. the value of the user.home system property

The name of the backup folder should be retrieved from the response of the repository backup request (see above).

URL: http://<host>:<port>/<context>/<repository_name>/restore?name=<backup_folder>

HTTP Method: POST

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

Default Output: application/json

Response Code (if successful): OK

Using CURL: curl -X POST --user dnauser:password http://localhost:8090/resources/repo/restore?name=modeshape_43-SNAPSHOT_repo_backup_07042015_111243

There are also a number of optional request parameters which can be passed to control the restore behavior:

Parameter

Default

Description

name

none, you must provide it

The name of a backup folder on the server which will be used as the source of the data

includeBinaries

true

Whether binary values should be restored from the backup folder or not

reindexContent

true

Whether or not a reindexing of the content should be performed once the restore is complete. If the backup contains lots of data and you already have accurate indexes created prior to the backup, you may
want to skip this

batchSize

1000

The number of documents which should be read from the backup and stored in the repository in a batch

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:12:51 UTC, last content change 2016-04-09 05:35:34 UTC.