jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ulrich <For...@gombers.de>
Subject Re: Reference to same-name sibling lost when retrieving back node from intermediate storing class
Date Mon, 15 Jul 2013 07:15:29 GMT
I see a similiar effect for node-iterated result of a query; the delivered
sibling depends on my actions during the loop.
I'm running the code:

NodeIterator nodeIterator = queryResult.getNodes();
while (nodeIterator.hasNext()) {
    Node selectNode = nodeIterator.nextNode();
    String nodename=selectNode.getPath();
    LOGGER.debug("Nodename1={}",nodename);
    DoSomething doSomething = new DoSomething(selectNode);
}

The DoSomething-Class doesn't change anything; it searches itself the repository
tree for more infos.

If I run DoSomething full functioning the list of logged nodenames is:
Nodename1=../jcr:content/content/contentcontainer2cols[4]/itemsLeft/richtextimage_3
Nodename1=../jcr:content/content/contentcontainer2cols[2]/itemsRight/richtextimage_4
Nodename1=../jcr:content/content/contentcontainer2cols[3]/itemsLeft/richtextimage_1
Nodename1=../jcr:content/content/contentcontainer2cols[2]/itemsRight/richtextimage_0
Nodename1=../jcr:content/content/contentcontainer2cols/itemsLeft/richtextimage
Nodename1=../jcr:content/content/contentcontainer2cols[3]/itemsRight/richtextimage_2

if I suppress all actions in DoSomething the result is:
Nodename1=../jcr:content/content/contentcontainer2cols[4]/itemsLeft/richtextimage_3
Nodename1=../jcr:content/content/contentcontainer2cols[4]/itemsRight/richtextimage_4
Nodename1=../jcr:content/content/contentcontainer2cols[3]/itemsLeft/richtextimage_1
Nodename1=../jcr:content/content/contentcontainer2cols[2]/itemsRight/richtextimage_0
Nodename1=../jcr:content/content/contentcontainer2cols/itemsLeft/richtextimage
Nodename1=../jcr:content/content/contentcontainer2cols[3]/itemsRight/richtextimage_2

In the second name the same-named sibling has changed to from
contentcontainer2cols[2] to contentcontainer2cols[4].

This is quite annoying; from now I can't work with the retrieved node directly
any more; I have to store the names in a list and iterate on the list then:

NodeIterator nodeIterator = queryResult.getNodes();
List<String> nodenames = new ArrayListy<String>();
while (nodeIterator.hasNext()) {
    Node selectNode = nodeIterator.nextNode();
    String nodename=selectNode.getPath();
    LOGGER.debug("Nodename1={}",nodename);
    nodenames.add(nodename);
}
for (String nodename : nodenames) {
    Node selectNode = session.getNode(nodename);
    DoSomething doSomething = new DoSomething(selectNode);
}

brgds,
Ulrich



> Ulrich <Forums@gombers.de> hat am 11. Juli 2013 um 15:25 geschrieben:
>
>
> When changing ComparableNode-Constructor to:
>          public ComparableNode(Node node) throws Exception {
>                  this.node=node;
>                  this.session=node.getSession();
>                  LOGGER.info("Nodename2="+getNode().getPath());
>                  buildEffectiveACL();
>          }
>
> I see these messages:
> Nodename1=/content/sibling[2]/mynode
> Nodename3=/content/sibling[2]/mynode
> Nodename2=/content/sibling[2]/mynode
> Nodename3=/content/sibling/mynode
> Nodename4=/content/sibling/mynode
>
>
> > Ulrich <Forums@gombers.de> hat am 11. Juli 2013 um 15:20 geschrieben:
> >
> >
> > While researching nodes I build for each of these nodes a new object with
> > some
> > methods to be tested.
> > So I have a class "ComparableNode":
> >
> >         private Session session;
> >         private final Node node;
> >
> >         public ComparableNode(Node node) throws Exception {
> >                 this.node=node;
> >                 this.session=node.getSession();
> >                 LOGGER.info("Nodename2="+node.getPath());
> >                 buildEffectiveACL();
> >         }
> >
> >         public Node getNode() throws RepositoryException {
> >                 LOGGER.info("Nodename3="+node.getPath());
> >                 return this.node;
> >         }
> >
> > The class is instantiated by:
> >         LOGGER.info("Nodename1="+node.getPath());
> >         ComparableNode cmpNode = new ComparableNode(node);
> >         LOGGER.info("Nodename4="+cmpNode.getNode());
> >
> > The node itself partially contains a same-name sibling; by retrieving the
> > node
> > from my ComparableNode I lose the index of the sibling.
> > So when researching: /content/sibling[2]/mynode
> > I get these messages:
> > Nodename1=/content/sibling[2]/mynode
> > Nodename2=/content/sibling[2]/mynode
> > Nodename3=/content/sibling/mynode
> > Nodename4=/content/sibling/mynode
> >
> > As you can see the node itself is stored to a final variable by the
> > constructor
> > of ComparableNode. But when retrieving it, it represents a different node.
> >
> > Any idea, whats going on here?
> >
> > brgds,
> > Ulrich

Mime
View raw message