cancel
Showing results for 
Search instead for 
Did you mean: 

Noderef doesn't exist after creation

amandine_b
Champ in-the-making
Champ in-the-making
Hi,

I'm using Alfresco 5.0.1 Enterprise and I have a persistence problem.

I create a NodeRef by using the "copy" fonction :

String nameRep = "122451";
FileInfo FiRep = serviceRegistry.getFileFolderService().copy(sourceNodeRef, destNodeRef, nameRep);
node = FiRep.getNodeRef();


Then, I need to get a specific child of this node :

NamespaceService namespaceService = getServiceRegistry().getNamespaceService();
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
Path pathRep = nodeService.getPath(node);
ResultSet rsRepDA = serviceRegistry.getSearchService().query(storeRef, SearchService.LANGUAGE_LUCENE,
      "PATH:\""+pathRep.toPrefixString(namespaceService)+"/cm:Documents_x0020_contractuels\"");
   
NodeRef result = null;
try
{
   result = rsRepDA.getNodeRef(0);
}
catch (Exception e) {
   log.error("Erreur lors de la récupération du répertoire");
}

Here I get the exception.
In Share interface, my node is not created.

When I'm debugging the code, I can see that the "node" is not null and has a NodeRef reference.
This NodeRef reference doesn't exist when I try to find it by the node browser.

How is it possible to create a Noderef and use it then (into the same action) ?

Thanks !
3 REPLIES 3

mrogers
Star Contributor
Star Contributor
Don't use search to find a child of a node,  its asynchronous and the results will not be available until some time after your current transaction commits.    In your case you can use the node service directly to lookup the child.

amandine_b
Champ in-the-making
Champ in-the-making
Thank you for the explanation ! It works when I use nodeService !

mrogers
Star Contributor
Star Contributor
Don't use search to find a child of a node,  its asynchronous and the results will not be available until some time after your current transaction commits.    In your case you can use the node service directly to lookup the child.