Java Code Examples for javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()

The following examples show how to use javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractExporter.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
private void writeNodeType(NodeType nt, CNDWriter w, Set<String> written)
        throws IOException, RepositoryException {
    if (nt != null && !written.contains(nt.getName())) {
        written.add(nt.getName());
        w.write(nt);
        for (NodeType s: nt.getSupertypes()) {
            writeNodeType(s, w, written);
        }
        for (NodeDefinition n: nt.getChildNodeDefinitions()) {
            writeNodeType(n.getDefaultPrimaryType(), w, written);
            if (n.getRequiredPrimaryTypes() != null) {
                for (NodeType r: n.getRequiredPrimaryTypes()) {
                    writeNodeType(r, w, written);
                }
            }
        }
    }
}
 
Example 2
Source File: AggregateManagerImpl.java    From jackrabbit-filevault with Apache License 2.0 4 votes vote down vote up
/**
 * internally add the node type and all transitive ones to the set of
 * used node types.
 * @param nodeType to add
 */
private void internalAddNodeType(NodeType nodeType) {
    if (nodeType != null && !nodeTypes.contains(nodeType.getName())) {
        nodeTypes.add(nodeType.getName());
        NodeType[] superTypes = nodeType.getSupertypes();
        for (NodeType superType: superTypes) {
            nodeTypes.add(superType.getName());
        }
        NodeDefinition[] nodeDefs = nodeType.getChildNodeDefinitions();
        if (nodeDefs != null) {
            for (NodeDefinition nodeDef: nodeDefs) {
                internalAddNodeType(nodeDef.getDefaultPrimaryType());
                NodeType[] reqs = nodeDef.getRequiredPrimaryTypes();
                if (reqs != null) {
                    for (NodeType req: reqs) {
                        internalAddNodeType(req);
                    }
                }
            }
        }

        // check reference constraints, too (bug #33367)
        PropertyDefinition[] propDefs = nodeType.getPropertyDefinitions();
        if (propDefs != null) {
            for (PropertyDefinition propDef: propDefs) {
                if (propDef.getRequiredType() == PropertyType.REFERENCE ||
                        propDef.getRequiredType() == PropertyType.WEAKREFERENCE) {
                    String[] vcs = propDef.getValueConstraints();
                    if (vcs != null) {
                        for (String vc: vcs) {
                            try {
                                internalAddNodeType(session.getWorkspace().getNodeTypeManager().getNodeType(vc));
                            } catch (RepositoryException e) {
                                // ignore
                            }
                        }
                    }
                }
            }
        }
    }

}