2 Replies Latest reply on Mar 12, 2013 7:26 PM by Bayani Portier

    Problem with asset.adaptTo(javax.jcr.Node.class)

    Bayani Portier Level 1

      Hi all,

       

      Have a bit of weird one. We tried to do this:

       

      javax.jcr.Node assetNode=asset.adaptTo(javax.jcr.Node.class);

      String assetMetadataPath=asset.getPath().concat("/jcr:content/metadata");

      javax.jcr.Node metadata = assetNode.getNode(assetMetadataPath);

      metadata.setProperty("dc:rights", rights);

       

      and dc:rights wasn't anywhere to be seen, even though the code executed correctly.

       

      We changed our apporach to do this:

      String assetMetadataPath=asset.getPath().concat("/jcr:content/metadata");

      javax.jcr.Node metadata = session.getNode(assetMetadataPath);

      metadata.setProperty("dc:rights", rights);

       

      and magically, it is able to save property and node changes.

       

      I would have thought that using asset.adaptTo was perfectly acceptable, and it does find the node etc. Just wondering if there is a reason for this not working that eludes me, or whether I should raise a defect?

       

      Bayani