cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the namespace given to a copied node

dallinns
Champ on-the-rise
Champ on-the-rise
I have a webscript that copies a node to another directory. It works fine other than it automatically assigns the default namespace when I want it to assign my own:
{http://www.alfresco.org/model/content/1.0}Copy of dwell.odt
But I really want it to say:
{ls.model}Copy of dwell.odt
like the parent node
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
What property are you using and how are you copying?

dallinns
Champ on-the-rise
Champ on-the-rise
destNode = search.findNode("workspace://SpacesStore/"+url.templateArgs.destNodeId);

nodeToCopy = search.findNode("workspace://SpacesStore/"+url.templateArgs.nodeToCopyId);

newNode = nodeToCopy.copy(destNode, true);

nodeToCopy.save();
newNode.save();

model.newNode = newNode;


So the problem is that the path to the original node is something like this:
   
/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1....

whereas the copy ends up like this:
   
/{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/content/1.... of dwell.odt

mrogers
Star Contributor
Star Contributor
So it is the node's primary assoc that you want to control.

Unfortunately the Java Script API does not present options for setting the namespace, simplifying the API by assuming that you will use the bog standard cm namespace.

The Java API copy service will give you the extra control you need.

Other ways would be to copy the node yourself or call the copy method and then move the node.

Incidentally why do you need your own namespace for the primary assoc?

dallinns
Champ on-the-rise
Champ on-the-rise
I have a script that navigates through folders using a lucene path query which requires that you specify the namespace of the folder. And now the script is breaking because it can't navigate through the folders because it expects the namespace to be my custom one.