简体   繁体   English

使用CMIS和Sharepoint创建文件夹

[英]Create folder using CMIS and Sharepoint

Currently I need to create a folder on a Sharepoint repository using it CMIS implementation so I am using the web services it offers on the path http://(server)/_vti_bin/cmis/soap . 当前,我需要使用CMIS实现在Sharepoint存储库上创建一个文件夹,因此我正在使用它在路径http://(server)/ _vti_bin / cmis / soap上提供的Web服务。 I implemented the code based on this example https://chemistry.apache.org/java/opencmis-cookbook.html but Sharepoint does not return the rootFolderId so the method getChildren returns nothing. 我基于此示例https://chemistry.apache.org/java/opencmis-cookbook.html实现了代码,但Sharepoint不会返回rootFolderId,因此getChildren方法不会返回任何内容。 Finally based on a query using the discovery service I retrieve the root folder id, but now the problem is I can't create a sub folder. 最后,基于使用发现服务的查询,我检索了根文件夹ID,但是现在的问题是我无法创建子文件夹。 This is my code: 这是我的代码:

            Object.cmisPropertyId p1 = new Object.cmisPropertyId();
            p1.propertyDefinitionId = "cmis:baseTypeId";
            p1.value = new string[1];
            p1.value[0] = "cmis:folder";
            propertiesType.Items.SetValue(p1, 0);

            Object.cmisPropertyString p2 = new Object.cmisPropertyString();
            p2.propertyDefinitionId = "cmis:name";
            p2.value = new string[1];
            p2.value[0] = "mytest";
            propertiesType.Items.SetValue(p2, 1);

            Object.cmisPropertyString p3 = new Object.cmisPropertyString();
            p3.propertyDefinitionId = "cmis:path";
            p3.value = new string[1];
            p3.value[0] = "Rep/f1/mytest";
            propertiesType.Items.SetValue(p3, 2);

            Object.cmisPropertyId p4 = new Object.cmisPropertyId();
            p4.propertyDefinitionId = "cmis:objectTypeId";
            p4.value = new string[1];
            p4.value[0] = "cmis:folder";
            propertiesType.Items.SetValue(p4, 3);

            Object.cmisPropertyId p5 = new Object.cmisPropertyId();
            p5.propertyDefinitionId = "cmis:parentId";
            p5.value = new string[1];
            p5.value[0] = "268";
            propertiesType.Items.SetValue(p5, 4);

            Object.cmisPropertyString p6 = new Object.cmisPropertyString();
            p6.propertyDefinitionId = "Author";
            p6.value = new string[1];
            p6.value[0] = "theAuthor";
            propertiesType.Items.SetValue(p6, 5);

            Object.cmisPropertyId p7 = new Object.cmisPropertyId();
            p7.propertyDefinitionId = "cmis:allowedChildObjectTypeIds";
            p7.value = new string[3];
            p7.value[0] = "cmis:document";
            p7.value[1] = "0x010100C98D402E3C78834C873469CE4F41E2C300B0A3B5E8A3E51543977DFDCE95850082";
            p7.value[2] = "cmis:folder";
            propertiesType.Items.SetValue(p7, 6);

var result = objectService.createFolder(repositoryInfo.repositoryId, propertiesType, null, null, null, null, ref extType);

It always return null, I'm not sure how to pass correctly the arguments to the service for make the creation works. 它总是返回null,我不确定如何正确地将参数传递给服务以使创建工作正常进行。 I don't know where to find logs o something that tell me what I am doing wrong. 我不知道在哪里可以找到日志,或者告诉我我做错了什么。

Thank you 谢谢

PD: I need to use this aproach because is a modification to an existing code that already use the Sharepoint CMIS services. PD:我需要使用此方法,因为它是对已经使用Sharepoint CMIS服务的现有代码的修改。

You try to update readonly properties. 您尝试更新只读属性。 See CMIS 1.0 http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html Sample on Java 请参见CMIS 1.0 http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html Java上的示例

Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, "a new folder");
Folder newFolder = root.createFolder(properties); 

The key is "session". 关键是“会话”。 You should create session to CMIS Repository(Atom or WSDL binding). 您应该创建到CMIS存储库的会话(Atom或WSDL绑定)。 Session will provide you ability to create/retrieve folders/documents 会话将使您能够创建/检索文件夹/文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM