1 Reply Latest reply on Sep 4, 2012 10:12 AM by rhauch

    Modeshape 3 b3 bug in Session.propertyExists ?

    chrispoulsen

      Hi,

       

      I was just reverting/cleaning up stuff after my Modeshape 3 Beta3 adventure.

       

      I noticed that I had to change the following code to get it to run properly in MS3:

       

      {code}

          private static void bootstrapSequence(Session session, Node parent, String relativePath) throws RepositoryException

          {

              if( !session.propertyExists( parent.getPath() + "/" + relativePath + "/counter" ) )

              {

                  Long returnValue = 0l;

                  Node sequenceNode = DezideJcrUtils.getOrCreateNode( parent, relativePath.split( "/" ) );

                  sequenceNode.setProperty( "counter", returnValue );

                  session.save();

              }

          }

      {code}

       

      To:

       

      {code}

      ...

              String sequenceNodePath = parent.getPath() + "/" + relativePath;

              if( !session.nodeExists( sequenceNodePath ) || !session.propertyExists( sequenceNodePath + "/counter" ) )

      ...

      {code}

       

      I don't have a working MS3 setup at the time, but I think the first original code block threw a "node does not exist" exception on MS 3 while it just worked in MS 2.8.2.

       

      In the bootstrap scenario the code is called like this:

       

      {code}

              bootstrapSequence( session, session.getRootNode(), "authorutil/sequence/revisionId" );

      {code}

       

      (The relative path does not exist yet in the repository so it is path containing 3 non-existing nodes) - I think this is a bug, but do not have the time to re-test - so I thought I'd mention it here.

       

      --

      Chris