use of javax.jcr.nodetype.NodeDefinition in project sling by apache.
the class VltNodeTypeFactory method initAllowedPrimaryChildNodeTypes.
private void initAllowedPrimaryChildNodeTypes(VltNodeType nt0) throws RepositoryException {
NodeDefinition[] declaredCihldNodeDefinitions = nt0.getDeclaredChildNodeDefinitions();
Set<String> allowedChildNodeTypes = new HashSet<>();
if (declaredCihldNodeDefinitions != null) {
for (int i = 0; i < declaredCihldNodeDefinitions.length; i++) {
NodeDefinition nodeDefinition = declaredCihldNodeDefinitions[i];
NodeType[] requiredPrimaryTypes = nodeDefinition.getRequiredPrimaryTypes();
if (requiredPrimaryTypes != null) {
for (int j = 0; j < requiredPrimaryTypes.length; j++) {
VltNodeType aRequiredPrimaryType = (VltNodeType) requiredPrimaryTypes[j];
if (aRequiredPrimaryType == null) {
System.out.println("this can not be");
}
Set<VltNodeType> allKnownChildTypes = aRequiredPrimaryType.getAllKnownChildTypes();
for (Iterator<VltNodeType> it = allKnownChildTypes.iterator(); it.hasNext(); ) {
VltNodeType aChildType = it.next();
VltNodeType nt2 = getNodeType(aChildType.getName());
if (!nt2.isMixin()) {
// mixins cannot be primary node types!
allowedChildNodeTypes.add(nt2.getName());
}
}
}
}
}
}
nt0.setAllowedPrimaryChildNodeTypes(allowedChildNodeTypes);
}
use of javax.jcr.nodetype.NodeDefinition in project sling by apache.
the class VltNodeTypeFactory method initDeclaredFields.
private void initDeclaredFields(VltNodeType nt) {
final ResourceProxy child = nt.getResourceProxy();
String[] superTypeNamess = (String[]) child.getProperties().get("jcr:supertypes");
nt.setDeclaredSupertypeNames(superTypeNamess);
if (superTypeNamess != null) {
NodeType[] superTypes = new NodeType[superTypeNamess.length];
for (int i = 0; i < superTypeNamess.length; i++) {
superTypes[i] = getNodeType(superTypeNamess[i]);
}
nt.setDeclaredSupertypes(superTypes);
}
Set<VltNodeDefinition> nds = new HashSet<>();
for (ResourceProxy ntChild : child.getChildren()) {
String ntChildName = PathUtil.getName(ntChild.getPath());
if (ntChildName.startsWith("jcr:childNodeDefinition")) {
VltNodeDefinition nd = handleChildNodeDefinition(ntChild);
nds.add(nd);
} else if (ntChildName.startsWith("rep:residualChildNodeDefinitions")) {
// go through children
for (ResourceProxy residualChild : ntChild.getChildren()) {
nds.add(handleChildNodeDefinition(residualChild));
}
}
}
nt.setDeclaredChildNodeDefinitions(nds.toArray(new NodeDefinition[0]));
initDeclaredPropertyDefinitions(nt, child);
}
Aggregations