cancel
Showing results for 
Search instead for 
Did you mean: 

custom category properties invisible via NodeService

dbevacqua
Champ in-the-making
Champ in-the-making
Hi

To implement a thesaurus we have extended the type cm:category…

<type name="cms:ThesaurusTerm">
         <title>Thesaurus term</title>
         <parent>cm:category</parent>
         <properties>
            <property name="cms:scopeNote">
               <title>Scope note</title>
               <type>d:text</type>
               <multiple>false</multiple>
           </property>
            <property name="cms:useFor">
               <title>Use for</title>
               <type>d:text</type>
               <multiple>true</multiple>
           </property>
            <property name="cms:termCode">
               <title>Term code</title>
               <type>d:text</type>
               <multiple>false</multiple>
           </property>
       </properties>



</type>

there are a couple of associations defined there too.

We create nodes of type cms:ThesaurusTerm, with no apparent problems. Using the JCR API we can navigate these categories and retrieve the value s of the properties we set….


    + cms:CurrencyILS
       * 1 cm:modifier = admin
       * 5 cm:modified = 2007-01-24T14:37:30.265Z
       * 1 sys:node-uuid = 6b5004ec-abb8-11db-b9ef-f5cb86f258dc
       * 1 cm:creator = admin
       * 3 sys:node-dbid = 1283
       * 1 cms:termCode = ILS
       * 1 sys:store-protocol = workspace
       * 1 cm:name = 6b5004ec-abb8-11db-b9ef-f5cb86f258dc
       * 1 cms:name = ILS Israel
       * 1 sys:store-identifier = SpacesStore
       * 3 cms:id = 12
       * 5 cm:created = 2007-01-24T14:37:30.077Z
       * 1 jcr:uuid = 6b5004ec-abb8-11db-b9ef-f5cb86f258dc
       * 7 jcr:primaryType = cms:Currency
       * 7 jcr:mixinTypes = sys:incompletecm:auditablesys:referenceablemix:referenceable

but when we do something similar with the NodeService…


      + {http://researchcommons.com/cms}CurrencyILS (type={http://www.alfresco.org/model/content/1.0}subcategories)
        -{http://www.alfresco.org/model/content/1.0}modifier= admin
        -{http://www.alfresco.org/model/content/1.0}modified= Wed Jan 24 10:58:03 GMT 2007
        -{http://www.alfresco.org/model/system/1.0}node-uuid= c2e62502-ab99-11db-a7a4-3130f5422c8c
        -{http://www.alfresco.org/model/content/1.0}creator= admin
        -{http://www.alfresco.org/model/system/1.0}node-dbid= 677
        -{http://www.alfresco.org/model/system/1.0}store-protocol= workspace
        -{http://www.alfresco.org/model/content/1.0}name= c2e62502-ab99-11db-a7a4-3130f5422c8c
        -{http://www.alfresco.org/model/system/1.0}store-identifier= SpacesStore
        -{http://www.alfresco.org/model/content/1.0}created= Wed Jan 24 10:58:02 GMT 2007



So it appears that anything outside the cm: and sys: namespaces is invisible to the NodeService.

This only happens with categories.

Is there a reason for this behaviour? Is what we're trying to do with categories that strange? Hope you can help.

Thanks

Dominic
4 REPLIES 4

davidc
Star Contributor
Star Contributor
That's strange - the JCR API is using the NodeService to retrieve property values.

JCR namespaced properties will not be visible via NodeService as these are properties that are relevant only to the JCR layer.

Have you tried the NodeBrowser (available in the Web Client/Admin Console) ? It displays everything about a node.

dbevacqua
Champ in-the-making
Champ in-the-making
Yup we thought it was a bit strange too!

Same result in NodeBrowser.

FYI this is a snippet of the code we are using to check the props:


   private void listAssociations(NodeRef nodeRef,int level) {
      
      StringBuffer indent = new StringBuffer();
      for(int i=0;i<2*level;i++) indent.append(' ');
      
      List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef);
      for(ChildAssociationRef assoc : childAssocs) {
         System.out.print(indent.toString()+"+ "+assoc.getQName());
         System.out.println(" (type="+assoc.getTypeQName()+")");
         
         Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
         for(Map.Entry property : properties.entrySet()) {
            System.out.println(indent.toString()+"  -"+property.getKey().toString()+"= "+property.getValue());
         }
         Serializable property = nodeService.getProperty(nodeRef,CommonsContentModel.PROP_CMS_NAME);
         if(property != null)
            System.out.println(indent+"cms:name="+property.toString());
         
         listAssociations(assoc.getChildRef(),level+1);
      }
   }

note the explicit attempt to retrieve a property in our namespace - this never returns  a vlue for a subtype of cm:category.

This happens both agains HEAD and 1.4 versions.

derek
Star Contributor
Star Contributor
If I could sneak in here…

Have a look at the alf_node_properties table to see if the properties were actually persisted to the database.  Then, just clarify that you don't see the properties persisted in the Node Browser.

When are you doing the JCR tests w.r.t. to the session lifecycle?
When are you doing the NodeService tests w.r.t. to the transaction lifecycle?

Regards

dbevacqua
Champ in-the-making
Champ in-the-making
hi Derek

All good questions - the answer is altogether simpler, and is not a bug in Alfresco, you will be overjoyed to hear.

Thanks for your assistance

Dominic