On Mon, Nov 23, 2009 at 10:06, Sunil Dhage <[email protected]> wrote:
>  public Node verifyAndAddNode(Session session,Node parent,String... 
> parameters) throws RepositoryException
>    {   Node node2Add = null;
>        //code review comment - to ensure parameters size is either 2 or 3.
>        if(parameters.length < 2 || parameters.length > 3)
>        {   throw new IllegalArgumentException("Number of parameters to 
> verify/add node invalid ");
>        }
>        NodeIterator iterator = queryForPath(session,parameters[0]);
>        if(iterator.hasNext())
>        {   log.info("Node exists in this path...");
>            node2Add = iterator.nextNode();
>        }else
>        {   if(parameters.length == 2)
>                node2Add = parent.addNode(parameters[1]);
>            else
>               node2Add = parent.addNode(parameters[1],parameters[2]);
>        }
>        return node2Add;
>    }

The "parameters" handling seems broken. You call the above method with

>           Node account = 
> verifyAndAddNode(session,candidatedocs,path,"lc:account");

in which case parameters.length = 2 and the addNode() call will be
done without the node type. Also, the indexes look wrong to me:
parameters[1], which is used as the node name in the addNode() call,
will be "lc:account" in your case - the nodetype.

Regards,
Alex

-- 
Alexander Klimetschek
[email protected]

Reply via email to