Create folder using CMIS and Sharepoint

773 views Asked by At

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. 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. 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. 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. 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.

1

There are 1 answers

0
ievgen shevchenko On

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

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). Session will provide you ability to create/retrieve folders/documents