cancel
Showing results for 
Search instead for 
Did you mean: 

Custom content types

naveenkumar
Champ in-the-making
Champ in-the-making
I created my own content types, i want to use them while adding node using JCR API. lets take my content type is dml:rsscontent.
here is my java class.

Node rootNode = session.getRootNode();
         // first, access the company home
         Node companyHome = rootNode.getNode("app:company_home");
         Node rssFeeds = companyHome.getNode("app:user_homes");
         //To get items from rss feeds.                       
         // create the content nodegud morning
         Node channelContent = rssFeeds.addNode("cm:","dml:rsscontent");

while executing the above class i am getting this error

org.alfresco.service.namespace.NamespaceException: Namespace prefix dml is not mapped to a namespace URI
   at org.alfresco.service.namespace.QName.createQName(QName.java:103)
   at org.alfresco.service.namespace.QName.createQName(QName.java:125)
   at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:188)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138)
   at $Proxy82.addNode(Unknown Source)
   at com.cognizant.digitalmedialab.cms.business.JCRManagerMeta.getJCRRepository(JCRManagerMeta.java:46)
   at com.cognizant.digitalmedialab.cms.business.RssFeeds.getChannelDetails(RssFeeds.java:34)
   at com.cognizant.digitalmedialab.cms.business.JCRManagerMeta.main(JCRManagerMeta.java:107)


I found similar kind of problem in this link http://issues.alfresco.com/browse/AR-1179?page=history
as well as the solution.not able to do that way.

Please any one help me……………..


Thanks
Naveen
3 REPLIES 3

derek
Star Contributor
Star Contributor
Hi,

You need to register a model that declares that namespace and the properties.  See the sample file custom-model-context.xml.sample.  (http://wiki.alfresco.com/wiki/Data_Dictionary_Guide).

Regards

naveenkumar
Champ in-the-making
Champ in-the-making
hi derek i followed this link http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Step_4:_Register_the_Model_with_the_Repository for registering my custom content types. whats the diff in using example-model-context.xml.sample  and custom-model-context.xml.sample..both are same….

i found usage of custom content types is impossible through jcr api…
Please check here… http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Using_a_Custom_Model

Thanks
Naveen

naveenkumar
Champ in-the-making
Champ in-the-making
hi derek followed your reply getting same error……

thanks
Naveen