jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SCHEDENIG Marian <Marian.Schede...@infinica.com>
Subject Workspace.copy() not updating existing target node?
Date Thu, 27 Mar 2014 11:17:38 GMT

I'm struggling with Workspace's copy method.


The way I understand the specification, it should copy the entire sub tree of the source node,
even if the target node already exists (in this case updating any already existing nodes).
Or, failing that, it should throw an exception.

But the behaviour I get differs: If the target node does not exist, the source sub tree is
copied correctly. If the target node exists, it seems to be not changed at all. In particular,
if the source node has child nodes and the target node exists and is empty before the copy
call, it is still empty after the call finishes (without exceptions).

Is this a bug? It doesn't seem to be, because I've been getting this behaviour with Jackrabbit
2.4.2, 2.6.5 and 2.7.5. But if it isn't, what about the specification am I not interpreting

Here's the relevant code from my test method. I'm not providing the full file, as it references
a couple of project internal convenience classes for setting up stuff, but the issue should
be clear from this snippet. If required, I can create a standalone test class.

public void testCopy() throws LoginException, RepositoryException, IOException
                Node root = session.getRootNode();

                Node dir1 = createFolder(root, "dir1");
                Node file1 = createFile(dir1, "file.txt");
                storeContent(file1, "test1".getBytes());

                Node dir2 = createFolder(root, "dir2");
                Node file2 = createFile(dir2, "file.txt");
                storeContent(file2, "test2".getBytes());

                Node dir3 = createFolder(root, "dir3");

                Assert.assertEquals("test1", new String(readContent(file1)));
                Assert.assertEquals("test2", new String(readContent(file2)));

                session.getWorkspace().copy(dir1.getPath(), dir3.getPath());
//            session.getWorkspace().copy(dir1.getPath(), root.getPath() + "dir3/");

//            Node dir3 = root.getNode("dir3");
                Assert.assertEquals(1, getChildren(dir3).size());
                Node file3 = dir3.getNode("file.txt");
                Assert.assertEquals("test1", new String(readContent(file3)));

                session.getWorkspace().copy(dir1.getPath(), dir2.getPath());

                Assert.assertEquals("test1", new String(readContent(file1)));
                Assert.assertEquals("test1", new String(readContent(file2)));

This code fails at Assert.assertEquals(1, getChildren(dir3).size());, because the existing
dir3 node is still empty after the copy().

If I remove the current dir3 assignment and the matching copy() call and instead activate
the currently commented out lines, the dir3 segment runs through and the final assert fails,
because file2 was not changed by the second copy() call.


DI Marian Schedenig
Senior Developer

[Description: Description: Description: Description: Description: Description: cid:image001.png@01CCBE64.F3314040]

INFINICA - Member of Qualysoft Group
Leonard-Bernstein-Straße 10
A-1220 Wien

Tel +43 1 263 12 96
Fax +43 1 4095987-11


P Please consider the environment before printing this email

  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message