AnsweredAssumed Answered

Add an attachment via CMIS to datalist

Question asked by chocox on Nov 27, 2013
Latest reply on Nov 29, 2013 by chocox
Hello,

how can i add an attachment (file) to a field in a datalist??

This is my Model:

<aspects>
      <aspect name="gc:Attachments2">
         <title>Anhänge</title>
         <associations>
            <association name="gc:gcAttachments">
               <title>Attachements</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
      </aspect>
   </aspects>


And this is my Java Code:


//Add Document to Space

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

//Add Datalist Item
Map<String, Object> properties2 = new HashMap<String, Object>();
               properties2.put(PropertyIds.OBJECT_TYPE_ID,  "D:gc:generalRechnung");
               properties2.put(PropertyIds.NAME, filename);
               properties2.put("gc:gcBeschreibung", filename);
               ObjectId newItemId = session.createDocument(properties2, dataList,contentStream,null);

//Add Relationship

               Map<String,Object> relProps = new HashMap<String, Object>();
               relProps.put("cmis:sourceId", newItemId.getId());
               relProps.put("cmis:targetId", doc.getId());
               relProps.put("cmis:objectTypeId", "R:gc:gcAttachments");
               session.createRelationship(relProps, null, null, null);


But the Code doesnt work. I have a new Item in the datalist but no attachment.

Thanks for answering,

Outcomes