How to create root node in the spacesStore?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2015 09:54 PM
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.
I get spaces store in the following way:
but nodeService only have function to create NodeRef under another NodeRef. How can I create a root node in the Spaces Store?
Thank you!
<?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!
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 04:50 AM
You just need to get root node of the space store
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 12:56 PM
Thank you! You information is very useful. following I still have the problem to create node in SpacesStore root. The code is like this:
<java>
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
QName nodeTypeQName = QName.createQName(NAMESPACE_HIGHROADS_CONTENT_MODEL, TYPE_HR_SEARCHFIELD_ROOT);
ChildAssociationRef childAssRef = nodeService.createNode(rootNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{app}searchfields"), nodeTypeQName);
</java>
I get the following exception:
<cite>
org.alfresco.repo.node.integrity.IntegrityException: 01130007 Found 1 integrity violations:
The association source type is incorrect:
Source Node: workspace://SpacesStore/e909ccce-092e-4bce-a77f-6848dd7b1f42
Association: Association[ class=ClassDef[name={http://www.alfresco.org/model/content/1.0}folder], name={http://www.alfresco.org/model/content/1.0}contains, target class={http://www.alfresco.org/model/system/1.0}base, source role=null, target role=null]
Required Source Type: {http://www.alfresco.org/model/content/1.0}folder
Actual Source Type: {http://www.alfresco.org/model/system/1.0}store_root
at org.alfresco.repo.node.integrity.IntegrityChecker.checkIntegrity(IntegrityChecker.java:664)
at org.alfresco.repo.node.integrity.IntegrityChecker.beforeCommit(IntegrityChecker.java:766)
at org.alfresco.util.transaction.TransactionSupportUtil$TransactionSynchronizationImpl.beforeCommit(TransactionSupportUtil.java:498)
at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:925)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:738)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)
</cite>
But if I use "company home" as parent node, it will success.
Any suggestion? Sorry I am new for Alfresco.
Thank you!
<java>
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
QName nodeTypeQName = QName.createQName(NAMESPACE_HIGHROADS_CONTENT_MODEL, TYPE_HR_SEARCHFIELD_ROOT);
ChildAssociationRef childAssRef = nodeService.createNode(rootNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{app}searchfields"), nodeTypeQName);
</java>
I get the following exception:
<cite>
org.alfresco.repo.node.integrity.IntegrityException: 01130007 Found 1 integrity violations:
The association source type is incorrect:
Source Node: workspace://SpacesStore/e909ccce-092e-4bce-a77f-6848dd7b1f42
Association: Association[ class=ClassDef[name={http://www.alfresco.org/model/content/1.0}folder], name={http://www.alfresco.org/model/content/1.0}contains, target class={http://www.alfresco.org/model/system/1.0}base, source role=null, target role=null]
Required Source Type: {http://www.alfresco.org/model/content/1.0}folder
Actual Source Type: {http://www.alfresco.org/model/system/1.0}store_root
at org.alfresco.repo.node.integrity.IntegrityChecker.checkIntegrity(IntegrityChecker.java:664)
at org.alfresco.repo.node.integrity.IntegrityChecker.beforeCommit(IntegrityChecker.java:766)
at org.alfresco.util.transaction.TransactionSupportUtil$TransactionSynchronizationImpl.beforeCommit(TransactionSupportUtil.java:498)
at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:925)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:738)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)
</cite>
But if I use "company home" as parent node, it will success.
Any suggestion? Sorry I am new for Alfresco.
Thank you!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2015 04:13 AM
I think association type should be sys:children (ContentModel.ASSOC_CHILDREN) instead of cm:contains (ContentModel.ASSOC_CONTAINS). Try this:
NodeRef rootNode = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); QName nodeTypeQName = QName.createQName(NAMESPACE_HIGHROADS_CONTENT_MODEL, TYPE_HR_SEARCHFIELD_ROOT); ChildAssociationRef childAssRef = nodeService.createNode(rootNode, ContentModel.ASSOC_CHILDREN, QName.createQName("{app}searchfields"), nodeTypeQName);
