/** * {@inheritDoc} */ public NodeType[] getSupertypes() { Name[] ntNames = ent.getInheritedNodeTypes(); NodeType[] supertypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { try { supertypes[i] = ntMgr.getNodeType(ntNames[i]); } catch (NoSuchNodeTypeException e) { // should never get here log.error("undefined supertype", e); return new NodeType[0]; } } return supertypes; }
/** * As Jackrabbit {@link NodeTypeRegistry#unregisterNodeTypes} doesn't cover more * than one level of dependencies, we need to manually get all dependencies recursively. The ones we find are added * to a list in order to register them afterwards. */ private void getDependencies(NodeTypeManager nodeTypeManager, String nodeTypeName, List<NodeTypeDefinition> dependentNodeTypeDefinitions) throws RepositoryException { NodeTypeRegistry registry = ((NodeTypeManagerImpl) nodeTypeManager).getNodeTypeRegistry(); NamePathResolver namePathResolver = ((NodeTypeManagerImpl) nodeTypeManager).getNamePathResolver(); Set<Name> directChildNodeTypeQNames = registry.getDependentNodeTypes(namePathResolver.getQName(nodeTypeName)); if (directChildNodeTypeQNames.size() == 0) { return; } for (Name directChildNodeTypeQName : directChildNodeTypeQNames) { dependentNodeTypeDefinitions.add(((NodeTypeManagerImpl) nodeTypeManager).getNodeType(directChildNodeTypeQName)); getDependencies(nodeTypeManager, namePathResolver.getJCRName(directChildNodeTypeQName), dependentNodeTypeDefinitions); } }
/** * {@inheritDoc} */ public NodeType[] getSupertypes() { Name[] ntNames = ent.getInheritedNodeTypes(); NodeType[] supertypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { try { supertypes[i] = ntMgr.getNodeType(ntNames[i]); } catch (NoSuchNodeTypeException e) { // should never get here log.error("undefined supertype", e); return new NodeType[0]; } } return supertypes; }
/** * {@inheritDoc} */ public NodeTypeIterator getAllNodeTypes() throws RepositoryException { Name[] ntNames = context.getNodeTypeRegistry().getRegisteredNodeTypes(); Arrays.sort(ntNames); ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length); for (Name ntName : ntNames) { list.add(getNodeType(ntName)); } return new NodeTypeIteratorAdapter(list); }
/** * {@inheritDoc} */ public NodeTypeIterator getAllNodeTypes() throws RepositoryException { Name[] ntNames = context.getNodeTypeRegistry().getRegisteredNodeTypes(); Arrays.sort(ntNames); ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length); for (Name ntName : ntNames) { list.add(getNodeType(ntName)); } return new NodeTypeIteratorAdapter(list); }
/** * {@inheritDoc} */ public NodeTypeIterator getPrimaryNodeTypes() 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); }
/** * {@inheritDoc} */ public NodeType[] getMixinNodeTypes() throws RepositoryException { // check state of this instance sanityCheck(); Set<Name> mixinNames = data.getNodeState().getMixinTypeNames(); if (mixinNames.isEmpty()) { return new NodeType[0]; } NodeType[] nta = new NodeType[mixinNames.size()]; Iterator<Name> iter = mixinNames.iterator(); int i = 0; while (iter.hasNext()) { nta[i++] = sessionContext.getNodeTypeManager().getNodeType(iter.next()); } return nta; }
/** * {@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); }
/** * {@inheritDoc} */ public NodeType[] getMixinNodeTypes() throws RepositoryException { // check state of this instance sanityCheck(); Set<Name> mixinNames = data.getNodeState().getMixinTypeNames(); if (mixinNames.isEmpty()) { return new NodeType[0]; } NodeType[] nta = new NodeType[mixinNames.size()]; Iterator<Name> iter = mixinNames.iterator(); int i = 0; while (iter.hasNext()) { nta[i++] = sessionContext.getNodeTypeManager().getNodeType(iter.next()); } return nta; }
/** * {@inheritDoc} */ public NodeTypeIterator getPrimaryNodeTypes() 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); }
/** * {@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); }
/** * 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; }
/** * 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; }
/** * {@inheritDoc} */ public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException { try { return getNodeType(context.getQName(nodeTypeName)); } catch (NameException e) { throw new NoSuchNodeTypeException(nodeTypeName, e); } catch (NamespaceException e) { throw new NoSuchNodeTypeException(nodeTypeName, e); } }
/** * {@inheritDoc} */ public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException { try { return getNodeType(context.getQName(nodeTypeName)); } catch (NameException e) { throw new NoSuchNodeTypeException(nodeTypeName, e); } catch (NamespaceException e) { throw new NoSuchNodeTypeException(nodeTypeName, e); } }
/** * {@inheritDoc} */ public NodeType getPrimaryNodeType() throws RepositoryException { // check state of this instance sanityCheck(); return sessionContext.getNodeTypeManager().getNodeType( data.getNodeState().getNodeTypeName()); }
/** * {@inheritDoc} */ public NodeType getPrimaryNodeType() throws RepositoryException { // check state of this instance sanityCheck(); return sessionContext.getNodeTypeManager().getNodeType( data.getNodeState().getNodeTypeName()); }
/** * Resolves the node type name in <code>node</code> into a {@link javax.jcr.nodetype.NodeType} * object using the {@link javax.jcr.nodetype.NodeTypeManager} of <code>session</code>. * * @param node the node. * @param session the session. * @return the {@link javax.jcr.nodetype.NodeType} of <code>node</code>. * @throws ItemStateException if the nodetype cannot be resolved. */ private NodeTypeImpl getNodeType(NodeState node, SessionImpl session) throws ItemStateException { try { return session.getNodeTypeManager().getNodeType(node.getNodeTypeName()); } catch (Exception e) { // also catch eventual runtime exceptions here // should never happen actually String msg; if (node == null) { msg = "Node state is null"; } else { msg = "Item " + node.getNodeId() + " has unknown node type: " + node.getNodeTypeName(); } log.error(msg); throw new ItemStateException(msg, e); } }
/** * Resolves the node type name in <code>node</code> into a {@link javax.jcr.nodetype.NodeType} * object using the {@link javax.jcr.nodetype.NodeTypeManager} of <code>session</code>. * * @param node the node. * @param session the session. * @return the {@link javax.jcr.nodetype.NodeType} of <code>node</code>. * @throws ItemStateException if the nodetype cannot be resolved. */ private NodeTypeImpl getNodeType(NodeState node, SessionImpl session) throws ItemStateException { try { return session.getNodeTypeManager().getNodeType(node.getNodeTypeName()); } catch (Exception e) { // also catch eventual runtime exceptions here // should never happen actually String msg; if (node == null) { msg = "Node state is null"; } else { msg = "Item " + node.getNodeId() + " has unknown node type: " + node.getNodeTypeName(); } log.error(msg); throw new ItemStateException(msg, e); } }
protected NodeImpl addNode(NodeImpl parentImpl, Name name, Name ntName, NodeId nodeId) throws RepositoryException { checkPermission(parentImpl, name, getPermission(true, false)); // validation: make sure Node is not locked or checked-in. parentImpl.checkSetProperty(); NodeTypeImpl nodeType = parentImpl.sessionContext.getNodeTypeManager().getNodeType(ntName); org.apache.jackrabbit.spi.commons.nodetype.NodeDefinitionImpl def = parentImpl.getApplicableChildNodeDefinition(name, ntName); // check for name collisions // TODO: improve. copied from NodeImpl NodeState thisState = parentImpl.getNodeState(); ChildNodeEntry cne = thisState.getChildNodeEntry(name, 1); if (cne != null) { // there's already a child node entry with that name; // check same-name sibling setting of new node if (!def.allowsSameNameSiblings()) { throw new ItemExistsException(); } // check same-name sibling setting of existing node NodeId newId = cne.getId(); NodeImpl n = (NodeImpl) parentImpl.sessionContext.getItemManager().getItem(newId); if (!n.getDefinition().allowsSameNameSiblings()) { throw new ItemExistsException(); } } return parentImpl.createChildNode(name, nodeType, nodeId); }