/** * @param name * @throws ConstraintViolationException */ public void checkAddNodeConstraints(Name name) throws ConstraintViolationException { try { getApplicableChildNodeDef(name, null, null); } catch (NoSuchNodeTypeException nsnte) { String msg = "internal error: inconsistent node type"; log.debug(msg); throw new ConstraintViolationException(msg, nsnte); } }
/** * @param name * @throws ConstraintViolationException */ public void checkAddNodeConstraints(Name name) throws ConstraintViolationException { try { getApplicableChildNodeDef(name, null, null); } catch (NoSuchNodeTypeException nsnte) { String msg = "internal error: inconsistent node type"; log.debug(msg); throw new ConstraintViolationException(msg, nsnte); } }
/** * Retrieves the node definition for the given constraints. * * @param parent The parent state. * @param nodeName * @param nodeTypeName * @return * @throws RepositoryException */ protected QNodeDefinition getApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName) throws RepositoryException { return getEffectiveNodeType(parent).getApplicableChildNodeDef( nodeName, nodeTypeName, getNodeTypeRegistry()); }
/** * Retrieves the node definition for the given constraints. * * @param parent The parent state. * @param nodeName * @param nodeTypeName * @return * @throws RepositoryException */ protected QNodeDefinition getApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName) throws RepositoryException { return getEffectiveNodeType(parent).getApplicableChildNodeDef( nodeName, nodeTypeName, getNodeTypeRegistry()); }
/** * Helper method that finds the applicable definition for a child node with * the given name and node type in the parent node's node type and * mixin types. * * @param name * @param nodeTypeName * @param parentState * @return a <code>QNodeDefinition</code> * @throws ConstraintViolationException if no applicable child node definition * could be found * @throws RepositoryException if another error occurs */ public QNodeDefinition findApplicableNodeDefinition(Name name, Name nodeTypeName, NodeState parentState) throws RepositoryException, ConstraintViolationException { EffectiveNodeType entParent = getEffectiveNodeType(parentState); return entParent.getApplicableChildNodeDef( name, nodeTypeName, context.getNodeTypeRegistry()); }
/** * Helper method that finds the applicable definition for a child node with * the given name and node type in the parent node's node type and * mixin types. * * @param name * @param nodeTypeName * @param parentState * @return a <code>QNodeDefinition</code> * @throws ConstraintViolationException if no applicable child node definition * could be found * @throws RepositoryException if another error occurs */ public QNodeDefinition findApplicableNodeDefinition(Name name, Name nodeTypeName, NodeState parentState) throws RepositoryException, ConstraintViolationException { EffectiveNodeType entParent = getEffectiveNodeType(parentState); return entParent.getApplicableChildNodeDef( name, nodeTypeName, context.getNodeTypeRegistry()); }
/** * Returns the QNodeDefinition for this state * @return the node def * @throws RepositoryException if an error occurs */ public QNodeDefinition getDefinition() throws RepositoryException { if (def == null) { EffectiveNodeType ent = getParent().getEffectiveNodeType(); def = ent.getApplicableChildNodeDef(getName(), nodeState.getNodeTypeName(), ntReg); } return def; }
/** * Returns the QNodeDefinition for this state * @return the node def * @throws RepositoryException if an error occurs */ public QNodeDefinition getDefinition() throws RepositoryException { if (def == null) { EffectiveNodeType ent = getParent().getEffectiveNodeType(); def = ent.getApplicableChildNodeDef(getName(), nodeState.getNodeTypeName(), ntReg); } return def; }
/** * Returns the applicable child node definition for a child node with the * specified name and node type. * * @param nodeName * @param nodeTypeName * @return * @throws ConstraintViolationException if no applicable child node definition * could be found * @throws RepositoryException if another error occurs */ protected NodeDefinitionImpl getApplicableChildNodeDefinition(Name nodeName, Name nodeTypeName) throws ConstraintViolationException, RepositoryException { NodeTypeManagerImpl ntMgr = sessionContext.getNodeTypeManager(); QNodeDefinition cnd = getEffectiveNodeType().getApplicableChildNodeDef( nodeName, nodeTypeName, sessionContext.getNodeTypeRegistry()); return ntMgr.getNodeDefinition(cnd); }
/** * Returns the applicable child node definition for a child node with the * specified name and node type. * * @param nodeName * @param nodeTypeName * @return * @throws ConstraintViolationException if no applicable child node definition * could be found * @throws RepositoryException if another error occurs */ protected NodeDefinitionImpl getApplicableChildNodeDefinition(Name nodeName, Name nodeTypeName) throws ConstraintViolationException, RepositoryException { NodeTypeManagerImpl ntMgr = sessionContext.getNodeTypeManager(); QNodeDefinition cnd = getEffectiveNodeType().getApplicableChildNodeDef( nodeName, nodeTypeName, sessionContext.getNodeTypeRegistry()); return ntMgr.getNodeDefinition(cnd); }
protected final QNodeDefinition lookupNodeDef(NodeState parent, org.apache.jackrabbit.spi.Name nodeTypeName, org.apache.jackrabbit.spi.Name nodeName) throws RepositoryException { org.apache.jackrabbit.core.nodetype.EffectiveNodeType effNodeType; try { HashSet set = new HashSet(parent.getMixinTypeNames()); effNodeType = stateMgr.getNodeTypeRegistry().getEffectiveNodeType(parent.getNodeTypeName(), set); try { return effNodeType.getApplicableChildNodeDef(nodeName, nodeTypeName, stateMgr.getNodeTypeRegistry()); } catch (RepositoryException re) { // FIXME? hack, use nt:unstructured as parent effNodeType = stateMgr.getNodeTypeRegistry().getEffectiveNodeType(NameConstants.NT_UNSTRUCTURED); return effNodeType.getApplicableChildNodeDef(nodeName, nodeTypeName, stateMgr.getNodeTypeRegistry()); } } catch (NoSuchNodeTypeException ex) { throw new RepositoryException("internal error: failed to build effective node type for node " + parent.getNodeId(), ex); } catch (NodeTypeConflictException ex) { throw new RepositoryException("internal error: failed to build effective node type for node " + parent.getNodeId(), ex); } }
public boolean allowsSameNameSiblings(NodeId id) { try { NodeState ns = getNodeState(id); NodeState parent = getNodeState(ns.getParentId()); Name name = parent.getChildNodeEntry(id).getName(); EffectiveNodeType ent = ntReg.getEffectiveNodeType( parent.getNodeTypeName(), parent.getMixinTypeNames()); QNodeDefinition def = ent.getApplicableChildNodeDef(name, ns.getNodeTypeName(), ntReg); return def != null ? def.allowsSameNameSiblings() : false; } catch (Exception e) { log.warn("Unable to get node definition", e); return false; } }
public boolean allowsSameNameSiblings(NodeId id) { try { NodeState ns = getNodeState(id); NodeState parent = getNodeState(ns.getParentId()); Name name = parent.getChildNodeEntry(id).getName(); EffectiveNodeType ent = ntReg.getEffectiveNodeType( parent.getNodeTypeName(), parent.getMixinTypeNames()); QNodeDefinition def = ent.getApplicableChildNodeDef(name, ns.getNodeTypeName(), ntReg); return def != null ? def.allowsSameNameSiblings() : false; } catch (Exception e) { log.warn("Unable to get node definition", e); return false; } }
/** * @param name * @param nodeTypeName * @param ntReg * @throws ConstraintViolationException * @throws NoSuchNodeTypeException */ public void checkAddNodeConstraints(Name name, Name nodeTypeName, NodeTypeRegistry ntReg) throws ConstraintViolationException, NoSuchNodeTypeException { if (nodeTypeName != null) { QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(nodeTypeName); if (ntDef.isAbstract()) { throw new ConstraintViolationException(nodeTypeName + " is abstract."); } if (ntDef.isMixin()) { throw new ConstraintViolationException(nodeTypeName + " is mixin."); } } QItemDefinition nd = getApplicableChildNodeDef(name, nodeTypeName, ntReg); if (nd.isProtected()) { throw new ConstraintViolationException(name + " is protected"); } if (nd.isAutoCreated()) { throw new ConstraintViolationException(name + " is auto-created and can not be manually added"); } }
/** * @param name * @param nodeTypeName * @param ntReg * @throws ConstraintViolationException * @throws NoSuchNodeTypeException */ public void checkAddNodeConstraints(Name name, Name nodeTypeName, NodeTypeRegistry ntReg) throws ConstraintViolationException, NoSuchNodeTypeException { if (nodeTypeName != null) { QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(nodeTypeName); if (ntDef.isAbstract()) { throw new ConstraintViolationException(nodeTypeName + " is abstract."); } if (ntDef.isMixin()) { throw new ConstraintViolationException(nodeTypeName + " is mixin."); } } QItemDefinition nd = getApplicableChildNodeDef(name, nodeTypeName, ntReg); if (nd.isProtected()) { throw new ConstraintViolationException(name + " is protected"); } if (nd.isAutoCreated()) { throw new ConstraintViolationException(name + " is auto-created and can not be manually added"); } }
QNodeDefinition def; try { def = ent.getApplicableChildNodeDef( cne.getName(), state.getNodeTypeName(), ntReg); } catch (ConstraintViolationException e) { def = ent.getApplicableChildNodeDef( cne.getName(), state.getNodeTypeName(), ntReg); log.warn("Fallback to nt:unstructured due to unknown child " +
QNodeDefinition def; try { def = ent.getApplicableChildNodeDef( cne.getName(), state.getNodeTypeName(), ntReg); } catch (ConstraintViolationException e) { def = ent.getApplicableChildNodeDef( cne.getName(), state.getNodeTypeName(), ntReg); log.warn("Fallback to nt:unstructured due to unknown child " +
def = ent.getApplicableChildNodeDef(name, nodeState.getNodeTypeName(), ntReg); } catch (RepositoryException re) { String msg = "no definition found in parent node's node type for new node"; throw new RepositoryException(e); QNodeDefinition existingChildDef = ent.getApplicableChildNodeDef( cne.getName(), existingChild.getNodeTypeName(), ntReg); if (!existingChildDef.allowsSameNameSiblings()) {
def = ent.getApplicableChildNodeDef(name, nodeState.getNodeTypeName(), ntReg); } catch (RepositoryException re) { String msg = "no definition found in parent node's node type for new node"; throw new RepositoryException(e); QNodeDefinition existingChildDef = ent.getApplicableChildNodeDef( cne.getName(), existingChild.getNodeTypeName(), ntReg); if (!existingChildDef.allowsSameNameSiblings()) {