Dear esteemed sir's, I am struggling to make a node shareable in jackrabbit using jcr and following the specs at:-
http://www.day.com/specs/jcr/2.0/14_Shareable_Nodes.html It clearly mentions that to make a node shareable we need to write W.clone(“W”, “/A/B/C”, “/X/Y/Z”, false) But I get below error :- javax.jcr.RepositoryException: default: illegal workspace (same as current) , caused in org.apache.jackrabbit.jcr2spi.WorkspaceImpl can you provide some help on it so that we can document it in the interest of developer communty. I used below code, String url = FileShipUtils.getInstance().getServerURL(); url = url.replaceFirst("/repository/default", "/server"); Repository repository = JcrUtils.getRepository(url); String username = FileShipUtils.getInstance().getUserName(); String password = FileShipUtils.getInstance().getPassword(); Session session = repository.login(new SimpleCredentials(username, password.toCharArray()), null); String originalPath = "/domains/files1.correspond.de/users/test1/files/000.txt"; String sharedPath = "/domains/files1.correspond.de/users/test1/files/pahmad.txt"; Node sharableNode = session.getNode(originalPath); //Node sharableNode = session.getNode(originalPath); if (!sharableNode.isNodeType(MIX_SHAREABLE)) { sharableNode.addMixin(MIX_SHAREABLE); } sharableNode.save(); session.getNode(originalPath).save(); session.save(); makeShare(session,originalPath, sharedPath); session.save(); // Session session1 = repository. Workspace workspace = sharableNode.getSession().getWorkspace(); String path = "/domains/files1.correspond.de/users/test1/files/pahmad.txt"; makeShare(session,originalPath, sharedPath); workspace.clone(workspace.getName(), sharableNode.getPath(),path, false); protected Node makeShare( Session session, String sourcePath, String newSharePath ) throws RepositoryException { // Make sure the source node exists ... Node original = session.getNode(sourcePath); // It is expected that a node does not exist at the supplied path, so verify this... boolean exists = session.nodeExists(newSharePath); Workspace workspace = session.getWorkspace(); // Then this call will create a shared node at this exact path ... workspace.clone(workspace.getName(), sourcePath, newSharePath, false); // If we've succeeded in the creation of the share, we can make sure that a node did // not already exist (otherwise the call should have then failed) ... //assertThat(exists, is(false)); // Now look up the new share node ... Node node = session.getNode(newSharePath); // And verify that this node has the same path and name ... //assertThat(node.getPath(), is(newSharePath)); //assertThat(node.getName(), is(string(path(newSharePath).getLastSegment().getName()))); //assertThat(node.getIndex(), is(path(newSharePath).getLastSegment().getIndex())); // But that the identity, properties and children match the original node ... //verifyShare(original, node); return node; } protected static final String MIX_SHAREABLE = "mix:shareable"; with sincere regards and esteem, Yours sincerely, Parvez Ahmad Hakim Srinagar Kashmir India
