JCR 签入/结账操作

发布于 2024-09-27 19:17:10 字数 124 浏览 8 评论 0原文

我刚刚开始使用 JCR (apache jackrabbit),我想问一个简单的问题(因为我找不到好的教程): 那么我需要 Node.checkout 和 Node.checkin 方法做什么? 它们是什么意思?

谢谢

I'm just starting to work with JCR (apache jackrabbit), i want to ask simple question (because i coudn't find good tutorial for it):
So for what do i need Node.checkout and Node.checkin methods?
What do they mean?

Thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑饮青盏花 2024-10-04 19:17:10

“签入”和“签出”方法与 JCR 存储库跟踪内容版本的方式有关。 “checkout”方法向存储库发出信号,表明您的客户端应用程序(可能)将修改某些版本控制的内容。 “签入”方法向存储库发出信号,表明您的客户端应用程序已对版本控制内容进行了更改,并且存储库应在版本历史记录中记录这些更改(例如,新版本)。

例如,假设我们要在“/a/b/c”处创建一个可版本控制的节点。这是使用类似以下代码的内容来完成的:

要创建内容,您只需在节点上设置“mix:versionable”mixin(或使用从“mix:versionable”继承的mixin或主节点类型),然后保存更改。此时,存储库将初始化该节点(或子图)的版本历史记录。

Node b = session.getNode("/a/b");
Node newNode = b.addNode("c");
newNode.addMixin("mix:versionable");
// set other properties and create children
session.save();

在“session.save()”上,存储库将记录“mix:versionable”mixin,并将初始化“/a/b/c”处内容的版本历史记录。从此时起,您的客户端应用程序使用“签出”和“签入”将新版本添加到历史记录中。

VersionManager vm = session.getWorkspace().getVersionManager();
vm.checkout("/a/b/c");
// make some changes at/under '/a/b/c'
session.save();
// Can make more changes and save, if desired
vm.checkin("/a/b/c");

当调用“checkin”时,存储库将获取“/a/b/c”的当前状态并将其添加到版本历史记录中。当然,每次您想要对版本控制节点进行更改时,都会重复此过程。

The 'checkin' and 'checkout' methods have to do with how a JCR repository tracks the versions of content. The 'checkout' method signals to the repository that your client application is (likely) going to be modifying some versionable content. The 'checkin' methods signals to the repository that your client application has made changes to the versionable content, and that the repository should record those changes (e.g., the new version) in the version history.

For example, let's imagine that we want to create a node at '/a/b/c' that is versionable. This is done using something like the following code:

To create content, you simply set the 'mix:versionable' mixin (or use a mixin or primary node type that inherits from 'mix:versionable') on a node and then save your changes. At that point, the repository will initialize the version history for that node (or subgraph).

Node b = session.getNode("/a/b");
Node newNode = b.addNode("c");
newNode.addMixin("mix:versionable");
// set other properties and create children
session.save();

Upon 'session.save()', the repository will note the 'mix:versionable' mixin and will initialize the version history for the content at '/a/b/c'. From this point on, your client application uses 'checkout' and 'checkin' to add new versions to the history.

VersionManager vm = session.getWorkspace().getVersionManager();
vm.checkout("/a/b/c");
// make some changes at/under '/a/b/c'
session.save();
// Can make more changes and save, if desired
vm.checkin("/a/b/c");

When 'checkin' is called, the repository will take the current state of '/a/b/c' and will add it to the version history. Of course, this process is repeated each time you want to make changes to versionable nodes.

铜锣湾横着走 2024-10-04 19:17:10

在 Jackrabbit 2.x 中,Node 上的方法为 已弃用。相反,请使用 VersionManager.checkout / checkin (它们在 Jackrabbit 1.x 中也可用)。这是一些示例代码:

Node test = s.getRootNode().addNode("test");
Node t1 = test.addNode("t1");
t1.addMixin("mix:versionable");
s.save();
VersionManager vm = s.getWorkspace().
    getVersionManager();
vm.checkout("/test/t1");
t1.setProperty("data", "Hello" + i);
s.save();
vm.checkin("/test/t1");

In Jackrabbit 2.x, the methods on Node are deprecated. Instead, use VersionManager.checkout / checkin (they are available in Jackrabbit 1.x as well). Here is some sample code:

Node test = s.getRootNode().addNode("test");
Node t1 = test.addNode("t1");
t1.addMixin("mix:versionable");
s.save();
VersionManager vm = s.getWorkspace().
    getVersionManager();
vm.checkout("/test/t1");
t1.setProperty("data", "Hello" + i);
s.save();
vm.checkin("/test/t1");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文