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

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

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

Node.remove介绍

[英]Removes the specified mixin node type from this node and removes mixinName from this node's jcr:mixinTypes property. Both the semantic change in effective node type and the persistence of the change to the jcr:mixinTypes property occur on persist.

If this node does not have the specified mixin, a NoSuchNodeTypeException is thrown either immediately, on dispatch or on persist. Implementations may differ on when this validation is done.

A ConstraintViolationException will be thrown either immediately, on dispatch or on persist, if the removal of a mixin is not allowed. Implementations are free to enforce any policy with regard to mixin removal and may differ on when this validation is done.

A VersionException is thrown either immediately, on dispatch or on persist, if this node is read-only due to a checked-in node. Implementations may differ on when this validation is done.

A LockException is thrown either immediately or on save if a lock prevents the removal of the mixin. Implementations may differ on when this validation is done.
[中]从此节点中删除指定的mixin节点类型,并从此节点的jcr:mixinTypes属性中删除mixinName。有效节点类型的语义更改和jcr:mixinTypes属性更改的持久性都发生在persist上。
如果此节点没有指定的mixin,则在分派或持久化时立即抛出NoSuchNodeTypeException。在完成此验证时,实现可能会有所不同。
如果不允许删除mixin,则ConstraintViolationException将在分派或持久化时立即抛出。实现可以自由执行与mixin删除相关的任何策略,并且在完成此验证时可能会有所不同。
如果此节点由于签入节点而为只读,则在分派或持久化时立即抛出VersionException。在完成此验证时,实现可能会有所不同。
如果锁阻止移除mixin,则会立即或在save上抛出LockException。在完成此验证时,实现可能会有所不同。

代码示例

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

public void call() throws RepositoryException {
    n.remove();
    testRootNode.getSession().save();
  }
}, Event.NODE_REMOVED);

代码示例来源:origin: org.onehippo.cms7/hippo-repository-deprecated-updater-module

@Override
  protected void leaving(Node node, int level) throws RepositoryException {
    log.info("Removing the cms-pickers node from " + node.getPath());
    node.getNode("cms-pickers").remove();
  }
});

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

@Override
  protected void afterSuite() throws Exception {
    Session session = loginWriter();
    session.getNode(testRoot.getPath()).remove();
    testRoot.getSession().logout();
    session.save();
    session.logout();
  }
}

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

protected void tearDown() throws Exception {
  try {
    Node folder = testRootNode.getNode("bigcoll");
    folder.remove();
    folder.getSession().save();
  }
  catch (RepositoryException ex) {
    // nothing to do
  }
  super.tearDown();
}

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

/**
 * Test reordering same-name-siblings using move
 */
public void testReorderSameNameSiblingsUsingMove() throws RepositoryException {
  Session session = testRootNode.getSession();
  for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
    it.nextNode().remove();
    session.save();
  }
  Node node1 = testRootNode.addNode(nodeName1);
  Node node2 = testRootNode.addNode(nodeName1);
  String path = node1.getPath();
  // re-order the nodes using move
  session.move(path, path);
  assertEquals(path + "[2]", node1.getPath());
  assertEquals(path, node2.getPath());
}

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

public void testRemoveLockedChild() throws RepositoryException {
    Session otherSession = getHelper().getReadWriteSession();
    try {
      Node child = (Node) otherSession.getItem(childNode.getPath());
      child.remove();
      otherSession.save();
      fail("A node below a deeply locked node cannot be removed by another Session.");
    } catch (LockException e) {
      // success
    } finally {
      otherSession.logout();
    }
  }
}

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

protected void tearDown() throws Exception {
  int count = 0;
  for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
    it.nextNode().remove();
    count++;
    if (count % 10000 == 0) {
      testRootNode.getSession().save();
    }
  }
  testRootNode.getSession().save();
  super.tearDown();
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

@Test
public void testGetJcrItemWithPropertyNotExisting() throws Exception {
  // GIVEN
  String nodeName = "nodeName";
  Node testNode = session.getRootNode().addNode(nodeName);
  String propertyName = "propertyName";
  String propertyValue = "propertyValue";
  Property testProperty = testNode.setProperty(propertyName, propertyValue);
  testNode.remove();
  // WHEN
  DummyJcrAdapter adapter = new DummyJcrAdapter(testProperty);
  // THEN
  assertNull(adapter.getJcrItem());
}

代码示例来源:origin: org.onehippo.cms7.hst.client-modules/hst-page-composer

protected final void deleteOrMarkDeletedIfLiveExists(final Node toDelete) throws RepositoryException {
  if (liveExists(toDelete.getSession(), toDelete.getPath())) {
    markDeleted(toDelete);
  } else {
    toDelete.remove();
  }
}

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

@Override
  void run(int scale) throws RepositoryException {
    session.getNode("/large-remove/s" + scale).remove();
    session.save();
  }
};

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

@Test
public void testAclDefinedButEmpty() throws RepositoryException, TaskExecutionException {
  // GIVEN
  GrantReadPermissionToRolesTask task = new GrantReadPermissionToRolesTask("name", "description");
  aclUserrolesNode.getNode("0").remove();
  userRoleSession.save();
  // WHEN
  task.execute(installContext);
  // THEN
  checkACL("/superuser", 8l, "0");
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-editor-repository

void revert() throws RepositoryException {
    if (draft != null) {
      if (current == null) {
        throw new ItemNotFoundException("Remodel node " + HippoNodeType.HIPPOSYSEDIT_NODETYPE
            + ", current version was not found for type " + subject.getPath());
      }
      draft.remove();
      draft = null;
    }
  }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-tools

private void removeResource(final Resource resource) {
  if (resource != null) {
    final Node node = resource.adaptTo(Node.class);
    if (node != null) {
      try {
        log.trace("Removing AEM Fiddle compiled scripts at: {}", node.getPath());
        node.remove();
        node.getSession().save();
      } catch (RepositoryException e) {
        log.error("Could not remove compiled AEM Fiddle scripts: {}", e);
      }
    }
  }
}

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

public void removeNode(String key) throws RepositoryException {
  Node parent = getParent(key);
  Node n = parent.getNode(key);
  n.remove();
  treeManager.join(this, parent, n);
  if (autoSave) {
    parent.getSession().save();
  }
}

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

private void doTestMoveWithGetPath(boolean index) throws RepositoryException {
  Session session = testRootNode.getSession();
  for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
    it.nextNode().remove();
    session.save();
  }
  String testPath = testRootNode.getPath();
  Node a = testRootNode.addNode("a");
  Node b = a.addNode("b");
  session.save();
  session.move(testPath + "/a/b", testPath + "/a");
  if (index) {
    b.getPath();
  }
  session.move(testPath + "/a", testPath + "/a");
  assertEquals(testPath + "/a[2]", a.getPath());
  assertEquals(testPath + "/a", b.getPath());
}

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

public void call() throws RepositoryException {
    n.remove();
    testRootNode.getSession().save();
  }
}, Event.NODE_REMOVED);

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

public void testRemoveLockedNode() throws RepositoryException {
    Node n = (Node) otherSession.getItem(lockedNode.getPath());

    // since removing a node is a modification of the non-locked parent
    // the removal must succeed.
    n.remove();
    otherSession.save();
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-deprecated-updater-module

@Override
  protected void leaving(Node node, int level) throws RepositoryException {
    if (node.hasNode("cms-pickers")) {
      log.info("Removing the cms-pickers node from " + node.getPath());
      node.getNode("cms-pickers").remove();
    }
  }
});

代码示例来源:origin: ModeShape/modeshape

@FixFor( "MODE-1685" )
@Test
public void shouldNotEnforceReferentialIntegrityOfWeakReferenceWhenRemovingNodes() throws Exception {
  JcrValueFactory valueFactory = session.getValueFactory();
  Node targetNode = session.getRootNode().addNode("target");
  targetNode.addMixin(JcrMixLexicon.REFERENCEABLE.toString());
  Node parentNode = session.getRootNode().addNode("parent");
  Node childNode = parentNode.addNode("child");
  childNode.setProperty("ref1", valueFactory.createValue(targetNode, true));
  session.save();
  // Delete the target - there should be no strong references, but the weak is okay and won't prevent removal ...
  targetNode.remove();
  session.save();
}

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

public void testRemoveDestParent() throws RepositoryException {
  String srcPath = moveNode.getPath();
  testRootNode.getSession().move(srcPath, destinationPath);
  destParentNode.remove();
  assertFalse(destParentNode.isNew());
  assertFalse(destParentNode.isModified());
  assertFalse(moveNode.isModified());
  assertTrue(srcParentNode.isModified());
  assertFalse(testRootNode.getSession().itemExists(srcPath));
}

相关文章

微信公众号

最新文章

更多