Search in sources :

Example 1 with NodeTypeIteratorAdapter

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

the class NodeTypeManagerImpl method registerNodeTypes.

/**
     * @see NodeTypeManager#registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[], boolean)
     */
public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate) throws RepositoryException {
    List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>(ntds.length);
    for (NodeTypeDefinition definition : ntds) {
        QNodeTypeDefinition qdef = new QNodeTypeDefinitionImpl(definition, getNamePathResolver(), mgrProvider.getQValueFactory());
        if (!allowUpdate && hasNodeType(qdef.getName())) {
            throw new NodeTypeExistsException("NodeType " + definition.getName() + " already exists.");
        }
        defs.add(qdef);
    }
    getNodeTypeRegistry().registerNodeTypes(defs, allowUpdate);
    List<NodeType> nts = new ArrayList<NodeType>();
    for (QNodeTypeDefinition def : defs) {
        nts.add(getNodeType(def.getName()));
    }
    return new NodeTypeIteratorAdapter(nts);
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) NodeTypeExistsException(javax.jcr.nodetype.NodeTypeExistsException) NodeType(javax.jcr.nodetype.NodeType) ArrayList(java.util.ArrayList) QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) NodeTypeDefinition(javax.jcr.nodetype.NodeTypeDefinition) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter) QNodeTypeDefinitionImpl(org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl)

Example 2 with NodeTypeIteratorAdapter

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

the class NodeTypeManagerImpl method getPrimaryNodeTypes.

/**
     * {@inheritDoc}
     */
public NodeTypeIterator getPrimaryNodeTypes() 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)

Example 3 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 = context.getNodeTypeRegistry().getRegisteredNodeTypes();
    Arrays.sort(ntNames);
    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)

Example 4 with NodeTypeIteratorAdapter

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

the class ReadOnlyNodeTypeManager method getMixinNodeTypes.

@Override
public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
    List<NodeType> list = Lists.newArrayList();
    NodeTypeIterator iterator = getAllNodeTypes();
    while (iterator.hasNext()) {
        NodeType type = iterator.nextNodeType();
        if (type.isMixin()) {
            list.add(type);
        }
    }
    return new NodeTypeIteratorAdapter(list);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) NodeTypeIterator(javax.jcr.nodetype.NodeTypeIterator) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter)

Example 5 with NodeTypeIteratorAdapter

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

the class ReadOnlyNodeTypeManager method getPrimaryNodeTypes.

@Override
public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
    List<NodeType> list = Lists.newArrayList();
    NodeTypeIterator iterator = getAllNodeTypes();
    while (iterator.hasNext()) {
        NodeType type = iterator.nextNodeType();
        if (!type.isMixin()) {
            list.add(type);
        }
    }
    return new NodeTypeIteratorAdapter(list);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) NodeTypeIterator(javax.jcr.nodetype.NodeTypeIterator) NodeTypeIteratorAdapter(org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter)

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