Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1302

PathNotFoundException when trying to retrieve version history for a node.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 2.8.0.Final, 3.0.0.Alpha2
    • 2.5.2.GA
    • JCR
    • None

      Following code fragment will produce javax.jcr.PathNotFoundException: Unable to find "{}outerFolder[2]/{}innerFolder/{}testFile.dat"; lowest existing path is "/".
      Occurs for inmemory and jpa repositories.

      Repository repository = RepositoryReferenceFactory.getRepository("test-inmemory");
      Session session = repository.login();
      VersionManager vm = session.getWorkspace().getVersionManager();
      		
      Node outer = session.getRootNode().addNode("outerFolder");
      Node inner = outer.addNode("innerFolder");
      Node file  = inner.addNode("testFile.dat");
      file.setProperty("jcr:mimeType", "text/plain");
      file.setProperty("jcr:data", "Original content");
      session.save();
      		
      isVersionable(vm, file);
      file.addMixin("mix:versionable");
      session.refresh(true);
      isVersionable(vm, file);
      
      boolean isVersionable(VersionManager vm, Node node) throws RepositoryException {
          try {
              vm.getVersionHistory(node.getPath());
              return true;
          } catch (UnsupportedRepositoryOperationException e) {
              return false;
          }
      }
      

              hchiorean Horia Chiorean (Inactive)
              mbaluch@redhat.com Marek Baluch
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: