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

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

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

Node.canAddMixin介绍

[英]Returns true if calling #addMixin on this node with the mixn node type mixinName will not fail. Returns false otherwise.
[中]如果使用mixn节点类型在该节点上调用#addMixinmixinName不会失败,则返回true。否则返回false

代码示例

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

  1. /**
  2. * @inheritDoc
  3. */
  4. public boolean canAddMixin(String mixinName) throws NoSuchNodeTypeException, RepositoryException {
  5. return node.canAddMixin(mixinName);
  6. }

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

  1. @Override
  2. public void addMixin(String type) throws RepositoryException {
  3. // TODO: there seems to be bug somewhere as we are able to add mixins even when the method below returns false
  4. if (!this.node.canAddMixin(type)) {
  5. log.debug("Node - {} does not allow mixin type - {}", this.node.getPath(), type);
  6. }
  7. try {
  8. this.node.addMixin(type);
  9. } catch (Exception e) {
  10. log.error("Failed to add mixin type - {} to a node {}", type, this.node.getPath());
  11. }
  12. }

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

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

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

  1. private static void initializeNewBinaryProperties(final Node node) {
  2. try {
  3. if (node.canAddMixin(FEDORA_RESOURCE)) {
  4. node.addMixin(FEDORA_RESOURCE);
  5. }
  6. if (node.canAddMixin(FEDORA_BINARY)) {
  7. node.addMixin(FEDORA_BINARY);
  8. }
  9. } catch (final RepositoryException e) {
  10. LOGGER.warn("Could not decorate {} with binary properties: {}", node, e);
  11. }
  12. }

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

  1. private static void initializeNewDescriptionProperties(final Node descNode) {
  2. try {
  3. if (descNode.canAddMixin(FEDORA_NON_RDF_SOURCE_DESCRIPTION)) {
  4. descNode.addMixin(FEDORA_NON_RDF_SOURCE_DESCRIPTION);
  5. }
  6. if (descNode.canAddMixin(FEDORA_BINARY)) {
  7. descNode.addMixin(FEDORA_BINARY);
  8. }
  9. } catch (final RepositoryException e) {
  10. LOGGER.warn("Could not decorate {} with description properties: {}", descNode, e);
  11. }
  12. }

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

  1. private Node createVersionableNode(Node parent) throws Exception {
  2. Node n = (parent.hasNode(nodeName1)) ? parent.getNode(nodeName1) : parent.addNode(nodeName1);
  3. if (n.canAddMixin(mixVersionable)) {
  4. n.addMixin(mixVersionable);
  5. } else {
  6. throw new NotExecutableException();
  7. }
  8. n.getSession().save();
  9. return n;
  10. }

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

  1. private Node createVersionableNode(Node parent) throws Exception {
  2. Node n = (parent.hasNode(nodeName1)) ? parent.getNode(nodeName1) : parent.addNode(nodeName1);
  3. if (n.canAddMixin(mixVersionable)) {
  4. n.addMixin(mixVersionable);
  5. } else {
  6. throw new NotExecutableException();
  7. }
  8. n.getSession().save();
  9. return n;
  10. }

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

  1. public void testCanAddMixin() throws RepositoryException, NotExecutableException {
  2. checkReadOnly(childNode.getPath());
  3. assertFalse(childNode.canAddMixin(mixinName));
  4. modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true);
  5. assertTrue(childNode.canAddMixin(mixinName));
  6. modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, false);
  7. assertFalse(childNode.canAddMixin(mixinName));
  8. }

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

  1. @Test
  2. public void testCanAddMixin() throws Exception {
  3. assertFalse(childNode.canAddMixin(mixinName));
  4. modify(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true);
  5. assertTrue(childNode.canAddMixin(mixinName));
  6. modify(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, false);
  7. assertFalse(childNode.canAddMixin(mixinName));
  8. }

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

  1. private Container createContainer(final FedoraSession session, final String path) {
  2. try {
  3. final Node node = findOrCreateNode(session, path, NT_FOLDER);
  4. if (node.canAddMixin(FEDORA_RESOURCE)) {
  5. node.addMixin(FEDORA_RESOURCE);
  6. node.addMixin(FEDORA_CONTAINER);
  7. }
  8. return new ContainerImpl(node);
  9. } catch (final RepositoryException e) {
  10. throw new RepositoryRuntimeException(e);
  11. }
  12. }

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

  1. protected Node createVersionableNode(Node parent) throws RepositoryException, NotExecutableException {
  2. Node n = parent.addNode(nodeName1);
  3. if (n.canAddMixin(mixVersionable)) {
  4. n.addMixin(mixVersionable);
  5. } else {
  6. throw new NotExecutableException();
  7. }
  8. parent.save();
  9. return n;
  10. }

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

  1. private Node createLockableNode(Node parent) throws RepositoryException, NotExecutableException {
  2. Node n = parent.addNode(nodeName1);
  3. if (!n.isNodeType(mixLockable)) {
  4. if (n.canAddMixin(mixLockable)) {
  5. n.addMixin(mixLockable);
  6. } else {
  7. throw new NotExecutableException();
  8. }
  9. parent.save();
  10. }
  11. return n;
  12. }

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

  1. @Override
  2. protected void setUp() throws Exception {
  3. super.setUp();
  4. Node child = testRootNode.addNode(nodeName2);
  5. if (child.isNodeType(mixReferenceable) || !child.canAddMixin(mixReferenceable)) {
  6. throw new NotExecutableException();
  7. }
  8. superuser.save();
  9. mixinName = getTestSession().getNamespacePrefix(NS_MIX_URI) + ":referenceable";
  10. childNode = getTestSession().getNode(child.getPath());
  11. }

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

  1. @Test( expected = IllegalArgumentException.class )
  2. public void shouldNotAllowEmptyMixinTypeName() throws Exception {
  3. session.getRootNode().addNode("a", PRIMARY_TYPE_A);
  4. session.save();
  5. Node rootNode = session.getRootNode();
  6. Node nodeA = rootNode.getNode("a");
  7. nodeA.canAddMixin("");
  8. }

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

  1. @Test( expected = IllegalArgumentException.class )
  2. public void shouldNotAllowNullMixinTypeName() throws Exception {
  3. session.getRootNode().addNode("a", PRIMARY_TYPE_A);
  4. session.save();
  5. Node rootNode = session.getRootNode();
  6. Node nodeA = rootNode.getNode("a");
  7. nodeA.canAddMixin(null);
  8. }

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

  1. @Test( expected = NoSuchNodeTypeException.class )
  2. public void shouldNotAllowInvalidMixinTypeName() throws Exception {
  3. session.getRootNode().addNode("a", PRIMARY_TYPE_A);
  4. session.save();
  5. Node rootNode = session.getRootNode();
  6. Node nodeA = rootNode.getNode("a");
  7. nodeA.canAddMixin("foo");
  8. }

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

  1. @Test
  2. public void shouldAllowAddingMixinIfNoConflict() throws Exception {
  3. session.getRootNode().addNode("a", PRIMARY_TYPE_A).addMixin("mix:referenceable");
  4. session.save();
  5. Node rootNode = session.getRootNode();
  6. Node nodeA = rootNode.getNode("a");
  7. assertThat(nodeA.canAddMixin(MIXIN_TYPE_B), is(true));
  8. }

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

  1. @Test( expected = ConstraintViolationException.class )
  2. public void shouldNotAllowAdditionIfResidualPropertyConflicts() throws Exception {
  3. session.getRootNode().addNode("a", "nt:unstructured");
  4. session.save();
  5. Node rootNode = session.getRootNode();
  6. Node nodeA = rootNode.getNode("a");
  7. Property b = nodeA.setProperty(PROPERTY_B, "Not a boolean");
  8. assertThat(b.getType(), is(not(PropertyType.UNDEFINED))); // see JavaDoc on javax.jcr.PropertyType.UNDEFINED
  9. assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_PROP), is(false));
  10. nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_PROP);
  11. }

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

  1. @Override
  2. protected void setUp() throws Exception {
  3. super.setUp();
  4. if (!moveNode.canAddMixin(mixReferenceable)) {
  5. throw new NotExecutableException("Cannot add mix:referencable to node to be moved.");
  6. }
  7. // prepare move-node
  8. moveNode.addMixin(mixReferenceable);
  9. moveNode.save();
  10. }

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

  1. @Test( expected = ConstraintViolationException.class )
  2. public void shouldNotAllowAdditionIfResidualChildNodeConflicts() throws Exception {
  3. session.getRootNode().addNode("a", "nt:unstructured").addNode(CHILD_NODE_B, "nt:base");
  4. session.save();
  5. Node rootNode = session.getRootNode();
  6. Node nodeA = rootNode.getNode("a");
  7. assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_CHILD), is(false));
  8. nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_CHILD);
  9. }

相关文章