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
HiL

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>
<version>1.0</version>

<imports>
<!– Import Alfresco Dictionary Definitions –>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!– Import Alfresco Content Domain Model Definitions –>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>

<namespaces>
<namespace uri="http://www.ihgmerlin.com/hotelSolution" prefix="hs"/>
</namespaces>

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

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

<properties>

  <property name="hs:name">
    <type>d:text</type>
  </property>
  <property name="hs:hotel">
    <type>d:text</type>
  </property>
  <property name="hs:title">
    <type>d:text</type>
  </property>
</properties>
<associations/>
</type>
<!– Definition of new Content Type: Idea Attachment –>

<type name="hs:IdeaAttachment">
<title>Hotel Solution Idea Attachment</title>
<parent>cm:content</parent>
<properties>

  <property name="hs:NameValue">
    <type>d:text</type>
  </property>
  <property name="hs:HotelValue">
    <type>d:text</type>
  </property>
  <property name="hs:TitleValue">
    <type>d:text</type>
  </property>
  <property name="hs:Attachment">
    <type>d:content</type>
  </property>
</properties>
<associations/>
</type>
</types>
<aspects/>
</model>

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,
               removeAces);

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

Outcomes