AnsweredAssumed Answered

exception on iterating NodeRef

Question asked by kbryd on Jan 31, 2008
Hello

Can anyone tell me why this code (taken from here: http://wiki.alfresco.com/wiki/NodeRef_cookbook)  fails when called with XPATH which points to my space  (created using option Create Space) and works correctly for example for Company Home? I am using admin/admin account and the 2.9B community version.


resultSet = searchService.query(storeRef, SearchService.LANGUAGE_XPATH, "./app:company_home/cm:myspace");
        for(int n = 0; n < resultSet.length(); n++) {
            List<ChildAssociationRef> children = nodeService.getChildAssocs(resultSet.getNodeRef(0));
            for (ChildAssociationRef childAssoc : children) {
                NodeRef childNodeRef = childAssoc.getChildRef();
                System.out.println("Child NodeRef " + childNodeRef.getId());
                Serializable nodeName = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
                System.out.println("\tChild Name " + nodeName.toString());
       }
        }

this fails with:

Exception in thread "main" java.lang.NullPointerException
   at org.alfresco.repo.security.permissions.impl.model.PermissionModel.getExposedPermissionsImpl(PermissionModel.java:455)
   at org.alfresco.repo.security.permissions.impl.model.PermissionModel.getAllPermissions(PermissionModel.java:434)
   at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.hasPermission(PermissionServiceImpl.java:356)
   at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.hasPermission(PermissionServiceImpl.java:577)
   at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:577)
   at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:224)
   at net.sf.acegisecurity.afterinvocation.AfterInvocationProviderManager.decide(AfterInvocationProviderManager.java:107)
   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.afterInvocation(AbstractSecurityInterceptor.java:329)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:82)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:241)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
   at $Proxy3.getChildAssocs(Unknown Source)
   at org.alfresco.sample.FirstFoundationClient.doExample(FirstFoundationClient.java:171)
   at org.alfresco.sample.FirstFoundationClient$1.execute(FirstFoundationClient.java:94)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:236)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:166)
   at org.alfresco.sample.FirstFoundationClient.main(FirstFoundationClient.java:98)

cm:myspace is a plain folder in Company Home, here is what it outputs for a cm:company_home:

Child NodeRef 44b0dcaa-c43e-11dc-a5ba-71364e4f999b
   Child Name Data Dictionary
Child NodeRef 45366068-c43e-11dc-a5ba-71364e4f999b
   Child Name Guest Home
Child NodeRef 5fd604b1-c43e-11dc-a5ba-71364e4f999b
   Child Name Projects
Child NodeRef 4553ac6a-c43e-11dc-a5ba-71364e4f999b
   Child Name User Homes
Child NodeRef f899b04e-d043-11dc-9b5e-1965b26b4d72
   Child Name myspace

Any ideas?

Karol

Outcomes