AnsweredAssumed Answered

How to create root node in the spacesStore?

Question asked by davidsun on Feb 13, 2015
Latest reply on Feb 13, 2015 by davidsun
I have a data model as following and now I want to create root node in the spaces store, just like out-of-box Catetory_root in the contentModel.xml.


<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="sc:somecompanymodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <!– Optional meta-data about the model –>
   <description>SomeCompany Content Model</description>
   <author>Some Guy</author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>
   <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" />
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.somecompany.com/model/content/1.0" prefix="sc" />
   </namespaces>

      <type name="sc:searchField">
         <title>Search Fields</title>
         <description>The search field payer organization defined</description>
         <parent>cm:cmobject</parent>
         <properties>
            <property name="sc:organizationId">
               <type>d:text</type>
               <mandatory enforced="true">true</mandatory>
               <multiple>false</multiple>
            </property>
            <property name="sc:definedSearchedFields">
               <type>d:text</type>
               <mandatory enforced="true">true</mandatory>
               <multiple>false</multiple>
            </property>
         </properties>
      </type>
      
      <type name="sc:searchFields_root">
         <title>Search Field Root</title>
         <parent>cm:cmobject</parent>
         <associations>
            <child-association name="sc:searchFields">
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>sc:searchField</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </child-association>
         </associations>
         <mandatory-aspects>
            <aspect>sys:aspect_root</aspect>
         </mandatory-aspects>
      </type>
   </types>
</model>


I get spaces store in the following way:

       List<StoreRef> stores = nodeService.getStores();
       StoreRef store = null;
       for(StoreRef s : stores) {
          if(s.getProtocol().equalsIgnoreCase(StoreRef.PROTOCOL_WORKSPACE) && s.getIdentifier().equalsIgnoreCase("SpacesStore")) {
             store = s;
             break;
          }
       }

but nodeService only have function to create NodeRef under another NodeRef. How can I create a root node in the Spaces Store?


Thank you!

Outcomes