javax.jcr.UnsupportedRepositoryOperationException: узел в / testVersionable не является версионным - PullRequest
0 голосов
/ 04 июля 2019

Я пытаюсь реализовать управление версиями для узла с приведенной ниже ошибкой,

    at org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager.checkVersionable(ReadOnlyVersionManager.java:313)
    at org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager.getVersionHistory(ReadOnlyVersionManager.java:152)

я пробовал ниже код,

   @Autowired 
   NodeStore rdbNodeStore;

   //create reposiotory
   LuceneIndexProvider provider = new LuceneIndexProvider();
   ContentRepository repository = new Oak(documentNodeStoreService)
                    .with(new InitialContent())
                    .with(new VersionHook())
                    .with(new LucenePropertyInitialiser("ocbluceneIndex",
                            of("ocb:content", NodeStoreConstant.REGEX_ALL_PROPS)))
                    .with(new OpenSecurityProvider()).with(new PropertyIndexProvider())
                    .with(new PropertyIndexEditorProvider()).createContentRepository();

    //login repository and retrieve session
    ContentSession contentSession = repository.login(null, null);
    Root rootNode = contentSession.getLatestRoot();
        NodeUtil node = new NodeUtil(rootNode.getTree("/"));
        NodeUtil testVersionable = node.addChild("testVersionable", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
        TreeUtil.addMixin(testVersionable.getTree(), JcrConstants.MIX_VERSIONABLE, rootNode.getTree(NodeTypeConstants.NODE_TYPES_PATH), null);
        rootNode.commit();

        ReadOnlyVersionManager versionManager =ReadOnlyVersionManager.getInstance(rootNode, NamePathMapper.DEFAULT); 

        Tree history = versionManager.getVersionHistory(testVersionable.getTree());
       System.out.println("History exist="+history.exists());
        String historyUuid = history.getProperty("jcr:uuid").getValue(Type.STRING);
        System.out.println("History historyUuid="+historyUuid);

Может кто-нибудь объяснить, что я здесь делаю не так?

...