cancel
Showing results for 
Search instead for 
Did you mean: 

How to read aspect properties?

forrest43
Champ in-the-making
Champ in-the-making
i have created an aspect as followed

<aspect name="erry:contentScan">
         <title>Content Scan</title>
         <!–
         <properties>
            <property name="erry:ruleFile">
               <title>rule file</title>
               <type>d:noderef</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
          –>
         <associations>
               <association name="erry:ruleFile">
                  <source>
                     <mandatory>false</mandatory>
                     <many>false</many>
                  </source>
                  <target>
                     <class>erry:devDoc</class>
                     <mandatory>true</mandatory>
                     <many>false</many>
                  </target>
               </association>
          </associations>
   </aspect>
added the aspect into some files, and maintain the erry:ruleFile parameters in aspect
i couldn't get the erry:ruleFile data, coding as followed

NodeService ns = serviceRegistry.getNodeService();
NodeRef childNodeRef = childAssocRef.getChildRef();
NodeRef parentNodeRef = childAssocRef.getParentRef();
serviceRegistry.getAuthenticationService().authenticate(GlobalContext.userName, GlobalContext.password.toCharArray());
QName qname =  QName.createQName("http://www.erry.com/model/1.0", "ruleFile");
List<ChildAssociationRef> ruleFileNodes = ns.getChildAssocs(parentNodeRef,qname , RegexQNamePattern.MATCH_ALL);
      
1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator
Hello,

your call to retrieve the property is incorrect. You need to call nodeService.getProperty(nodeRef, qname) to retrieve a single property value.
You should not assign the same name to a property and an association - either you have a property erry:ruleFile or an association erry:ruleFile, not both. At the moment, your model actively defines the association, which you can retrieve using nodeService.getTargetAssocs(sourceNodeRef, qname).

Regards
Axel