11

JCR (apache jackrabbit) を使い始めたばかりです。簡単な質問をしたいと思います (適切なチュートリアルが見つからないため)。彼らはどういう意味ですか?

どうも

4

2 に答える 2

10

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.

于 2010-10-18T16:09:54.043 に答える
4

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");
于 2010-10-18T11:54:04.670 に答える