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

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

本文整理了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

  1. public void call() throws RepositoryException {
  2. n.remove();
  3. testRootNode.getSession().save();
  4. }
  5. }, Event.NODE_REMOVED);

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

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

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

  1. @Override
  2. protected void afterSuite() throws Exception {
  3. Session session = loginWriter();
  4. session.getNode(testRoot.getPath()).remove();
  5. testRoot.getSession().logout();
  6. session.save();
  7. session.logout();
  8. }
  9. }

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

  1. protected void tearDown() throws Exception {
  2. try {
  3. Node folder = testRootNode.getNode("bigcoll");
  4. folder.remove();
  5. folder.getSession().save();
  6. }
  7. catch (RepositoryException ex) {
  8. // nothing to do
  9. }
  10. super.tearDown();
  11. }

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

  1. /**
  2. * Test reordering same-name-siblings using move
  3. */
  4. public void testReorderSameNameSiblingsUsingMove() throws RepositoryException {
  5. Session session = testRootNode.getSession();
  6. for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
  7. it.nextNode().remove();
  8. session.save();
  9. }
  10. Node node1 = testRootNode.addNode(nodeName1);
  11. Node node2 = testRootNode.addNode(nodeName1);
  12. String path = node1.getPath();
  13. // re-order the nodes using move
  14. session.move(path, path);
  15. assertEquals(path + "[2]", node1.getPath());
  16. assertEquals(path, node2.getPath());
  17. }

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

  1. public void testRemoveLockedChild() throws RepositoryException {
  2. Session otherSession = getHelper().getReadWriteSession();
  3. try {
  4. Node child = (Node) otherSession.getItem(childNode.getPath());
  5. child.remove();
  6. otherSession.save();
  7. fail("A node below a deeply locked node cannot be removed by another Session.");
  8. } catch (LockException e) {
  9. // success
  10. } finally {
  11. otherSession.logout();
  12. }
  13. }
  14. }

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

  1. protected void tearDown() throws Exception {
  2. int count = 0;
  3. for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
  4. it.nextNode().remove();
  5. count++;
  6. if (count % 10000 == 0) {
  7. testRootNode.getSession().save();
  8. }
  9. }
  10. testRootNode.getSession().save();
  11. super.tearDown();
  12. }

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

  1. @Test
  2. public void testGetJcrItemWithPropertyNotExisting() throws Exception {
  3. // GIVEN
  4. String nodeName = "nodeName";
  5. Node testNode = session.getRootNode().addNode(nodeName);
  6. String propertyName = "propertyName";
  7. String propertyValue = "propertyValue";
  8. Property testProperty = testNode.setProperty(propertyName, propertyValue);
  9. testNode.remove();
  10. // WHEN
  11. DummyJcrAdapter adapter = new DummyJcrAdapter(testProperty);
  12. // THEN
  13. assertNull(adapter.getJcrItem());
  14. }

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

  1. protected final void deleteOrMarkDeletedIfLiveExists(final Node toDelete) throws RepositoryException {
  2. if (liveExists(toDelete.getSession(), toDelete.getPath())) {
  3. markDeleted(toDelete);
  4. } else {
  5. toDelete.remove();
  6. }
  7. }

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

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

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

  1. @Test
  2. public void testAclDefinedButEmpty() throws RepositoryException, TaskExecutionException {
  3. // GIVEN
  4. GrantReadPermissionToRolesTask task = new GrantReadPermissionToRolesTask("name", "description");
  5. aclUserrolesNode.getNode("0").remove();
  6. userRoleSession.save();
  7. // WHEN
  8. task.execute(installContext);
  9. // THEN
  10. checkACL("/superuser", 8l, "0");
  11. }

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

  1. void revert() throws RepositoryException {
  2. if (draft != null) {
  3. if (current == null) {
  4. throw new ItemNotFoundException("Remodel node " + HippoNodeType.HIPPOSYSEDIT_NODETYPE
  5. + ", current version was not found for type " + subject.getPath());
  6. }
  7. draft.remove();
  8. draft = null;
  9. }
  10. }
  11. }

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

  1. private void removeResource(final Resource resource) {
  2. if (resource != null) {
  3. final Node node = resource.adaptTo(Node.class);
  4. if (node != null) {
  5. try {
  6. log.trace("Removing AEM Fiddle compiled scripts at: {}", node.getPath());
  7. node.remove();
  8. node.getSession().save();
  9. } catch (RepositoryException e) {
  10. log.error("Could not remove compiled AEM Fiddle scripts: {}", e);
  11. }
  12. }
  13. }
  14. }

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

  1. public void removeNode(String key) throws RepositoryException {
  2. Node parent = getParent(key);
  3. Node n = parent.getNode(key);
  4. n.remove();
  5. treeManager.join(this, parent, n);
  6. if (autoSave) {
  7. parent.getSession().save();
  8. }
  9. }

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

  1. private void doTestMoveWithGetPath(boolean index) throws RepositoryException {
  2. Session session = testRootNode.getSession();
  3. for (NodeIterator it = testRootNode.getNodes(); it.hasNext();) {
  4. it.nextNode().remove();
  5. session.save();
  6. }
  7. String testPath = testRootNode.getPath();
  8. Node a = testRootNode.addNode("a");
  9. Node b = a.addNode("b");
  10. session.save();
  11. session.move(testPath + "/a/b", testPath + "/a");
  12. if (index) {
  13. b.getPath();
  14. }
  15. session.move(testPath + "/a", testPath + "/a");
  16. assertEquals(testPath + "/a[2]", a.getPath());
  17. assertEquals(testPath + "/a", b.getPath());
  18. }

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

  1. public void call() throws RepositoryException {
  2. n.remove();
  3. testRootNode.getSession().save();
  4. }
  5. }, Event.NODE_REMOVED);

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

  1. public void testRemoveLockedNode() throws RepositoryException {
  2. Node n = (Node) otherSession.getItem(lockedNode.getPath());
  3. // since removing a node is a modification of the non-locked parent
  4. // the removal must succeed.
  5. n.remove();
  6. otherSession.save();
  7. }
  8. }

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

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

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

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

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

  1. public void testRemoveDestParent() throws RepositoryException {
  2. String srcPath = moveNode.getPath();
  3. testRootNode.getSession().move(srcPath, destinationPath);
  4. destParentNode.remove();
  5. assertFalse(destParentNode.isNew());
  6. assertFalse(destParentNode.isModified());
  7. assertFalse(moveNode.isModified());
  8. assertTrue(srcParentNode.isModified());
  9. assertFalse(testRootNode.getSession().itemExists(srcPath));
  10. }

相关文章