jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viz06 <vijaykumarsharma_1...@yahoo.com>
Subject Re: Adding child to node obatined from iterator doesn't work
Date Wed, 25 Jun 2008 14:03:31 GMT

Alex,

Thanks for looking at this.

Here is the snippet of code which I am attempting (removed some details
which are not relevant)


String nodeSearchPath = "//nms:root/*/nms:node1";
        
QueryManager queryManager = this.jcrTemplate.getSessionFactory()
            .getSession().getWorkspace().getQueryManager();
        
Query jcrQuery = queryManager.createQuery(nodeSearchPath, Query.XPATH);
        
NodeIterator nodeIterator =  jcrQuery.execute().getNodes();

Node parentNode = null;
        
if (nodeIterator.hasNext())
{
    parentNode = nodeIterator.nextNode();

    //cannot add child to this node, uncomment following to make this work
    //parentNode = this.jcrTemplate.getNodeByUUID(parentNode.getUUID());
}
else
{
    Node rootNode = this.jcrTemplate.getRootNode();
    parentNode = rootNode.addNode("nms:root");
    parentNode.setProperty("name", "root");
    this.jcrTemplate.save();
}

Node folderNode = parentNode.addNode("child1");
            
folderNode.setProperty("name", "child1");
                    
this.jcrTemplate.save();

I have wrongly mentioned that these are 2 separate txn, in fact they are
part of same txn. If I uncomment code mentioned in 'if' block then I am able
to add the child node.




-- 
View this message in context: http://www.nabble.com/Adding-child-to-node-obatined-from-iterator-doesn%27t-work-tp18108121p18113330.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message