Search in sources :

Example 46 with NoSuchNodeTypeException

use of javax.jcr.nodetype.NoSuchNodeTypeException in project jackrabbit by apache.

the class NodeTypeManagerImpl method registerNodeTypes.

// --------------------------------------------< JackrabbitNodeTypeManager >
/**
 * Internal helper method for registering a list of node type definitions.
 * Returns a collection containing the registered node types.
 *
 * @param defs a collection of <code>QNodeTypeDefinition<code> objects
 * @return registered node types
 * @throws InvalidNodeTypeDefException if a nodetype is invalid
 * @throws RepositoryException if an error occurs
 */
private Collection<NodeType> registerNodeTypes(List<QNodeTypeDefinition> defs) throws InvalidNodeTypeDefException, RepositoryException {
    context.getNodeTypeRegistry().registerNodeTypes(defs);
    Set<NodeType> types = new HashSet<NodeType>();
    for (QNodeTypeDefinition def : defs) {
        try {
            types.add(getNodeType(def.getName()));
        } catch (NoSuchNodeTypeException e) {
        // ignore
        }
    }
    return types;
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) NodeType(javax.jcr.nodetype.NodeType) HashSet(java.util.HashSet) NoSuchNodeTypeException(javax.jcr.nodetype.NoSuchNodeTypeException)

Example 47 with NoSuchNodeTypeException

use of javax.jcr.nodetype.NoSuchNodeTypeException in project jackrabbit by apache.

the class PropertyTypeRegistry method nodeTypeRegistered.

public void nodeTypeRegistered(Name ntName) {
    try {
        QNodeTypeDefinition def = registry.getNodeTypeDef(ntName);
        QPropertyDefinition[] propDefs = def.getPropertyDefs();
        synchronized (typeMapping) {
            for (QPropertyDefinition propDef : propDefs) {
                int type = propDef.getRequiredType();
                if (!propDef.definesResidual() && type != PropertyType.UNDEFINED) {
                    Name name = propDef.getName();
                    // only remember defined property types
                    TypeMapping[] types = typeMapping.get(name);
                    if (types == null) {
                        types = new TypeMapping[1];
                    } else {
                        TypeMapping[] tmp = new TypeMapping[types.length + 1];
                        System.arraycopy(types, 0, tmp, 0, types.length);
                        types = tmp;
                    }
                    types[types.length - 1] = new TypeMapping(ntName, type, propDef.isMultiple());
                    typeMapping.put(name, types);
                }
            }
        }
    } catch (NoSuchNodeTypeException e) {
        log.error("Unable to get newly registered node type definition for name: " + ntName);
    }
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) Name(org.apache.jackrabbit.spi.Name) NoSuchNodeTypeException(javax.jcr.nodetype.NoSuchNodeTypeException)

Aggregations

NoSuchNodeTypeException (javax.jcr.nodetype.NoSuchNodeTypeException)47 Name (org.apache.jackrabbit.spi.Name)16 NodeType (javax.jcr.nodetype.NodeType)15 RepositoryException (javax.jcr.RepositoryException)11 Node (javax.jcr.Node)10 QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)9 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)8 Session (javax.jcr.Session)7 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)7 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)7 HashSet (java.util.HashSet)5 Tree (org.apache.jackrabbit.oak.api.Tree)4 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)4 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)4 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)3 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)3 ValueConstraint (org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint)3 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 Stack (java.util.Stack)2