本文整理了Java中javax.jcr.Node.canAddMixin()
方法的一些代码示例,展示了Node.canAddMixin()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.canAddMixin()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称: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
/**
* @inheritDoc
*/
public boolean canAddMixin(String mixinName) throws NoSuchNodeTypeException, RepositoryException {
return node.canAddMixin(mixinName);
}
代码示例来源:origin: info.magnolia/magnolia-core
@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());
}
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public boolean canAddMixin(String name)
throws RepositoryException, RemoteException {
try {
return node.canAddMixin(name);
} catch (RepositoryException ex) {
throw getRepositoryException(ex);
}
}
代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape
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);
}
}
代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape
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);
}
}
代码示例来源:origin: apache/jackrabbit-oak
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;
}
代码示例来源:origin: apache/jackrabbit-oak
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;
}
代码示例来源:origin: apache/jackrabbit
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));
}
代码示例来源:origin: apache/jackrabbit-oak
@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));
}
代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape
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);
}
}
代码示例来源:origin: apache/jackrabbit
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;
}
代码示例来源:origin: apache/jackrabbit
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;
}
代码示例来源:origin: apache/jackrabbit
@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());
}
代码示例来源:origin: ModeShape/modeshape
@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("");
}
代码示例来源:origin: ModeShape/modeshape
@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);
}
代码示例来源:origin: ModeShape/modeshape
@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");
}
代码示例来源:origin: ModeShape/modeshape
@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));
}
代码示例来源:origin: ModeShape/modeshape
@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);
}
代码示例来源:origin: apache/jackrabbit
@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();
}
代码示例来源:origin: ModeShape/modeshape
@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);
}
内容来源于网络,如有侵权,请联系作者删除!