cancel
Showing results for 
Search instead for 
Did you mean: 

missing nodes when trying ther sample SimpleExample.java

bparis
Champ in-the-making
Champ in-the-making
Hi,

I've tried the org.alfresco.sample.jcr.SimpleExample code, and strangely got 3 nodes guest_home, users and dictionary. 
Can anybody tell me why the other folders I've created at same hierachical level are not displayed  by the small example application ?

Thanks for any help,
Bernie.
4 REPLIES 4

bparis
Champ in-the-making
Champ in-the-making
I cannot believe this:
if I try this code :

Node root = session.getRootNode();
Node companyHome = root.getNode("app:company_home");
System.out.println(companyHome.getPath());
NodeIterator iterator = companyHome.getNodes();
System.out.println(iterator.getSize());
while(iterator.hasNext())
{
   Node child = iterator.nextNode();
   System.out.println("—->" + child.getPrimaryNodeType().getName() );
}

I get:
/app:company_home
14
—->cm:folder
—->cm:folder
—->cm:folder
—->cm:content
—->cm:content
—->cm:content
—->cm:content
—->cm:content
—->cm:content
—->cm:folder
—->cm:content
—->cm:folder
—->cm:folder
—->cm:folder

Great, this is correct for me since this is what i see in the alfresco webclient.
Now if if change the line
System.out.println("—->" + child.getPrimaryNodeType().getName() );
to
System.out.println("—->" + child.getName() );
I only get

/app:company_home
14
—->app:dictionary
—->app:guest_home
—->cm:users


strange isn't it ??
note: I catch NO RepositoryException.

Any help would be appreciate.
bernie

bparis
Champ in-the-making
Champ in-the-making
In deed I get a NamespaceException when using child.getName() or child.getPath() :
org.alfresco.service.namespace.NamespaceException: A namespace prefix is not registered for uri cm
….

but I don't understand why….
Bernie

davidc
Star Contributor
Star Contributor
org.alfresco.service.namespace.NamespaceException: A namespace prefix is not registered for uri cm

The namespace uri 'cm' does indeed seem invalid; by default 'cm' is defined as a namespace prefix.

So, I suspect that child nodes have been created using an invlalid QName.  Not sure how.  How are you creating those nodes?

bparis
Champ in-the-making
Champ in-the-making
this node was created with one of the example code in the alfresco SDK (FirstFoundationClient or FirstWebServiceClient, I don't remember the which one).

BP.