javax.jcr.Node.update()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中javax.jcr.Node.update()方法的一些代码示例,展示了Node.update()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.update()方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:update

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

  1. /**
  2. * @inheritDoc
  3. */
  4. public void update(String srcWorkspaceName) throws NoSuchWorkspaceException, AccessDeniedException, LockException,
  5. InvalidItemStateException, RepositoryException {
  6. node.update(srcWorkspaceName);
  7. }

代码示例来源:origin: apache/jackrabbit

  1. public Object run() throws RepositoryException {
  2. getNode(nodeId, sInfo).update(srcWorkspaceName);
  3. return null;
  4. }
  5. }, sInfo);

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-spi2jcr

  1. public Object run() throws RepositoryException {
  2. getNode(nodeId, sInfo).update(srcWorkspaceName);
  3. return null;
  4. }
  5. }, sInfo);

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

  1. public void update(String s) throws RepositoryException {
  2. this.item.update(s);
  3. }

代码示例来源:origin: apache/jackrabbit

  1. /** {@inheritDoc} */
  2. public void update(String workspace)
  3. throws RepositoryException, RemoteException {
  4. try {
  5. node.update(workspace);
  6. } catch (RepositoryException ex) {
  7. throw getRepositoryException(ex);
  8. }
  9. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. @Override
  2. public void update(String srcWorkspace) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
  3. getWrappedNode().update(srcWorkspace);
  4. }

代码示例来源:origin: brix-cms/brix-cms

  1. public void execute() throws Exception {
  2. getDelegate().update(srcWorkspaceName);
  3. }
  4. });

代码示例来源:origin: nl.vpro/jcr-criteria

  1. @Override
  2. public void update(String srcWorkspace) throws RepositoryException {
  3. getNode().update(srcWorkspace);
  4. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Tries to use {@link javax.jcr.Node#update(String)} with an invalid
  3. * workspace.
  4. * <p>
  5. * This should throw an {@link javax.jcr.NoSuchWorkspaceException}.
  6. */
  7. public void testUpdateNoSuchWorkspaceException() throws RepositoryException {
  8. // get default workspace test root node using superuser session
  9. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  10. // create a test node in default workspace
  11. Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
  12. // save changes
  13. superuser.save();
  14. try {
  15. testNode.update(getNonExistingWorkspaceName(superuser));
  16. fail("Calling Node.update() on a non existing workspace should throw NoSuchWorkspaceException");
  17. } catch (NoSuchWorkspaceException e) {
  18. // ok, works as expected
  19. }
  20. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Calls {@link javax.jcr.Node#update(String)} for a node that only exists
  3. * in current workspace. <br><br> In that case nothing should happen.
  4. * <p>
  5. * Prerequisites: <ul> <li><code>javax.jcr.tck.propertyname1</code>
  6. * name of a String property that can be modified in
  7. * <code>javax.jcr.tck.nodetype</code> for testing</li> </ul>
  8. */
  9. public void testUpdateNoClone() throws RepositoryException {
  10. // get default workspace test root node using superuser session
  11. Node defaultRootNode = (Node) superuser.getItem(testRootNode.getPath());
  12. // create a test node in default workspace
  13. Node testNode = defaultRootNode.addNode(nodeName1, testNodeType);
  14. // modify the node
  15. testNode.setProperty(propertyName1, "test");
  16. superuser.save();
  17. // call the update method on test node in default workspace
  18. testNode.update(workspaceName);
  19. // check if property is still there
  20. assertTrue("Node got property removed after Node.update() eventhough node has no clone", testNode.hasProperty(propertyName1));
  21. // check if node did not get children suddenly
  22. assertFalse("Node has children assigned after Node.update() eventhough node has no clone", testNode.hasNodes());
  23. }

代码示例来源:origin: apache/jackrabbit

  1. public void testPendingChangesSameWorkspace() throws RepositoryException, NotExecutableException {
  2. testRootNode.addNode(nodeName2, testNodeType);
  3. try {
  4. testRootNode.update(currentWorkspace);
  5. fail("Update while changes are pending must fail with InvalidItemStateException");
  6. } catch (InvalidItemStateException e) {
  7. // ok
  8. }
  9. }

代码示例来源:origin: apache/jackrabbit

  1. public void testSameWorkspace() throws RepositoryException, NotExecutableException {
  2. try {
  3. // update without corresponding node must be a nop
  4. testRootNode.update(currentWorkspace);
  5. } catch (RepositoryException e) {
  6. fail("Update with srcWorkspace == this workspace must return silently.");
  7. }
  8. }

代码示例来源:origin: stackoverflow.com

  1. void foo (Node node){
  2. node.update()
  3. }
  4. bar(){
  5. foo (new Node())
  6. foo (new Derived())
  7. }

代码示例来源:origin: apache/jackrabbit

  1. public void testInvalidSrcWorkspace() throws RepositoryException {
  2. String nonExistingWorkspace = "nonExistingWorkspace";
  3. String[] accessibleWorkspaces = testRootNode.getSession().getWorkspace().getAccessibleWorkspaceNames();
  4. List<String> l = Arrays.asList(accessibleWorkspaces);
  5. while (l.contains(nonExistingWorkspace)) {
  6. nonExistingWorkspace = nonExistingWorkspace + "_";
  7. }
  8. try {
  9. testRootNode.update(nonExistingWorkspace);
  10. } catch (NoSuchWorkspaceException e) {
  11. // ok
  12. }
  13. }

代码示例来源:origin: apache/jackrabbit

  1. public void testPendingChanges() throws RepositoryException, NotExecutableException {
  2. testRootNode.addNode(nodeName2, testNodeType);
  3. String srcWorkspace = getAnotherWorkspace();
  4. try {
  5. testRootNode.update(srcWorkspace);
  6. fail("Update while changes are pending must fail with InvalidItemStateException");
  7. } catch (InvalidItemStateException e) {
  8. // ok
  9. }
  10. }

代码示例来源:origin: brix-cms/brix-cms

  1. public void update(String srcWorkspaceName) throws RepositoryException {
  2. getActionHandler().beforeNodeUpdate(this);
  3. getDelegate().update(srcWorkspaceName);
  4. getActionHandler().afterNodeUpdate(this);
  5. }

代码示例来源:origin: apache/jackrabbit

  1. s2.save();
  2. test.update(workspace2);

代码示例来源:origin: apache/jackrabbit

  1. public void testPendingChangesOnOtherNode() throws RepositoryException, NotExecutableException {
  2. try {
  3. Node root = testRootNode.getSession().getRootNode();
  4. if (root.isSame(testRootNode)) {
  5. throw new NotExecutableException();
  6. }
  7. if (root.canAddMixin(mixLockable)) {
  8. root.addMixin(mixLockable);
  9. } else {
  10. root.setProperty(propertyName1, "anyValue");
  11. }
  12. } catch (RepositoryException e) {
  13. throw new NotExecutableException();
  14. }
  15. String srcWorkspace = getAnotherWorkspace();
  16. try {
  17. testRootNode.update(srcWorkspace);
  18. fail("Update while changes are pending must fail with InvalidItemStateException");
  19. } catch (InvalidItemStateException e) {
  20. // ok
  21. }
  22. }

代码示例来源:origin: apache/jackrabbit

  1. public void testUpdateRemovesExtraProperty() throws RepositoryException, NotExecutableException {
  2. // create test node in default workspace
  3. testRootNode.setProperty(propertyName2, "test");
  4. testRootNode.save();
  5. String srcWorkspace = getAnotherWorkspace();
  6. // get the root node in the second workspace
  7. Session session2 = getHelper().getSuperuserSession(srcWorkspace);
  8. try {
  9. // make sure the source-session has the corresponding node.
  10. Node testRootW2 = (Node) session2.getItem(testRootNode.getCorrespondingNodePath(srcWorkspace));
  11. if (testRootW2.hasProperty(propertyName2)) {
  12. throw new NotExecutableException();
  13. }
  14. // call the update method on test node in default workspace
  15. testRootNode.update(srcWorkspace);
  16. // ok first check if node has no longer properties
  17. assertFalse("Node updated with Node.update() should have property removed", testRootNode.hasProperty(propertyName2));
  18. } catch (PathNotFoundException e) {
  19. throw new NotExecutableException();
  20. } catch (ItemNotFoundException e) {
  21. throw new NotExecutableException();
  22. } finally {
  23. session2.logout();
  24. }
  25. }

代码示例来源:origin: apache/jackrabbit

  1. public void testNoCorrespondingNode() throws RepositoryException, NotExecutableException {
  2. Node n = testRootNode.addNode(nodeName2, testNodeType);
  3. testRootNode.save();
  4. String srcWorkspace = null;
  5. String wspName = getHelper().getProperty("org.apache.jackrabbit.jcr2spi.workspace2.name");
  6. if (wspName == null) {
  7. throw new NotExecutableException("Cannot run update. Missing config param.");
  8. }
  9. try {
  10. n.getCorrespondingNodePath(wspName);
  11. } catch (ItemNotFoundException e) {
  12. srcWorkspace = wspName;
  13. } catch (RepositoryException e) {
  14. throw new NotExecutableException("Cannot run update. Workspace " + srcWorkspace + " does not exist or is not accessible.");
  15. }
  16. if (srcWorkspace == null) {
  17. throw new NotExecutableException("Cannot run update. No workspace found, that misses the corresponding node.");
  18. }
  19. try {
  20. // update without corresponding node must be a nop
  21. testRootNode.update(srcWorkspace);
  22. } catch (RepositoryException e) {
  23. fail("Update with workspace that doesn't contain the corresponding node must work.");
  24. }
  25. }

相关文章