Este conteúdo não está disponível no idioma selecionado.

17.23. Modify Repository Content


It is also possible to use the RESTful API to add, modify and remove repository content. Removal is simple - a DELETE request with no body returns a response with no body.
DELETE http://www.example.com/modeshape-rest/eds/default/items/path/to/deletedNode
Adding content requires a POST to the name of the relative root node of the content that you wish to add and a request body in the same format as the response from a GET. Adding multiple nodes at once is supported, as shown below.
POST http://www.example.com/modeshape-rest/eds/default/items/newNode
{
   "properties": {
      "jcr:primaryType": "nt:unstructured",
      "jcr:mixinTypes": "mix:referenceable",
      "someProperty": "foo"
   },
   "children": {
      "newChildNode": {
         "properties": {"jcr:primaryType": "nt:unstructured"}
      }
   }
}
Note that protected properties like jcr:uuid are not provided but that the primary type and mixin types are provided as properties. The REST server will translate these into the appropriate calls behind the scenes. The JSON-encoded response from the request will contain the node that you just posted, including any autocreated properties and child nodes.
If you do not need this information, add mode:includeNode=false as a query parameter to your URL.
POST http://www.example.com/modeshape-rest/eds/default/items/newNode?mode:includeNode=false

{
   "properties": {
      "jcr:primaryType": "nt:unstructured",
      "jcr:mixinTypes": "mix:referenceable",
      "someProperty": "foo"
   },
   "children": {
      "newChildNode": {
         "properties": {"jcr:primaryType": "nt:unstructured"}
      }
   }
}
This will instruct the REST server to only return the path of the newly-created node in the response.
The PUT method allows for updates of nodes and properties. If the URI points to a property, the body of the request must contain the new JSON-encoded value for the property, which includes the property name, allowing proper determination of whether the values are binary.
PUT http://www.example.com/modeshape-rest/eds/default/items/some/existing/node/someProperty

{
   "someProperty" : "bar"
}
Setting multiple properties at once can be performed by providing a URI to a node instead of a property. The body of the request should then be a JSON object that maps property names to their new values.
PUT http://www.example.com/modeshape-rest/eds/default/items/some/existing/node

{
   "someProperty": "foobar",
   "someOtherProperty": "newValue"
}
The JSON request can even contain a properties container:
PUT http://www.example.com/modeshape-rest/eds/default/items/some/existing/node

{
   "properties": {
      "someProperty": "foobar",
      "someOtherProperty": "newValue"
   }
}
A subgraph can be updated all at once using a PUT against a URI of the top node in the subgraph. Note that, in this case, every node in the subgraph must be provided in the JSON request (any node not in the request will be removed). This method will attempt to set all of the properties to the new values as specified in the JSON request, plus any descendant node in the JSON request that does not reflect an existing node will be created while any existing node not reflected in the JSON request will be removed. Any specifications of jcr:primaryType are ignored if the node already exists. In other words, the request only needs to contain the properties that are changed. Of course, if a node is being added, all of its properties need to be included in the request.
Here is an example:
PUT http://www.example.com/modeshape-rest/eds/default/items/some/existing/node

{
   "properties": {
      "jcr:primaryType": "nt:unstructured",
      "jcr:mixinTypes": "mix:referenceable",
      "someProperty": "foo"
   },
   "children": {
      "childNode": {
         "properties": {"jcr:primaryType": "nt:unstructured"}
      }
   }
}
This will update the existing node at /some/existing/node with the specified properties, and ensure that it contains one child node named childNode. Note that the body of this request is identical in structure to that of the POST requests.
Red Hat logoGithubredditYoutubeTwitter

Aprender

Experimente, compre e venda

Comunidades

Sobre a documentação da Red Hat

Ajudamos os usuários da Red Hat a inovar e atingir seus objetivos com nossos produtos e serviços com conteúdo em que podem confiar. Explore nossas atualizações recentes.

Tornando o open source mais inclusivo

A Red Hat está comprometida em substituir a linguagem problemática em nosso código, documentação e propriedades da web. Para mais detalhes veja o Blog da Red Hat.

Sobre a Red Hat

Fornecemos soluções robustas que facilitam o trabalho das empresas em plataformas e ambientes, desde o data center principal até a borda da rede.

Theme

© 2026 Red Hat
Voltar ao topo