Hi,

I am trying to copy a node using  workspace.copy api

I am using it as

workspace.copy("/test/CopySource/testCopyCommand" , 
"/test/CopyDestination/testCopyCommand"); 

The exception I get is    -  javax.jcr.RepositoryException: Invalid 
path:/test/CopyDestination//testCopyCommand


Details ::

I am getting session using webdav

Using this code is causing exception

                Node testNode1 = session.getRootNode().addNode("test", 
"sling:Folder");
                Node copyDestination = testNode1.addNode("CopyDestination", 
"sling:Folder");
                testNode1.addNode("CopySource", 
"sling:Folder").addNode("testCopyCommand", "sling:Folder").addNode("abc", 
"sling:Folder");
                session.save();
                
                copyDestination.addMixin("mix:referenceable");
                session.save();
                
                try{
                        ws.copy("/test/CopySource/testCopyCommand" , 
"/test/CopyDestination/testCopyCommand");
                }
                catch (Exception e) {
                        e.printStackTrace();
                }

This will create the exception  -  javax.jcr.RepositoryException: Invalid 
path:/test/CopyDestination//testCopyCommand
It is adding a  ‘/’ in between and telling invalid path

But using the following code is working as expected.

                Node testNode1 = session.getRootNode().addNode("test", 
"sling:Folder");
                testNode1.addNode("CopyDestination", 
"sling:Folder").addMixin(NodeType.MIX_REFERENCEABLE);;
                testNode1.addNode("CopySource", 
"sling:Folder").addNode("testCopyCommand", "sling:Folder").addNode("abc", 
"sling:Folder");
                session.save();
                
                try{
                        ws.copy("/test/CopySource/testCopyCommand" , 
"/test/CopyDestination/testCopyCommand");
                }
                catch (Exception e) {
                        e.printStackTrace();
                }


Thank you
Sriraj



Reply via email to