/** * @inheritDoc */ public boolean canAddMixin(String mixinName) throws NoSuchNodeTypeException, RepositoryException { return node.canAddMixin(mixinName); }
@Override public void addMixin(String type) throws RepositoryException { // TODO: there seems to be bug somewhere as we are able to add mixins even when the method below returns false if (!this.node.canAddMixin(type)) { log.debug("Node - {} does not allow mixin type - {}", this.node.getPath(), type); } try { this.node.addMixin(type); } catch (Exception e) { log.error("Failed to add mixin type - {} to a node {}", type, this.node.getPath()); } }
/** {@inheritDoc} */ public boolean canAddMixin(String name) throws RepositoryException, RemoteException { try { return node.canAddMixin(name); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
private static void initializeNewBinaryProperties(final Node node) { try { if (node.canAddMixin(FEDORA_RESOURCE)) { node.addMixin(FEDORA_RESOURCE); } if (node.canAddMixin(FEDORA_BINARY)) { node.addMixin(FEDORA_BINARY); } } catch (final RepositoryException e) { LOGGER.warn("Could not decorate {} with binary properties: {}", node, e); } }
private static void initializeNewDescriptionProperties(final Node descNode) { try { if (descNode.canAddMixin(FEDORA_NON_RDF_SOURCE_DESCRIPTION)) { descNode.addMixin(FEDORA_NON_RDF_SOURCE_DESCRIPTION); } if (descNode.canAddMixin(FEDORA_BINARY)) { descNode.addMixin(FEDORA_BINARY); } } catch (final RepositoryException e) { LOGGER.warn("Could not decorate {} with description properties: {}", descNode, e); } }
private Node createVersionableNode(Node parent) throws Exception { Node n = (parent.hasNode(nodeName1)) ? parent.getNode(nodeName1) : parent.addNode(nodeName1); if (n.canAddMixin(mixVersionable)) { n.addMixin(mixVersionable); } else { throw new NotExecutableException(); } n.getSession().save(); return n; }
private Node createVersionableNode(Node parent) throws Exception { Node n = (parent.hasNode(nodeName1)) ? parent.getNode(nodeName1) : parent.addNode(nodeName1); if (n.canAddMixin(mixVersionable)) { n.addMixin(mixVersionable); } else { throw new NotExecutableException(); } n.getSession().save(); return n; }
public void testCanAddMixin() throws RepositoryException, NotExecutableException { checkReadOnly(childNode.getPath()); assertFalse(childNode.canAddMixin(mixinName)); modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true); assertTrue(childNode.canAddMixin(mixinName)); modifyPrivileges(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, false); assertFalse(childNode.canAddMixin(mixinName)); }
@Test public void testCanAddMixin() throws Exception { assertFalse(childNode.canAddMixin(mixinName)); modify(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, true); assertTrue(childNode.canAddMixin(mixinName)); modify(childNode.getPath(), Privilege.JCR_NODE_TYPE_MANAGEMENT, false); assertFalse(childNode.canAddMixin(mixinName)); }
private Container createContainer(final FedoraSession session, final String path) { try { final Node node = findOrCreateNode(session, path, NT_FOLDER); if (node.canAddMixin(FEDORA_RESOURCE)) { node.addMixin(FEDORA_RESOURCE); node.addMixin(FEDORA_CONTAINER); } return new ContainerImpl(node); } catch (final RepositoryException e) { throw new RepositoryRuntimeException(e); } }
protected Node createVersionableNode(Node parent) throws RepositoryException, NotExecutableException { Node n = parent.addNode(nodeName1); if (n.canAddMixin(mixVersionable)) { n.addMixin(mixVersionable); } else { throw new NotExecutableException(); } parent.save(); return n; }
private Node createLockableNode(Node parent) throws RepositoryException, NotExecutableException { Node n = parent.addNode(nodeName1); if (!n.isNodeType(mixLockable)) { if (n.canAddMixin(mixLockable)) { n.addMixin(mixLockable); } else { throw new NotExecutableException(); } parent.save(); } return n; }
@Override protected void setUp() throws Exception { super.setUp(); Node child = testRootNode.addNode(nodeName2); if (child.isNodeType(mixReferenceable) || !child.canAddMixin(mixReferenceable)) { throw new NotExecutableException(); } superuser.save(); mixinName = getTestSession().getNamespacePrefix(NS_MIX_URI) + ":referenceable"; childNode = getTestSession().getNode(child.getPath()); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowEmptyMixinTypeName() throws Exception { session.getRootNode().addNode("a", PRIMARY_TYPE_A); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); nodeA.canAddMixin(""); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowNullMixinTypeName() throws Exception { session.getRootNode().addNode("a", PRIMARY_TYPE_A); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); nodeA.canAddMixin(null); }
@Test( expected = NoSuchNodeTypeException.class ) public void shouldNotAllowInvalidMixinTypeName() throws Exception { session.getRootNode().addNode("a", PRIMARY_TYPE_A); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); nodeA.canAddMixin("foo"); }
@Test public void shouldAllowAddingMixinIfNoConflict() throws Exception { session.getRootNode().addNode("a", PRIMARY_TYPE_A).addMixin("mix:referenceable"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); assertThat(nodeA.canAddMixin(MIXIN_TYPE_B), is(true)); }
@Test( expected = ConstraintViolationException.class ) public void shouldNotAllowAdditionIfResidualPropertyConflicts() throws Exception { session.getRootNode().addNode("a", "nt:unstructured"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); Property b = nodeA.setProperty(PROPERTY_B, "Not a boolean"); assertThat(b.getType(), is(not(PropertyType.UNDEFINED))); // see JavaDoc on javax.jcr.PropertyType.UNDEFINED assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_PROP), is(false)); nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_PROP); }
@Override protected void setUp() throws Exception { super.setUp(); if (!moveNode.canAddMixin(mixReferenceable)) { throw new NotExecutableException("Cannot add mix:referencable to node to be moved."); } // prepare move-node moveNode.addMixin(mixReferenceable); moveNode.save(); }
@Test( expected = ConstraintViolationException.class ) public void shouldNotAllowAdditionIfResidualChildNodeConflicts() throws Exception { session.getRootNode().addNode("a", "nt:unstructured").addNode(CHILD_NODE_B, "nt:base"); session.save(); Node rootNode = session.getRootNode(); Node nodeA = rootNode.getNode("a"); assertThat(nodeA.canAddMixin(MIXIN_TYPE_WITH_AUTO_CHILD), is(false)); nodeA.addMixin(MIXIN_TYPE_WITH_AUTO_CHILD); }