cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript addNode but cannot addChild in Java?

esource
Champ on-the-rise
Champ on-the-rise
In Javascript, I can use the addNode() method to add an existing node to a new space.  But in Java if I try to do the same thing with addChild(), I get an error:

org.alfresco.service.cmr.repository.DuplicateChildNodeNameException: Duplicate child name not allowed:

Is this action allowed in Javascript but not in Java?  What do I need to do to make it work with Java?
3 REPLIES 3

esource
Champ on-the-rise
Champ on-the-rise
this case makes me want to ask the question can we use the javascript api within java in Alfresco?

mrogers
Star Contributor
Star Contributor
Yes you can use the javascript API from Java, you use the script service to run a script.  But why bother?  
The Java API is the one to use and can do everything the Script API can do and more.

Your error is that you are trying to create a duplicate which is not allowed.  

Sort out the parameters to your java call and it will work.

esource
Champ on-the-rise
Champ on-the-rise
Yes, you are right.  There were duplicates in the same space.  But they were duplicates in name only.  The nodes were located in different locations but they happened to have the same name.  It makes me wonder why Alfresco considers nodes with only the same name as duplicates even if their node references and locations are different.