gpt4 book ai didi

java - CMIS 版本控制未按预期工作

转载 作者:行者123 更新时间:2023-12-01 22:14:46 25 4
gpt4 key购买 nike

我正在使用以下代码通过 CMIS API 在文档服务上创建文件:

zipMapFile.put(PropertyIds.OBJECT_TYPE_ID, "sap:versioned");
zipMapFile.put(PropertyIds.NAME, "g" + g.getId() + ".zip");
Document versionedDocument = openCmisSession.getRootFolder().createDocument(zipMapFile, contentStream, VersioningState.MAJOR);
newZipFileId = versionedDocument.checkOut();
...

上面的代码正在运行并且文件正在正确生成。当我运行以下代码时:

cmisSession.getObject(newZipFileId.getId());

我得到了之前创建的文件,没有错误。

但是,当我尝试上传该文件的新版本时遇到问题。

为此,我使用以下代码:

oldZipFileId = newZipFileId;
Document pwc = (Document) cmisSession.getObject(oldZipFileId);
pwc.setContentStream(contentStream, true);
newZipFileId = pwc.checkIn(false, null, null, null);

每当我执行此操作时,运行以下代码都可以毫无问题地访问新版本:

cmisSession.getObject(newZipFileId.getId());

但是,我无法再访问旧版本了!如果我尝试运行:

cmisSession.getObject(oldZipFileId);

我收到一个CmisObjectNotFoundException

我失去对旧版本的访问权限的那一刻正是执行方法 pwc.checkIn(false, null, null, null); 的时候。在此调用之后,尝试获取 oldZipId 引用的对象会出现 CmisObjectNotFoundException。

我正在使用 MongoDB。

感谢任何帮助!谢谢!

最佳答案

工作代码应如下所示:

Document versionedDocument = openCmisSession.getRootFolder().createDocument(zipMapFile, contentStream, VersioningState.MAJOR);
oldZipFileId = versionedDocument.getId();

newZipFileId = versionedDocument.checkOut();
Document pwc = (Document) cmisSession.getObject(newZipFileId);
pwc.setContentStream(contentStream, true);
newZipFileId = pwc.checkIn(false, null, null, null);

// access last version
cmisSession.getObject(newZipFileId.getId());

// access old version
cmisSession.getObject(oldZipFileId);

关于java - CMIS 版本控制未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31304481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com