use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class NodeTypeImpl method getDeclaredNodeDefs.
private List<NodeDefinition> getDeclaredNodeDefs(Tree defs) {
if (defs.exists()) {
List<NodeDefinition> list = newArrayList();
String typeName = getOakName();
for (Tree def : defs.getChildren()) {
String declaringTypeName = TreeUtil.getName(def, REP_DECLARING_NODE_TYPE);
if (typeName.equals(declaringTypeName)) {
list.add(new NodeDefinitionImpl(def, this, mapper));
}
}
return list;
} else {
return emptyList();
}
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class RepositoryTest method testGetDefinitionWithSNS.
@Test
public void testGetDefinitionWithSNS() throws RepositoryException, IOException {
Session session = getAdminSession();
Node node = session.getNode("/jcr:system/jcr:nodeTypes/nt:file");
// TODO: use getNode("jcr:childNodeDefinition[1]") once that works
for (Node child : getChildNodes(node, "jcr:childNodeDefinition")) {
// OAK-829
NodeDefinition definition = child.getDefinition();
// OAK-826
definition.getDefaultPrimaryType();
// OAK-826
definition.getRequiredPrimaryTypes();
}
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class NodeDefinitionTest method testGetRequiredPrimaryTypes.
@Test
public void testGetRequiredPrimaryTypes() throws RepositoryException {
for (String path : paths) {
Node n = superuser.getNode(path);
NodeDefinition def = n.getDefinition();
def.getRequiredPrimaryTypes();
}
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class NodeTypeDefinitionTest method testIndexedChildDefinition.
public void testIndexedChildDefinition() throws Exception {
String ntPath = NodeTypeConstants.NODE_TYPES_PATH + '/' + NodeTypeConstants.NT_VERSIONHISTORY;
assertTrue(superuser.nodeExists(ntPath + "/jcr:childNodeDefinition"));
assertTrue(superuser.nodeExists(ntPath + "/jcr:childNodeDefinition[1]"));
Node cdNode = superuser.getNode(ntPath + "/jcr:childNodeDefinition[1]");
assertEquals(ntPath + "/jcr:childNodeDefinition", cdNode.getPath());
List<String> defNames = new ArrayList();
NodeType nt = superuser.getWorkspace().getNodeTypeManager().getNodeType(NodeTypeConstants.NT_VERSIONHISTORY);
for (NodeDefinition nd : nt.getDeclaredChildNodeDefinitions()) {
defNames.add(nd.getName());
}
Node ntNode = superuser.getNode(ntPath);
NodeIterator it = ntNode.getNodes("jcr:childNodeDefinition*");
while (it.hasNext()) {
Node def = it.nextNode();
int index = getIndex(def);
String name = (def.hasProperty(NodeTypeConstants.JCR_NAME)) ? def.getProperty(NodeTypeConstants.JCR_NAME).getString() : NodeTypeConstants.RESIDUAL_NAME;
assertEquals(name, defNames.get(index - 1));
}
}
use of javax.jcr.nodetype.NodeDefinition in project jackrabbit-oak by apache.
the class NodeDefinitionTest method getAggregatedNodeDefinitions.
private static NodeDefinition[] getAggregatedNodeDefinitions(Node node) throws RepositoryException {
Set<NodeDefinition> cDefs = newHashSet();
NodeDefinition[] nd = node.getPrimaryNodeType().getChildNodeDefinitions();
cDefs.addAll(Arrays.asList(nd));
NodeType[] mixins = node.getMixinNodeTypes();
for (NodeType mixin : mixins) {
nd = mixin.getChildNodeDefinitions();
cDefs.addAll(Arrays.asList(nd));
}
return cDefs.toArray(new NodeDefinition[cDefs.size()]);
}
Aggregations