jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Parvez Hakim <parve...@gmail.com>
Subject Fwd: Workspace clone jackrabbit 2.1 not in line with jsr-283
Date Wed, 25 Aug 2010 08:42:52 GMT
Dear esteemed sir's,
I am struggling to make a node shareable  in jackrabbit using jcr and
following  the specs at:-

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
                               password.toCharArray()), null);

               String originalPath =
               String sharedPath =
               Node sharableNode = session.getNode(originalPath);

               //Node sharableNode = session.getNode(originalPath);
               if (!sharableNode.isNodeType(MIX_SHAREABLE)) {


               makeShare(session,originalPath, sharedPath);

              // Session session1 = repository.
               Workspace workspace = sharableNode.getSession().getWorkspace();
               String path =
               makeShare(session,originalPath, sharedPath);

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));

               // 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

View raw message