cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCMIS Create Custom Content

johnpneal
Champ in-the-making
Champ in-the-making
I am new to OpenCMIS.  I am able to create folders and documents.  Alfresco also has content types either pre-defined or custom.  I want to create content types of either kind but am having difficulty finding out a way to do this in OpenCMIS.  For example, here is a test custom type:


<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of Hotel Solution Model –>
<model name="hs:HotelSolution" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Hotel Solution Content Model</description>
   <author>Development Team</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>

   <!– Introduction of new namespaces defined by this model –>
   <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>
    </types>
    <aspects/>
</model>

I want to programatically create this content type using OpenCMIS, filling in the correct propeties, etc., can anyone help me with this with a code example or a link that can help out?
2 REPLIES 2

fmui
Champ in-the-making
Champ in-the-making
Try something like this:


Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, "myDocument");
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:hs:IdeaContent");
properties.put("hs:hotel", "A hotel");


ContentStream contentStream = …

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

CMIS object type ids must be prefixed with "D:" for document types and "F:" for folders types.

- Florian

johnpneal
Champ in-the-making
Champ in-the-making
Thanks got it to work.