You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Parvez Hakim <pa...@gmail.com> on 2010/08/25 10:42:52 UTC
Fwd: Workspace clone jackrabbit 2.1 not in line with jsr-283
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
Re: Workspace clone jackrabbit 2.1 not in line with jsr-283
Posted by Jukka Zitting <ju...@gmail.com>.
Dear Mr. Hakim,
On Wed, Aug 25, 2010 at 10:42 AM, Parvez Hakim <pa...@gmail.com> wrote:
> 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
The SPI layer in Jackrabbit, that's used for example by the WebDAV
remoting code, does not yet fully support all JCR 2.0 features like
shareable nodes. See JCR-2099 [1] for the related open issue.
Shareable nodes are supported when you use a local Jackrabbit instance
(i.e. jackrabbit-core) or access the repository remotely through the
JCR-RMI layer.
[1] https://issues.apache.org/jira/browse/JCR-2099
Best regards,
Jukka Zitting