jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Unable to lock Exception.
Date Mon, 23 Nov 2009 17:59:21 GMT
On Mon, Nov 23, 2009 at 10:06, Sunil Dhage <sunil.dhage@coreobjects.com> 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
alexander.klimetschek@day.com

Mime
View raw message