cancel
Showing results for 
Search instead for 
Did you mean: 

Java nodeservice.createNode params

spdaly
Champ in-the-making
Champ in-the-making
I'm trying to create a set of nodes from XML data parsed from a file that is uploaded via a web script.

Here's the scenario:  Order data is submitted into ALF via a web script called createOrder.  It creates a node and stores the XML as content.  This works perfectly.  I need to create two additional nodes of a custom type.  I need to create an order document and a printer's guide document.

Here's my model:


   <types>
      <type name="wp:doc">
         <title>Wearport Document</title>
         <parent>cm:content</parent>
         <associations>
            <association name="wp:relatedDocuments">
               <title>Related Documents</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>wp:doc</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
         <mandatory-aspects>
            <aspect>cm:generalclassifiable</aspect>
         </mandatory-aspects>
      </type>
      <type name="wp:art">
         <title>Wearport Art</title>
         <parent>wp:doc</parent>
      </type>
      <type name="wp:order">
         <title>Wearport Order</title>
         <parent>cm:content</parent>
         <properties>
            <property name="wp:orderId">
               <type>d:text</type>
            </property>
            <property name="wp:specialInstructions">
               <type>d:text</type>
            </property>
         </properties>
         <associations>
            <association name="wp:orderDoc">
               <title> "Order Document"</title>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
            <association name="wp:printerGuide">
               <title>"Printer Guide"</title>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
         </associations>
      </type>
   </types>

So, wpSmiley Surprisedrder is the node created by the web script.  The behavior should create the wpSmiley SurprisedrderDoc and reference the wpSmiley Surprisedrder node.

I have an OnCreateNode behaviour that parses the XML.  I thought that I would call createNode like this (this is a Java class BTW):

NodeRef orderDoc = nodeService.createNode(orderDataNode, ContentModel.ASSOC_REFERENCES,  WearportModel.ASSOC_ORDER_DOC, ContentModel.TYPE_CONTENT).getChildRef();

But the nodes don't get created.  I'm not understanding the "assocTypeQName" and "assocQName."
1 REPLY 1

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

the assocTypeQName is the QName of an association described in an Alfresco model.
For instance a valid value is :
org.alfresco.model.ContentModel.ASSOC_CONTAINS

the assocQName parameter is the name (in fact QName) of the parent-to-child association instance you are creating to bear your child node. The name is usually identical to the child node name, located in the same namespace as the assocTypeQName.