2

Is it possible via a SLING query to access to a whole node by GUID?

I know that it is possible to do a search by GUID but it means that after doing the search we must do an other query to get the node.

I would like to get a node with only one query.

Yacine Zalouani
  • 7,999
  • 6
  • 25
  • 24
  • 1
    I'm not sure that I would want to use GUIDs directly if it is at all avoidable, why use these instead of the node path? Also it might help if you post the query you are using. – antonyh Oct 11 '12 at 14:48
  • The problem is that the node path could change as the app evolve. The GUID never changes ... – Yacine Zalouani Oct 12 '12 at 08:50
  • Did you manage to find a solution to this? Also, is the GUID the same when content is activated / replicated / published? I was under the impression that it's a instance local identifier and not shared between repositories. – antonyh Dec 13 '12 at 23:08
  • No I didn't find a solution :/ – Yacine Zalouani Dec 14 '12 at 13:47
  • @webnoob - Don't understand your point. None of the answer were acceptable so why would I accept them ? – Yacine Zalouani Dec 17 '12 at 10:17

2 Answers2

4

You can access the node by identifier programatically using this the java.jcr.Session.getNodeByIdentifier

http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/Session.html#getNodeByIdentifier(java.lang.String)

If you want to be able to have access to it through a HTTP request, then create a servlet that would expose this functionality.

notdang
  • 500
  • 2
  • 8
1

You can get the node by UUID using either an XPATH query such as

/jcr:root//*[@jcr:uuid='b1e1d3c3-983c-33d6-811c-18d2a8824e03']

or

node = Session.getNodeByIdentifier(String id);

there's a good code sample here: Jackrabbit Running Queries against UUID

You can also try

propertyIterator = node.getReferences();

This appears to rely on mix:referenceable, which may not be the case for your nodes.
Javadoc: http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/Node.html#getReferences() Related question: Jackrabbit - node.getReferences() not returning anything

Community
  • 1
  • 1
antonyh
  • 2,131
  • 2
  • 21
  • 42