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

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

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

Node.removeMixin介绍

[英]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: org.onehippo.cms7/hippo-repository-connector

  1. /**
  2. * @inheritDoc
  3. */
  4. public void removeMixin(String mixinName) throws NoSuchNodeTypeException, VersionException,
  5. ConstraintViolationException, LockException, RepositoryException {
  6. node.removeMixin(mixinName);
  7. }

代码示例来源:origin: org.chromattic/chromattic.core

  1. public boolean removeMixin(Node node, String mixinTypeName) throws RepositoryException {
  2. try {
  3. node.removeMixin(mixinTypeName);
  4. return true;
  5. } catch (NoSuchNodeTypeException ignore) {
  6. // Mixin was not here
  7. return false;
  8. }
  9. }

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

  1. @Override
  2. public void removeMixin(String type) throws RepositoryException {
  3. this.node.removeMixin(type);
  4. }

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

  1. /**
  2. * Removes the cq:ReplicationStatus mixin from the node if it has it.
  3. *
  4. * @param node the node
  5. * @throws RepositoryException
  6. */
  7. private void removeReplicationStatusMixin(final Node node) throws RepositoryException {
  8. if (this.hasMixin(node, ReplicationStatus.NODE_TYPE)) {
  9. node.removeMixin(ReplicationStatus.NODE_TYPE);
  10. }
  11. }

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

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

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

  1. /**
  2. * Removes the cq:ReplicationStatus mixin from the node if it has it.
  3. *
  4. * @param node the node
  5. * @throws RepositoryException
  6. */
  7. private void removeReplicationStatusMixin(final Node node) throws RepositoryException {
  8. if (this.hasMixin(node, ReplicationStatus.NODE_TYPE)) {
  9. node.removeMixin(ReplicationStatus.NODE_TYPE);
  10. }
  11. }

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

  1. private void removeMixin(final Node node, final String mixin) throws RepositoryException {
  2. for (NodeType mixinType : node.getMixinNodeTypes()) {
  3. if (mixinType.getName().equals(mixin)) {
  4. node.removeMixin(mixin);
  5. return;
  6. }
  7. }
  8. }

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

  1. void checkout() throws RepositoryException {
  2. // copy nodetype
  3. if (draft == null) {
  4. if (current == null) {
  5. throw new ItemNotFoundException("Remodel node " + HippoNodeType.HIPPOSYSEDIT_NODETYPE
  6. + ", current version was not found for type " + subject.getPath());
  7. }
  8. draft = ((HippoSession) current.getSession()).copy(current, current.getParent().getPath() + "/"
  9. + HippoNodeType.HIPPOSYSEDIT_NODETYPE);
  10. draft.removeMixin(HippoNodeType.NT_REMODEL);
  11. }
  12. }

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

  1. private void removeHasVersionMixin(String destAbsPath) throws RepositoryException {
  2. Node node = getSession().getNode(destAbsPath);
  3. NodeUtil.visit(node, nodeToVisit -> {
  4. if (NodeUtil.hasMixin(nodeToVisit, NodeTypes.HasVersion.NAME)) {
  5. nodeToVisit.removeMixin(NodeTypes.HasVersion.NAME);
  6. nodeToVisit.getSession().save();
  7. }
  8. });
  9. }
  10. }

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

  1. @Override
  2. public void move(String srcAbsPath, String destAbsPath) throws PathNotFoundException, VersionException, ConstraintViolationException, LockException, ItemExistsException, RepositoryException {
  3. Node node = getNode(srcAbsPath);
  4. // we want to remove mixin when copying node via NodeUtil
  5. if (node.isNew() && TEMPORARY_NODE.matcher(srcAbsPath).matches() && NodeUtil.hasMixin(node, NodeTypes.HasVersion.NAME)) {
  6. node.removeMixin(NodeTypes.HasVersion.NAME);
  7. }
  8. getWrappedSession().move(srcAbsPath, destAbsPath);
  9. }
  10. }

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

  1. public void testRemoveMixVersionable() throws Exception {
  2. Node node = testRootNode.addNode(nodeName1);
  3. node.addMixin(mixVersionable);
  4. superuser.save();
  5. node.removeMixin(mixVersionable);
  6. superuser.save();
  7. }

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

  1. public void testRemoveMixVersionable1() throws Exception {
  2. Node node = testRootNode.addNode(nodeName1);
  3. node.addMixin(mixReferenceable);
  4. node.addMixin(mixVersionable);
  5. superuser.save();
  6. node.removeMixin(mixVersionable);
  7. superuser.save();
  8. }

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

  1. @Test
  2. public void testRemoveMixin() throws Exception {
  3. ((Node) superuser.getItem(childNode.getPath())).addMixin(mixinName);
  4. superuser.save();
  5. testSession.refresh(false);
  6. modify(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true);
  7. childNode.removeMixin(mixinName);
  8. testSession.save();
  9. }

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

  1. public void testRemoveAddMixVersionable() throws Exception {
  2. Node node = testRootNode.addNode(nodeName1);
  3. node.addMixin(mixVersionable);
  4. superuser.save();
  5. String vhId = node.getVersionHistory().getUUID();
  6. node.removeMixin(mixVersionable);
  7. node.addMixin(mixVersionable);
  8. superuser.save();
  9. assertFalse(vhId.equals(node.getVersionHistory().getUUID()));
  10. }

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

  1. @Test( expected = ConstraintViolationException.class )
  2. public void shouldNotAllowRemovalIfExistingChildNodeWouldHaveNoDefinition() throws Exception {
  3. Node a = session.getRootNode().addNode("a", BASE_PRIMARY_TYPE);
  4. a.addMixin(MIXIN_TYPE_B);
  5. a.addNode(CHILD_NODE_B);
  6. session.save();
  7. Node rootNode = session.getRootNode();
  8. Node nodeA = rootNode.getNode("a");
  9. nodeA.removeMixin(MIXIN_TYPE_B);
  10. }

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

  1. @Test
  2. public void shouldAllowRemovalIfExistingChildNodeWouldHaveDefinition() throws Exception {
  3. Node a = session.getRootNode().addNode("a", "nt:unstructured");
  4. a.addMixin(MIXIN_TYPE_B);
  5. a.addNode(CHILD_NODE_B);
  6. session.save();
  7. Node rootNode = session.getRootNode();
  8. Node nodeA = rootNode.getNode("a");
  9. nodeA.removeMixin(MIXIN_TYPE_B);
  10. }

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

  1. public void testRemoveAddMixVersionable1() throws Exception {
  2. Node node = testRootNode.addNode(nodeName1);
  3. node.addMixin(mixReferenceable);
  4. node.addMixin(mixVersionable);
  5. superuser.save();
  6. String vhId = node.getVersionHistory().getUUID();
  7. node.removeMixin(mixVersionable);
  8. node.addMixin(mixVersionable);
  9. superuser.save();
  10. assertEquals(vhId, node.getVersionHistory().getUUID());
  11. }
  12. }

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

  1. @Test( expected = ConstraintViolationException.class )
  2. public void shouldNotAllowRemovalIfExistingPropertyWouldHaveNoDefinition() throws Exception {
  3. Node a = session.getRootNode().addNode("a", BASE_PRIMARY_TYPE);
  4. a.addMixin(MIXIN_TYPE_B);
  5. a.setProperty(PROPERTY_B, "true");
  6. session.save();
  7. Node rootNode = session.getRootNode();
  8. Node nodeA = rootNode.getNode("a");
  9. nodeA.removeMixin(MIXIN_TYPE_B);
  10. session.save();
  11. }

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

  1. @Test
  2. public void testRemoveMixin() throws Exception {
  3. Node n = superuser.getNode(path);
  4. deny(path, readPrivileges);
  5. assertTrue(n.hasNode("rep:policy"));
  6. assertTrue(n.isNodeType("rep:AccessControllable"));
  7. n.removeMixin("rep:AccessControllable");
  8. superuser.save();
  9. assertFalse(n.hasNode("rep:policy"));
  10. assertFalse(n.isNodeType("rep:AccessControllable"));
  11. }
  12. }

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

  1. public void testRemoveMixin() throws Exception {
  2. Node n = superuser.getNode(path);
  3. Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
  4. withdrawPrivileges(path, privileges, getRestrictions(superuser, path));
  5. assertTrue(n.hasNode("rep:policy"));
  6. assertTrue(n.isNodeType("rep:AccessControllable"));
  7. n.removeMixin("rep:AccessControllable");
  8. superuser.save();
  9. assertFalse(n.hasNode("rep:policy"));
  10. assertFalse(n.isNodeType("rep:AccessControllable"));
  11. }
  12. }

相关文章