AnsweredAssumed Answered

How to add an attachment using OpenCMIS with d:content

Question asked by johnpneal on Jan 13, 2011
Latest reply on Jul 26, 2014 by kaynezhang

I have my content XML as follows:

<model name="hs:HotelSolution">
<!– Optional meta-data about the model –>
<description>Hotel Solution Content Model</description>
<author>Kingsly Rajamani</author>

<!– Import Alfresco Dictionary Definitions –>
<import uri="" prefix="d"/>
<!– Import Alfresco Content Domain Model Definitions –>
<import uri="" prefix="cm"/>

<namespace uri="" prefix="hs"/>

<!– Definition of new Content Type: Idea Content –>

<type name="hs:IdeaContent">
<title>Hotel Solution Idea Content</title>


  <property name="hs:name">
  <property name="hs:hotel">
  <property name="hs:title">
<!– Definition of new Content Type: Idea Attachment –>

<type name="hs:IdeaAttachment">
<title>Hotel Solution Idea Attachment</title>

  <property name="hs:NameValue">
  <property name="hs:HotelValue">
  <property name="hs:TitleValue">
  <property name="hs:Attachment">

I can successfully add the IdeaContent.  I was trying to add the second type using OpenCMIS.  My current code up to this point is as follows:

                        CmisObject currentObject ,,,

                        ContentStream contentStream = new ContentStreamImpl("Test Content", null,
         "plain/text", new ByteArrayInputStream(contentString.getBytes()));         

         Map<String, Object> properties = new HashMap<String, Object>();
         properties.put(PropertyIds.NAME, "Test Idea");
         properties.put(PropertyIds.OBJECT_TYPE_ID, "D:hs:IdeaContent");
         properties.put("hs:name", "A name");      
         properties.put("hs:hotel", "A hotel");
         properties.put("hs:title", "A title");
         List<Ace> addAces = new LinkedList<Ace>();
         List<Ace> removeAces = new LinkedList<Ace>();
         List<Policy> policies = new LinkedList<Policy>();

         ObjectId newId = session.createDocument(properties, objectId,
               contentStream, VersioningState.MAJOR, policies, addAces,

This works just fine.  Any help is appreciated on how to add the second type and its attachment would be appreciated.