gpt4 book ai didi

java - 创建的文档不可版本控制

转载 作者:太空宇宙 更新时间:2023-11-04 07:37:00 25 4
gpt4 key购买 nike

我使用OpenCmis in-memory供测试用。但是当我创建文档时,我不允许将 versioningState 设置为 versioningState.NONE 之外的其他内容。

创建的文档无法以某种方式进行版本控制...我使用了 http://chemistry.apache.org/java/examples/example-create-update.html 中的代码

测试方法:

public void test() {
String filename = "test123";
Folder folder = this.session.getRootFolder();

// Create a doc
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.NAME, filename);
String docText = "This is a sample document";
byte[] content = docText.getBytes();
InputStream stream = new ByteArrayInputStream(content);
ContentStream contentStream = this.session.getObjectFactory().createContentStream(filename, Long.valueOf(content.length), "text/plain", stream);

Document doc = folder.createDocument(
properties,
contentStream,
VersioningState.MAJOR);
}

我得到的异常:

org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException: The versioning state flag is imcompatible to the type definition.

我错过了什么?

最佳答案

我找到原因了...

通过执行以下代码,我发现 OBJECT_TYPE_ID 'cmis:document' 不允许版本控制。

查看所有可用 OBJECT_TYPE_ID 的代码 ( source ):

    boolean includePropertyDefintions = true;
for (t in session.getTypeDescendants(
null, // start at the top of the tree
-1, // infinite depth recursion
includePropertyDefintions // include prop defs
)) {
printTypes(t, "");
}

static void printTypes(Tree tree, String tab) {
ObjectType objType = tree.getItem();
println(tab + "TYPE:" + objType.getDisplayName() +
" (" + objType.getDescription() + ")");
// Print some of the common attributes for this type
print(tab + " Id:" + objType.getId());
print(" Fileable:" + objType.isFileable());
print(" Queryable:" + objType.isQueryable());

if (objType instanceof DocumentType) {
print(" [DOC Attrs->] Versionable:" +
((DocumentType)objType).isVersionable());
print(" Content:" +
((DocumentType)objType).getContentStreamAllowed());
}
println(""); // end the line
for (t in tree.getChildren()) {
// there are more - call self for next level
printTypes(t, tab + " ");
}
}

这导致了这样的列表:

TYPE:CMIS Folder (Description of CMIS Folder Type) Id:cmis:folder Fileable:true Queryable:true

TYPE:CMIS Document (Description of CMIS Document Type) Id:cmis:document Fileable:true Queryable:true [DOC Attrs->] Versionable:false Content:ALLOWED

TYPE:My Type 1 Level 1 (Description of My Type 1 Level 1 Type)
Id:MyDocType1 Fileable:true Queryable:true [DOC Attrs->] Versionable:false Content:ALLOWED

TYPE:VersionedType (Description of VersionedType Type)
Id:VersionableType Fileable:true Queryable:true [DOC Attrs->] Versionable:true Content:ALLOWED

如您所见,最后一个 OBJECT_TYPE_ID 具有 versionable: true...当我使用它时,它确实有效。

关于java - 创建的文档不可版本控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16709033/

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