cancel
Showing results for 
Search instead for 
Did you mean: 

How to create document with more than 1 aspect?

doychev
Champ in-the-making
Champ in-the-making
Hello,

I am trying to create a document and add 2 aspects to it on creation. So far, I had only one aspect and it worked something like that:


properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:my:aspect");

//get contentStream, get folder

Document doc = folder.createDocument(properties, contentStream, null);


Now, I am trying to add the second aspect making a change like this:
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:my:aspect1,P:my:aspect2");

but this only adds the my:aspect2 to the document.
I know there is a way to create it with one aspect and then add the second one, but that could cause some problems in my application.

Is there a way to create it with 2+ aspects?

Thank you.
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
Using OpenCMIS 0.8 against Alfresco 4.2.c Community Edition and the Alfresco OpenCMIS Extension 0.2 I can run the following code:
<blockcode>
Map<String, Object> props = new HashMap<String, Object>();
props.put("cmisSmiley SurprisedbjectTypeId",  "D:cmisbook:image,P:sc:webable,P:scSmiley TongueroductRelated");
ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(
   fileName,
   file.length(),
   fileType,
   new FileInputStream(file)
);
document = parentFolder.createDocument(props, contentStream, null);      
</blockcode>

And successfully create an instance of the custom type, "cmisbook:image" that has both custom aspects, "sc:webable" and "scSmiley TongueroductRelated" added to the object.

Check your type IDs.

Jeff