javax.jcr.nodetype.NodeDefinition Java Examples

The following examples show how to use javax.jcr.nodetype.NodeDefinition. 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: FileFolderNodeFilter.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * Returns {@code true} if the item is a node of type nt:hierarchyNode
 * that has or defines a 'jcr:content' child node.
 */
public boolean matches(Item item) throws RepositoryException {
    if (item.isNode()) {
        Node node = (Node) item;
        if (node.isNodeType(JcrConstants.NT_HIERARCHYNODE)) {
            if (node.hasNode(JcrConstants.JCR_CONTENT)) {
                return true;
            } else {
                for (NodeDefinition pd: node.getPrimaryNodeType().getChildNodeDefinitions()) {
                    if (pd.getName().equals(JcrConstants.JCR_CONTENT)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
Example #2
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 #3
Source File: NodeWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public NodeDefinition getDefinition() throws RepositoryException {
    return this.delegate.getDefinition();
}
 
Example #4
Source File: NodeTypeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public NodeDefinition[] getChildNodeDefinitions() {
    return new NodeDefinition[0];
}
 
Example #5
Source File: NodeTypeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public NodeDefinition[] getDeclaredChildNodeDefinitions() {
    return new NodeDefinition[0];
}
 
Example #6
Source File: NodeImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public NodeDefinition getDefinition() throws RepositoryException {
    return new NodeDefinitionImpl();
}
 
Example #7
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
                            }
                        }
                    }
                }
            }
        }
    }

}