本文整理了Java中javax.jcr.Node.checkin()
方法的一些代码示例,展示了Node.checkin()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.checkin()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:checkin
[英]Creates a new version of this node and returns that Versionobject. The new version becomes the base version of this node. The name of the new version is implementaion determined.
This node becomes checked-in and its jcr:checkedOut
property is set to false to reflect this. On a successful check-in the change to this property is made as a workspace-write, and therefore does not require a save
.
The part of the subgraph of this node that is affected by check-in becomes read-only (see the specification for details).
If this node is already checked-in, this method has no effect but returns the current base version of this node.
[中]创建此节点的新版本并返回该版本对象。新版本将成为此节点的基础版本。新版本的名称已确定。
此节点将被检入,其jcr:checkedOut
属性设置为false以反映此情况。成功签入时,此属性的更改作为工作区写入进行,因此不需要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
/**
* 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
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(): 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
@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(): 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 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-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
/**
* 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
/**
* 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
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
/**
* 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 {
// 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
/**
* 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
/**
* Node.merge(): versionable subNode N checked-in: If V' is a successor (to
* any degree) of V, then the merge result for N is update<br> modify a node
* on the workspace1 and then merge the one in workspace2 with the one in
* workspace1 precondition is that the node in workspace2 is checked in
*/
@SuppressWarnings("deprecation")
public void disable_testMergeNodeFromUpdatedSourceWorkspace() throws RepositoryException {
Node originalNode = testRootNode.getNode(nodeName1);
// update nodeName1 on workspace1
originalNode.checkout();
originalNode.checkin();
testRootNode.getSession().save();
// "merge" the clonedNode with the newNode from the default workspace
// besteffort set to false to stop at the first failure
nodeToMerge.merge(workspace.getName(), false);
final String originalBaseVersionUUID = originalNode.getBaseVersion().getUUID();
final String clonedBaseVersionUUID = nodeToMerge.getBaseVersion().getUUID();
assertTrue("clonedNode has different version UUID than expected, it should be updated with the newNode version UUID", originalBaseVersionUUID.equals(clonedBaseVersionUUID));
}
代码示例来源: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 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();
}
}
});
代码示例来源: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);
内容来源于网络,如有侵权,请联系作者删除!