-
1. Re: Return node identifier in REST service?
rhauch Oct 2, 2012 4:32 PM (in response to jonathandfields)The newer RESTful API should already be including the "jcr:uuid" property in the response, and this is the same as "node.getIdentifier()". Are you not seeing this, or might you be using the older RESTful API (which is still available in 3.0, but just at a different URL)?
-
2. Re: Return node identifier in REST service?
jonathandfields Oct 2, 2012 4:55 PM (in response to rhauch)That is what I was expecting as well. I'm using 3.0. For example:
POST http://localhost:8080/modeshape-rest/sample/default/items/node1
{
'jcr:primaryType': 'nt:unstructured',
'prop1':'val1'
}
GET http://localhost:8080/modeshape-rest/sample/default/items/node1
{
"self": "http://localhost:8080/modeshape-rest/sample/default/items/node1",
"up": "http://localhost:8080/modeshape-rest/sample/default/items/",
"jcr:primaryType": "{http://www.jcp.org/jcr/nt/1.0}unstructured",
"prop1": "val1"
}
-
3. Re: Return node identifier in REST service?
rhauch Oct 2, 2012 4:59 PM (in response to jonathandfields)Hmm... okay, can you log an issue?
-
4. Re: Return node identifier in REST service?
jonathandfields Oct 2, 2012 5:09 PM (in response to rhauch)MODE-1657 created.
Thanks, Jon.
-
5. Re: Return node identifier in REST service?
hchiorean Oct 3, 2012 4:13 AM (in response to jonathandfields)Just a note: if a node is referenceable (aka mix:referenceable) the jcr:uuid should be returned together with the other properties. The identifier (which is a special field) isn't atm. The enhancement request should fix this.
-
6. Re: Return node identifier in REST service?
jonathandfields Oct 3, 2012 11:33 AM (in response to hchiorean)I had actually tried that first. If have this nodetype, which includes mix:referenceable
GET http://localhost:8080/modeshape-rest/sample/default/nodetypes/ex:mytype { "ex:mytype": { "mixin": false, "abstract": false, "queryable": true, "hasOrderableChildNodes": false, "superTypes": [ "http://localhost:8080/modeshape-rest/sample/default/nodetypes/mix:referenceable", "http://localhost:8080/modeshape-rest/sample/default/nodetypes/nt:unstructured" ] } }
And create a node of that type:
POST http://localhost:8080/modeshape-rest/sample/default/items/mynode { 'jcr:primaryType': 'ex:mytype', 'prop1':'val1' }
And then retrieve the node, I get the following results, which does not include jcr:uuid:
GET http://localhost:8080/modeshape-rest/sample/default/items/mynode { "self": "http://localhost:8080/modeshape-rest/sample/default/items/mynode", "up": "http://localhost:8080/modeshape-rest/sample/default/items/", "jcr:primaryType": "{http://www.example.com/}mytype", "prop1": "val1" }
I think it should include jcr:uuid, unless I am misunderstanding something.... (In fact, using the Java API, it does not appear as if "mynode" has a "jcr:uuid" property at all, which may be the root issue.)
However, using mix:referenceable/jcr:uuid really does not satisfy my use case, so I would still want to see the Node.getIdentifier() value in the REST service. The reason is that I am creating nodes using the REST service, and want to use the identifier to relate external resources (e.g. files or rows in a database) with the newly created node. This is because if the node is deleted, I want to detect that using Observation, and delete the corresponding external resource. The Observation Event only includes the path and identifier, and the event appears to be triggered after the node has been deleted, so the only information you have on which to delete the external resource is the path and ID. Since the node can be moved, the path is not an immutable identifier, hence the desire to use the identifier. Hope this makes sense.....
-
7. Re: Return node identifier in REST service?
hchiorean Oct 3, 2012 11:38 AM (in response to jonathandfields)This is interesting (and possibly a bug from a JCR perspective, although I'm not 100% sure): you basically have a type that has the mix:referenceable mixin and that does not trigger the addition of the jcr:uuid property on session.save().
The "inner id" part I've already added and submitted a pull request which will be merged shortly.
-
8. Re: Return node identifier in REST service?
jonathandfields Oct 3, 2012 11:50 AM (in response to hchiorean)Great, thank you.