cancel
Showing results for 
Search instead for 
Did you mean: 

Problem getting node from nodeService

wired
Champ in-the-making
Champ in-the-making
I'm having a hard time getting a node with the following details:

Primary Path:   /{http://www.alfresco.org/model/content/1.0}categoryRoot/{http://www.alfresco.org/model/content/1.0}ge... status/{http://www.alfresco.org/model/content/1.0}Screening ok
Type:   {http://www.alfresco.org/model/content/1.0}category

I tried to get it with:

nodeService.getChildByName( rootNodeRef, QName.createQName( "{http://www.alfresco.org/model/content/1.0}category" ), "categories/General/Screening status/Screening ok" ); 
this line returns null
nodeService.getChildByName( rootNodeRef, QName.createQName( "{http://www.alfresco.org/model/content/1.0}category" ), "Screening ok" );
this line returns null

searchService.selectNodes( rootNodeRef, "cm:categoryRoot/cm:generalclassifiable/cm:Screening status/cm:screening ok", null, namespaceService, false );
This last line throws the following exception:

org.alfresco.service.cmr.repository.XPathException: Error executing xpath:
   xpath: cm:categoryRoot/cm:generalclassifiable/cm:Screening status/cm:screening ok
Caused by: org.jaxen.XPathSyntaxException: Unexpected 'status/cm:screening ok'
Caused by: class org.jaxen.saxpath.XPathSyntaxException: cm:categoryRoot/cm:generalclassifiable/cm:Screening status/cm:screening ok: 52: Unexpected 'status/cm:screening ok'

It's clear to me that the space(s) in the name are causing this problem. I cannot simply remove them since there is a lot of javascript code that uses the following lines:
roothome.childByNamePath("categories/General/Screening status/Screening ok").nodeRef;

Anybody any suggestions for solutions?
3 REPLIES 3

dinger
Champ in-the-making
Champ in-the-making
How about sticking "\" before the spaces?

Rob

wired
Champ in-the-making
Champ in-the-making
now i also tried the following with no success:

cm:categoryRoot/cm:generalclassifiable/cm:'Screening status'/cm:'screening ok'
cm:categoryRoot/cm:generalclassifiable/cm:"Screening status"/cm:"screening ok"

cm:categoryRoot/cm:generalclassifiable/'cm:Screening status'/'cm:screening ok'
cm:categoryRoot/cm:generalclassifiable/"cm:Screening status"/"cm:screening ok"

"cm:categoryRoot/cm:generalclassifiable/cm:Screening status/cm:screening ok"
'cm:categoryRoot/cm:generalclassifiable/cm:Screening status/cm:screening ok'

cm:categoryRoot/cm:generalclassifiable/cm:Screening\ status/cm:screening\ ok
cm:categoryRoot/cm:generalclassifiable/cm:Screening\\ status/cm:screening\\ ok

cm:categoryRoot/cm:generalclassifiable/cm:Screening%20status/cm:screening%20ok
cm:categoryRoot/cm:generalclassifiable/cm:Screening status/cm:screening ok
cm:categoryRoot/cm:generalclassifiable/cm:Screening\x20status/cm:screening\x20ok


dinger
Champ in-the-making
Champ in-the-making
See here http://wiki.alfresco.com/wiki/Search#Example_Queries

The space character needs to be replaced with this: _x0020_

HTH

Rob