0

我正在尝试为节点实现版本控制,给出以下错误,

    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);

谁能解释这里做错了什么?

4

0 回答 0