Search in sources :

Example 11 with NodeTypeIteratorAdapter

use of org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter in project jackrabbit-oak by apache.

the class NodeTypeImpl method getDeclaredSubtypes.

@Override
public NodeTypeIterator getDeclaredSubtypes() {
    List<NodeType> subtypes = Lists.newArrayList();
    String oakName = getOakName();
    Tree root = definition.getParent();
    for (Tree child : root.getChildren()) {
        PropertyState supertypes = child.getProperty(JCR_SUPERTYPES);
        if (supertypes != null) {
            for (String name : supertypes.getValue(Type.NAMES)) {
                if (oakName.equals(name)) {
                    subtypes.add(new NodeTypeImpl(child, mapper));
                    break;
                }
            }
        }
    }
    return new NodeTypeIteratorAdapter(subtypes);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) Tree(org.apache.jackrabbit.oak.api.Tree) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 12 with NodeTypeIteratorAdapter

use of org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter in project jackrabbit-oak by apache.

the class NodeTypeImpl method getSubtypes.

@Override
public NodeTypeIterator getSubtypes() {
    Map<String, Set<String>> inheritance = Maps.newHashMap();
    Tree root = definition.getParent();
    for (Tree child : root.getChildren()) {
        String oakName = getOakName(child);
        PropertyState supertypes = child.getProperty(JCR_SUPERTYPES);
        if (supertypes != null) {
            for (String supername : supertypes.getValue(Type.NAMES)) {
                Set<String> subtypes = inheritance.get(supername);
                if (subtypes == null) {
                    subtypes = Sets.newHashSet();
                    inheritance.put(supername, subtypes);
                }
                subtypes.add(oakName);
            }
        }
    }
    Map<String, NodeType> subtypes = Maps.newHashMap();
    addSubtypes(getOakName(), subtypes, root, inheritance);
    return new NodeTypeIteratorAdapter(subtypes.values());
}
Also used : Set(java.util.Set) NodeType(javax.jcr.nodetype.NodeType) Tree(org.apache.jackrabbit.oak.api.Tree) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 13 with NodeTypeIteratorAdapter

use of org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter in project jackrabbit-oak by apache.

the class ReadOnlyNodeTypeManager method getAllNodeTypes.

@Override
public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
    List<NodeType> list = Lists.newArrayList();
    Tree types = getTypes();
    if (types != null) {
        NamePathMapper mapper = getNamePathMapper();
        for (Tree type : types.getChildren()) {
            list.add(new NodeTypeImpl(type, mapper));
        }
    }
    return new NodeTypeIteratorAdapter(list);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) Tree(org.apache.jackrabbit.oak.api.Tree) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter)

Example 14 with NodeTypeIteratorAdapter

use of org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter in project jackrabbit by apache.

the class NodeTypeManagerImpl method getAllNodeTypes.

//----------------------------------------------------< NodeTypeManager >---
/**
     * {@inheritDoc}
     */
public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
    Name[] ntNames = ntReg.getRegisteredNodeTypes();
    ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length);
    for (Name ntName : ntNames) {
        list.add(getNodeType(ntName));
    }
    return new NodeTypeIteratorAdapter(list);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) ArrayList(java.util.ArrayList) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter) Name(org.apache.jackrabbit.spi.Name)

Example 15 with NodeTypeIteratorAdapter

use of org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter in project jackrabbit by apache.

the class NodeTypeManagerImpl method getMixinNodeTypes.

/**
     * {@inheritDoc}
     */
public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
    Name[] ntNames = ntReg.getRegisteredNodeTypes();
    ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length);
    for (Name ntName : ntNames) {
        NodeType nt = getNodeType(ntName);
        if (nt.isMixin()) {
            list.add(nt);
        }
    }
    return new NodeTypeIteratorAdapter(list);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) ArrayList(java.util.ArrayList) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter) Name(org.apache.jackrabbit.spi.Name)

Aggregations

NodeType (javax.jcr.nodetype.NodeType)16 NodeTypeIteratorAdapter (org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter)16 ArrayList (java.util.ArrayList)11 Name (org.apache.jackrabbit.spi.Name)6 Tree (org.apache.jackrabbit.oak.api.Tree)4 NodeTypeDefinition (javax.jcr.nodetype.NodeTypeDefinition)3 NodeTypeIterator (javax.jcr.nodetype.NodeTypeIterator)3 NodeTypeExistsException (javax.jcr.nodetype.NodeTypeExistsException)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)2 Set (java.util.Set)1 RepositoryException (javax.jcr.RepositoryException)1 InvalidNodeTypeDefinitionException (javax.jcr.nodetype.InvalidNodeTypeDefinitionException)1 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 Root (org.apache.jackrabbit.oak.api.Root)1 NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)1 QNodeTypeDefinitionImpl (org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl)1 DavException (org.apache.jackrabbit.webdav.DavException)1 JcrDavException (org.apache.jackrabbit.webdav.jcr.JcrDavException)1