cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Document - CMIS Workbench GroovyConsole

a_palm
Champ in-the-making
Champ in-the-making
I am trying to create a document with some content by following this link (http://chemistry.apache.org/java/developing/guide.html#creating-a-simple-document-object). I am getting some errors and I don't know how to fix these.

I am new to Alfresco and CMIS and I am trying to get to know these programs.

-> At attachment1.png: If I use line 15 (instead of 16) and line 22 (instead of 23) I get this error.

-> At attachment2.png: If I use line 16 (instead of 15) and line 23 (instead of 22) I get this error.

Anyone knows what I may be doing wrong…

Thanks in Advance.
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
I cannot recreate this using OpenCMIS Workbench 0.11 running against Alfresco 5.0.b and the AtomPub binding.

Here is the code that works, which is nearly identical to yours:


import org.apache.chemistry.opencmis.commons.*
import org.apache.chemistry.opencmis.commons.data.*
import org.apache.chemistry.opencmis.commons.enums.*
import org.apache.chemistry.opencmis.client.api.*

def cmis = new scripts.CMIS(session)
Folder newFolder  = cmis.getFolder("/");

final String textFileName = "test.txt";
String mimetype = "text/plain; charset=UTF-8";
String content = "This is some test content";
String filename = textFileName;

byte[] buf = content.getBytes("UTF-8");
ByteArrayInputStream input = new ByteArrayInputStream(buf);

ContentStream contentStream = session.getObjectFactory().createContentStream(filename, buf.length, mimetype, input);

Map<String, Object> props = new HashMap<String, Object>();
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
props.put(PropertyIds.NAME, "filename");

Document doc = newFolder.createDocument(props, contentStream, VersioningState.MAJOR);


Jeff

a_palm
Champ in-the-making
Champ in-the-making
Hi Jeff, Thank you for your reply.

It works.
At line 21: props.put(PropertyIds.NAME, "filename"); -> I think <strong>filename</strong> needs to be without the <strong>" "</strong> . -> props.put(PropertyIds.NAME, filename);

Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.