本文整理了Java中javax.jcr.Node.checkout()
方法的一些代码示例,展示了Node.checkout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.checkout()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:checkout
[英]Sets this versionable node to checked-out status by setting its jcr:isCheckedOut
property to true
. Under full versioning it also sets the jcr:predecessors
property to be a reference to the current base version (the same value as held in jcr:baseVersion
). These changes are made by worksapce-write and therefore do require a save
.
The part of the subgraph of this node that is affected by the checked-out status of this node becomes no longer read-only.
If this node is already checked-out, this method has no effect.
[中]通过将其jcr:isCheckedOut
属性设置为true
,将此可版本化节点设置为签出状态。在完全版本控制下,它还将jcr:predecessors
属性设置为对当前基本版本的引用(与jcr:baseVersion
中的值相同)。这些更改由worksapce write进行,因此确实需要save
。
此节点的子图中受此节点的签出状态影响的部分不再是只读的。
如果此节点已签出,则此方法无效。
代码示例来源:origin: apache/jackrabbit
/**
* Returns the date this version was created.
*/
public void testGetCreated() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
Calendar now = GregorianCalendar.getInstance();
now.add(Calendar.SECOND, 1);
assertTrue("Method getCreated() should return a creation date before current date.", version.getCreated().before(now));
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns the predecessor versions of this version. This corresponds to
* returning all the nt:version nodes whose jcr:successors property includes
* a reference to the nt:version node that represents this version. A
* RepositoryException is thrown if an error occurs.
*/
public void testGetPredecessors() throws RepositoryException {
// create a new version
versionableNode.checkout();
Version version = versionableNode.checkin();
assertTrue("Version should have at minimum one predecessor version.", version.getPredecessors().length > 0);
}
代码示例来源:origin: apache/jackrabbit
/**
* Node.merge(): If V' of a versionable subnode N' in the source workspace
* is a successor of V (the base version of a subnode N in this workspace),
* calling merge must fail.
*/
public void testFailIfCorrespondingNodeIsSuccessor() throws RepositoryException {
// make V' of a subnode N' in source workspace be a successor version of
// the base version of the corresponding subnode.
Node n = testRootNode.getNode(nodeName1 + "/" + nodeName2);
n.checkout();
n.checkin();
n.checkout();
try {
// merge, besteffort set to false to stop at the first failure
nodeToMerge.merge(workspace.getName(), false);
fail("Merging a checkedout node if the version V' of the corresponding node is a successor of this node's base version must fail.");
} catch (MergeException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Test if InvalidItemStateException is thrown if the session affected by
* Workspace.restore(Version[], boolean) has pending changes.
*/
@SuppressWarnings("deprecation")
public void testWorkspaceRestoreWithPendingChanges() throws RepositoryException {
versionableNode.checkout();
try {
// modify node without calling save()
versionableNode.setProperty(propertyName1, propertyValue);
// create version in second workspace
Version v = wVersionableNode.checkin();
// try to restore that version
superuser.getWorkspace().restore(new Version[]{v}, false);
fail("InvalidItemStateException must be thrown on attempt to call Workspace.restore(Version[], boolean) in a session having any unsaved changes pending.");
} catch (InvalidItemStateException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Node.merge(): If V' of a versionable subnode N' in the source workspace
* is a predeccessor of V or V' identical to V (the base version of a
* subnode N in this workspace), calling merge must be leave.
*/
public void testLeaveIfCorrespondingNodeIsPredeccessor() throws RepositoryException {
// make V' of a subnode N' in source workspace be a predeccessor version of
// the base version of the corresponding subnode.
Node n = testRootNodeW2.getNode(nodeName1 + "/" + nodeName2);
n.checkout();
n.setProperty(propertyName1, CHANGED_STRING);
testRootNodeW2.save();
n.checkin();
n.checkout();
// merge, besteffort set to false to stop at the first failure
nodeToMerge.merge(workspace.getName(), false);
// check if subnode has status "leave"
assertTrue(n.getProperty(propertyName1).getString().equals(CHANGED_STRING));
}
代码示例来源:origin: apache/jackrabbit
/**
* Test the restore of a OnParentVersion-Ignore node
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreNode() throws RepositoryException {
versionableNode.checkout();
Version v = versionableNode.checkin();
versionableNode.checkout();
// add 'ignore' child
String childName = addChildNode(OPVAction).getName();
versionableNode.save();
versionableNode.restore(v, false);
if (!versionableNode.hasNode(childName)) {
fail("On restore of a OnParentVersion-Ignore child node, the node needs to be untouched.");
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Test the restore of a OnParentVersion-INITIALIZE property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreProp() throws RepositoryException {
Node propParent = p.getParent();
propParent.checkout();
Version v = propParent.checkin();
propParent.checkout();
p.setValue(newPropValue);
p.save();
propParent.restore(v, false);
assertEquals("On restore of a OnParentVersion-INITIALIZE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
}
代码示例来源:origin: apache/jackrabbit
/**
* Test the restore of a OnParentVersion-IGNORE property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreProp() throws RepositoryException {
Node propParent = p.getParent();
propParent.checkout();
Version v = propParent.checkin();
propParent.checkout();
p.setValue(newPropValue);
p.save();
propParent.restore(v, false);
assertEquals("On restore of a OnParentVersion-IGNORE property P, the current value of P must be left unchanged.", p.getString(), newPropValue);
}
代码示例来源:origin: apache/jackrabbit
/**
* Test the restore of a OnParentVersion-COMPUTE property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreProp() throws RepositoryException {
Node propParent = p.getParent();
propParent.checkout();
Version v = propParent.checkin();
propParent.checkout();
p.setValue(newPropValue);
p.save();
propParent.restore(v, false);
assertEquals("On restore of a OnParentVersion-COMPUTE property P, the current P in the workspace will be left unchanged.", p.getString(), newPropValue);
}
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
Node n = test.addNode("test");
n.addMixin(mixVersionable);
session.save();
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
n.checkout();
n.checkin();
}
n.checkout();
}
}, CONCURRENCY);
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
// add versionable nodes
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
Node n = test.addNode("test" + i);
n.addMixin(mixVersionable);
session.save();
n.checkout();
n.checkin();
n.checkout();
}
}
}, CONCURRENCY);
代码示例来源:origin: apache/jackrabbit
public void testRestoreChild1() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionableNode.checkin();
versionableNode.checkout();
Version v2 = versionableNode.checkin();
versionableNode.restore(v1, true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionableNode.restore(version, true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionableNode.restore(v2, true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Test the restore of a OnParentVersion-ABORT property
*
* @throws javax.jcr.RepositoryException
*/
public void testRestoreProp() throws RepositoryException {
try {
p.getParent().checkout();
p.getParent().checkin();
fail("On checkin of N which has a property with OnParentVersion ABORT defined, an UnsupportedRepositoryOperationException must be thrown.");
} catch (VersionException e) {
// success
}
}
代码示例来源:origin: apache/jackrabbit
@SuppressWarnings("deprecation")
public void testRestoreChild1() throws RepositoryException {
versionableNode.addNode("child1");
versionableNode.getSession().save();
Version v1 = versionableNode.checkin();
versionableNode.checkout();
Version v2 = versionableNode.checkin();
versionableNode.restore(v1, true);
assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
versionableNode.restore(version, true);
assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
try {
versionableNode.restore(v2, true);
} catch (RepositoryException e) {
fail("Node.restore('1.3') must fail.");
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Node.merge(): bestEffort is false and any merge fails a MergeException is
* thrown.<br>
*/
@SuppressWarnings("deprecation")
public void testMergeNodeBestEffortFalse() throws RepositoryException {
/// create successor versions for a node
// so merge fails for this node
// default workspace
Node originalNode = testRootNode.getNode(nodeName1);
originalNode.checkout();
originalNode.checkin();
// "merge" the clonedNode with the newNode from the default workspace
// merge, besteffort set to false
try {
nodeToMerge.merge(workspace.getName(), false);
fail("bestEffort is false and any merge should throw a MergeException.");
} catch (MergeException e) {
// successful
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if VersionHistory.getVersionableUUID() returns the uuid of the
* corresponding versionable node.
*/
public void testGetVersionableUUID() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
assertEquals("Method getVersionableUUID() must return the UUID of the corresponding Node.",
version.getContainingHistory().getVersionableUUID(),
versionableNode.getUUID());
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if {@link javax.jcr.version.Version#getContainingHistory()} returns
* the correct VersionHistory instance.
*/
public void testGetContainingHistory() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
assertTrue("Method getContainingHistory() must return the same VersionHistory " +
"as getVersionHistory() of the corresponding Node.",
versionableNode.getVersionHistory().isSame(version.getContainingHistory()));
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns the date this version was created. This corresponds to the value
* of the jcr:created property in the nt:version node that represents this
* version.
*/
public void testGetCreatedCheckAgainstProperty() throws RepositoryException {
// create version
versionableNode.checkout();
Version version = versionableNode.checkin();
Calendar calGetCreated = version.getCreated();
Calendar calCreatedProp = version.getProperty(jcrCreated).getValue().getDate();
assertEquals("Method getCreated() should return value of the jcr:created property.", calGetCreated, calCreatedProp);
}
代码示例来源:origin: apache/jackrabbit
public void execute(Session session, Node test) throws RepositoryException {
Node n = test.addNode("test");
n.addMixin(mixVersionable);
session.save();
// create 3 version
List versions = new ArrayList();
for (int i = 0; i < 3; i++) {
n.checkout();
versions.add(n.checkin());
}
// do random restores
Random rand = new Random();
for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
Version v = (Version) versions.get(rand.nextInt(versions.size()));
n.restore(v, true);
}
n.checkout();
}
}, CONCURRENCY);
代码示例来源:origin: apache/jackrabbit
public void run() {
long end = System.currentTimeMillis() + RUN_NUM_SECONDS * 1000;
try {
Node vn = (Node) s.getItem(n.getPath());
while (end > System.currentTimeMillis()) {
vn.checkout();
vn.checkin();
}
} catch (RepositoryException e) {
e.printStackTrace();
} finally {
s.logout();
}
}
});
内容来源于网络,如有侵权,请联系作者删除!