我正在尝试重命名Jackrabbit中的节点,但它失败,如下所示。给定节点“/ fooNode”,我希望它被重命名为“/ fooNodeRenamed”。
我的客户端是基于JavaDavexClient的简单Java程序,在Debian Wheezy上使用Apache Jackrabbit 2.6.2和Oracle Java 1.7.0_25。
以下是代码:
import javax.jcr.Credentials;
import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Workspace;
import javax.jcr.SimpleCredentials;
import javax.jcr.version.*;
import ch.liip.jcr.davex.DavexClient;
public class Client
{
public static void main(String[] args)
{
try {
// Config
String url = "http://localhost:8080/jackrabbit/server/";
String sourceWorkspaceName = "test-preview";
// Setup
DavexClient Client = new DavexClient(url);
Repository repo = Client.getRepository();
Credentials sc = new SimpleCredentials("admin", "admin".toCharArray());
Session sourceSession = repo.login(sc, sourceWorkspaceName);
// Create a node
Node fooNode = sourceSession.getRootNode().addNode("fooNode");
sourceSession.save();
// Rename the node - GIVES EXCEPTION
sourceSession.move("/fooNode", "/fooNodeMoved");
// This line is never reached
sourceSession.save();
} catch (RepositoryException e) {
e.printStackTrace();
}
}
}
我每次在运行上面之前清除工作区。这是一个例外:
javax.jcr.RepositoryException: Internal Server Error
at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:120)
at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:51)
at org.apache.jackrabbit.spi2dav.ExceptionConverter.generate(ExceptionConverter.java:45)
at org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.isGranted(RepositoryServiceImpl.java:904)
at org.apache.jackrabbit.jcr2spi.WorkspaceManager.canRead(WorkspaceManager.java:695)
at org.apache.jackrabbit.jcr2spi.state.ItemStateValidator.checkIsWritable(ItemStateValidator.java:199)
at org.apache.jackrabbit.jcr2spi.state.ItemStateValidator.checkRemoveItem(ItemStateValidator.java:431)
at org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager.visit(SessionItemStateManager.java:282)
at org.apache.jackrabbit.jcr2spi.operation.Move.accept(Move.java:89)
at org.apache.jackrabbit.jcr2spi.state.SessionItemStateManager.execute(SessionItemStateManager.java:215)
at org.apache.jackrabbit.jcr2spi.SessionImpl.move(SessionImpl.java:323)
at Client.main(Client.java:32)
Caused by: org.apache.jackrabbit.webdav.DavException: Internal Server Error
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.getResponseException(DavMethodBase.java:165)
at org.apache.jackrabbit.webdav.client.methods.DavMethodBase.checkSuccess(DavMethodBase.java:174)
at org.apache.jackrabbit.spi2dav.RepositoryServiceImpl.isGranted(RepositoryServiceImpl.java:876)
... 8 more
知道什么是错的吗?这是我的代码或环境的问题吗?
答案 0 :(得分:2)
我遇到了同样的问题。我通过使用Workspace对象的move方法而不是Session对象来解决它:
getSession().getWorkspace().move(node.getPath(), parentPath + newName);
答案 1 :(得分:0)
这绝对是jackrabbit-spi2dav-version 2.7.2的问题。它在版本2.5.2中不存在。
答案 2 :(得分:0)
Falcon的解决方案在Jackrabbit 2.7.0上为我工作。我认为据报道是JCR-3364的一部分。我刚刚尝试使用Jackrabbit 2.7.3,Session.move和Workspace.move都按预期工作。
与下面的错误报告一样,执行移动的用户没有对完整源和目标树的读访问权限。 2.7.0版本错误地要求对完整树进行读取/删除/添加访问,而不是仅移动节点和父项。