Hi,

currently SPI Batch distinguishes between adding a property, and setting the value of a property. In JCR however, this distinction does not exist.

Thus JCR2SPI relies on it's knowledge of the node's state to decide which method to use. Of course, this fails in case of overlapping updates, such as in:

  public void testSetCustomTwice() throws Exception {
    Session session = TestAll.getSessionForTestUser1();
    Session session2 = TestAll.getSessionForTestUser1();
    try {
if (session.getRepository().getDescriptor(Repository.LEVEL_2_SUPPORTED).equals("true")) { session.setNamespacePrefix("my", TestAll.STRINGPROP.getNamespaceURI()); session2.setNamespacePrefix("my", TestAll.STRINGPROP.getNamespaceURI());
        String propname = "my:" + TestAll.STRINGPROP.getLocalName();

        String nodepath = this.m_path + "/" + TestAll.PROPTESTNODE;
        Node n = (Node)session.getItem(nodepath);
        n.setProperty(propname, "one");

        Node n2 = (Node)session2.getItem(nodepath);
        n2.setProperty(propname, "two");
        session.save();
        session2.save();
      }
    }
    finally {
      session.logout();
      session2.logout();
    }
  }

This test will only pass if SPI's Batch.addProperty actually behaves the same way as setValue, meaning overwriting an existing property.

Questions:

1) Should we update the Javadoc to clarify that this is what it is expected?

or

2) Should we remove one of the signatures, because the distinction wasn't useful after all?

BR, Julian

Reply via email to