4 Replies Latest reply on Apr 4, 2013 11:29 AM by Mark Scott

    FileSystemConnector and creating content in new nt:file nodes

    Mark Scott Newbie

      Using 3.1.3 Final I have a view of an external filesystem projected into a repository using FileSystemConnector.  If I create a new federated node with primary type nt:file and add content to it should I see a non-empty file created on disk in my external filesystem?

       

      This code :

       

            Node node = root.getNode("federated/foo").addNode("bar.xml", "nt:file");
            Node contentNode = node.addNode("jcr:content", "nt:resource");
            Binary binary = session.getValueFactory().createBinary(new ByteArrayInputStream(SOME_STRING_CONTAINING_XML.getBytes()));
            contentNode.setProperty("jcr:data", binary);
            session.save();
      

       

      creates an empty file foo/bar.xml at the correct location in the external filesystem.

       

      If I step through the code then in FileSystemConnector.store(Document) I never see the

       

                  } else if (isContentNode(id)) {
      

       

      branch (on line 513) taken.  It looks like this is because id at this point ends with "bar.xml/content" while isContentNode(id) tests for id ending with "/jcr:content".  The "jcr:" prefix has been removed at this point during writing (but is present when getNode("jcr:content") is called).  If I extend FileSystemConnector and override isContentNode(String) and fileFor(String) so they handle a suffix of "/content" as well as "/jcr:content" then I get the behaviour I expect i.e. a non-empty XML file with the correct content.

       

      I'm not sure if this is a misunderstanding as to how FileSystemConnector works, a bug in FileSystemConnector or, more likely given my newness to ModeShape/JCR, caused by something I'm doing wrong (perhaps related to the config described in Problem getting the binary value from a federated node).

       

      Help gratefully received!