本文整理了Java中javax.jcr.Node.update()
方法的一些代码示例,展示了Node.update()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.update()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:update
[英]If this node does have a corresponding node in the workspace srcWorkspace
, then this replaces this node and its subgraph with a clone of the corresponding node and its subgraph.
If this node does not have a corresponding node in the workspace srcWorkspace
, then the update
method has no effect.
If the update
succeeds the changes made are persisted immediately, there is no need to call save
.
Note that update
does not respect the checked-in status of nodes. An update
may change a node even if it is currently checked-in (This fact is only relevant in an implementation that supports versioning).
[中]如果此节点在工作区srcWorkspace
中确实有一个对应的节点,则会用对应节点及其子图的克隆来替换此节点及其子图。
如果此节点在工作区srcWorkspace
中没有相应的节点,则update
方法无效。
如果update
成功,所做的更改将立即持久化,则无需调用save
。
请注意,update
不尊重节点的签入状态。update
可能会更改节点,即使该节点当前已签入(此事实仅与支持版本控制的实现相关)。
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
/**
* @inheritDoc
*/
public void update(String srcWorkspaceName) throws NoSuchWorkspaceException, AccessDeniedException, LockException,
InvalidItemStateException, RepositoryException {
node.update(srcWorkspaceName);
}
代码示例来源:origin: apache/jackrabbit
public Object run() throws RepositoryException {
getNode(nodeId, sInfo).update(srcWorkspaceName);
return null;
}
}, sInfo);
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr
public Object run() throws RepositoryException {
getNode(nodeId, sInfo).update(srcWorkspaceName);
return null;
}
}, sInfo);
代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr
public void update(String s) throws RepositoryException {
this.item.update(s);
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public void update(String workspace)
throws RepositoryException, RemoteException {
try {
node.update(workspace);
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public void update(String srcWorkspace) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
getWrappedNode().update(srcWorkspace);
}
代码示例来源:origin: brix-cms/brix-cms
public void execute() throws Exception {
getDelegate().update(srcWorkspaceName);
}
});
代码示例来源:origin: nl.vpro/jcr-criteria
@Override
public void update(String srcWorkspace) throws RepositoryException {
getNode().update(srcWorkspace);
}
代码示例来源:origin: apache/jackrabbit
/**
* Tries to use {@link javax.jcr.Node#update(String)} with an invalid
* workspace.
* <p>
* This should throw an {@link javax.jcr.NoSuchWorkspaceException}.
*/
public void testUpdateNoSuchWorkspaceException() throws RepositoryException {
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create a test node in default workspace
Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
// save changes
superuser.save();
try {
testNode.update(getNonExistingWorkspaceName(superuser));
fail("Calling Node.update() on a non existing workspace should throw NoSuchWorkspaceException");
} catch (NoSuchWorkspaceException e) {
// ok, works as expected
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Calls {@link javax.jcr.Node#update(String)} for a node that only exists
* in current workspace. <br><br> In that case nothing should happen.
* <p>
* Prerequisites: <ul> <li><code>javax.jcr.tck.propertyname1</code>
* name of a String property that can be modified in
* <code>javax.jcr.tck.nodetype</code> for testing</li> </ul>
*/
public void testUpdateNoClone() throws RepositoryException {
// get default workspace test root node using superuser session
Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
// create a test node in default workspace
Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
// modify the node
testNode.setProperty(propertyName1, "test");
superuser.save();
// call the update method on test node in default workspace
testNode.update(workspaceName);
// check if property is still there
assertTrue("Node got property removed after Node.update() eventhough node has no clone", testNode.hasProperty(propertyName1));
// check if node did not get children suddenly
assertFalse("Node has children assigned after Node.update() eventhough node has no clone", testNode.hasNodes());
}
代码示例来源:origin: apache/jackrabbit
public void testPendingChangesSameWorkspace() throws RepositoryException, NotExecutableException {
testRootNode.addNode(nodeName2, testNodeType);
try {
testRootNode.update(currentWorkspace);
fail("Update while changes are pending must fail with InvalidItemStateException");
} catch (InvalidItemStateException e) {
// ok
}
}
代码示例来源:origin: apache/jackrabbit
public void testSameWorkspace() throws RepositoryException, NotExecutableException {
try {
// update without corresponding node must be a nop
testRootNode.update(currentWorkspace);
} catch (RepositoryException e) {
fail("Update with srcWorkspace == this workspace must return silently.");
}
}
代码示例来源:origin: stackoverflow.com
void foo (Node node){
node.update()
}
bar(){
foo (new Node())
foo (new Derived())
}
代码示例来源:origin: apache/jackrabbit
public void testInvalidSrcWorkspace() throws RepositoryException {
String nonExistingWorkspace = "nonExistingWorkspace";
String[] accessibleWorkspaces = testRootNode.getSession().getWorkspace().getAccessibleWorkspaceNames();
List<String> l = Arrays.asList(accessibleWorkspaces);
while (l.contains(nonExistingWorkspace)) {
nonExistingWorkspace = nonExistingWorkspace + "_";
}
try {
testRootNode.update(nonExistingWorkspace);
} catch (NoSuchWorkspaceException e) {
// ok
}
}
代码示例来源:origin: apache/jackrabbit
public void testPendingChanges() throws RepositoryException, NotExecutableException {
testRootNode.addNode(nodeName2, testNodeType);
String srcWorkspace = getAnotherWorkspace();
try {
testRootNode.update(srcWorkspace);
fail("Update while changes are pending must fail with InvalidItemStateException");
} catch (InvalidItemStateException e) {
// ok
}
}
代码示例来源:origin: brix-cms/brix-cms
public void update(String srcWorkspaceName) throws RepositoryException {
getActionHandler().beforeNodeUpdate(this);
getDelegate().update(srcWorkspaceName);
getActionHandler().afterNodeUpdate(this);
}
代码示例来源:origin: apache/jackrabbit
s2.save();
test.update(workspace2);
代码示例来源:origin: apache/jackrabbit
public void testPendingChangesOnOtherNode() throws RepositoryException, NotExecutableException {
try {
Node root = testRootNode.getSession().getRootNode();
if (root.isSame(testRootNode)) {
throw new NotExecutableException();
}
if (root.canAddMixin(mixLockable)) {
root.addMixin(mixLockable);
} else {
root.setProperty(propertyName1, "anyValue");
}
} catch (RepositoryException e) {
throw new NotExecutableException();
}
String srcWorkspace = getAnotherWorkspace();
try {
testRootNode.update(srcWorkspace);
fail("Update while changes are pending must fail with InvalidItemStateException");
} catch (InvalidItemStateException e) {
// ok
}
}
代码示例来源:origin: apache/jackrabbit
public void testUpdateRemovesExtraProperty() throws RepositoryException, NotExecutableException {
// create test node in default workspace
testRootNode.setProperty(propertyName2, "test");
testRootNode.save();
String srcWorkspace = getAnotherWorkspace();
// get the root node in the second workspace
Session session2 = getHelper().getSuperuserSession(srcWorkspace);
try {
// make sure the source-session has the corresponding node.
Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
if (testRootW2.hasProperty(propertyName2)) {
throw new NotExecutableException();
}
// call the update method on test node in default workspace
testRootNode.update(srcWorkspace);
// ok first check if node has no longer properties
assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
} catch (PathNotFoundException e) {
throw new NotExecutableException();
} catch (ItemNotFoundException e) {
throw new NotExecutableException();
} finally {
session2.logout();
}
}
代码示例来源:origin: apache/jackrabbit
public void testNoCorrespondingNode() throws RepositoryException, NotExecutableException {
Node n = testRootNode.addNode(nodeName2, testNodeType);
testRootNode.save();
String srcWorkspace = null;
String wspName = getHelper().getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");
if (wspName == null) {
throw new NotExecutableException("Cannot run update. Missing config param.");
}
try {
n.getCorrespondingNodePath(wspName);
} catch (ItemNotFoundException e) {
srcWorkspace = wspName;
} catch (RepositoryException e) {
throw new NotExecutableException("Cannot run update. Workspace " + srcWorkspace + " does not exist or is not accessible.");
}
if (srcWorkspace == null) {
throw new NotExecutableException("Cannot run update. No workspace found, that misses the corresponding node.");
}
try {
// update without corresponding node must be a nop
testRootNode.update(srcWorkspace);
} catch (RepositoryException e) {
fail("Update with workspace that doesn't contain the corresponding node must work.");
}
}
内容来源于网络,如有侵权,请联系作者删除!