/** * Copy constructor. * * @param nt the node type definition. */ public QNodeTypeDefinitionImpl(QNodeTypeDefinition nt) { this(nt.getName(), nt.getSupertypes(), nt.getSupportedMixinTypes(), nt.isMixin(), nt.isAbstract(), nt.isQueryable(), nt.hasOrderableChildNodes(), nt.getPrimaryItemName(), nt.getPropertyDefs(), nt.getChildNodeDefs()); }
/** * Copy constructor. * * @param nt the qualified node type definition. */ public QNodeTypeDefinitionImpl(QNodeTypeDefinition nt) { this(nt.getName(), nt.getSupertypes(), nt.isMixin(), nt.hasOrderableChildNodes(), nt.getPrimaryItemName(), nt.getPropertyDefs(), nt.getChildNodeDefs()); }
/** * Determine if a type definition itself is trivial: adding no additional type constraints other than its 'marker' name. * * Note: this ignores 'inherited' constraints from its supertypes because the check is done against all added supertype * already, including those inherited. * * @param def the type definition to check * @return true if the type definition (itself) is trivial */ protected boolean isTrivialTypeDef(QNodeTypeDefinition def) { return !def.hasOrderableChildNodes() && def.getPrimaryItemName() == null && def.getPropertyDefs().length == 0 && def.getChildNodeDefs().length == 0; } }
Set<Name> supportedMixins = null; Name ntName = ntd.getName(); Name[] smixins = ntd.getSupportedMixinTypes(); for (QNodeDefinition nd : ntd.getChildNodeDefs()) { for (QPropertyDefinition pd : ntd.getPropertyDefs()) { Name[] supertypes = ntd.getSupertypes(); if (supertypes.length > 0) { EffectiveNodeTypeImpl effSuperType = (EffectiveNodeTypeImpl) getEffectiveNodeType(supertypes, ntdMap);
/** * {@inheritDoc} */ public String getPrimaryItemName() { try { Name piName = ntd.getPrimaryItemName(); if (piName != null) { return resolver.getJCRName(piName); } else { return null; } } catch (NamespaceException e) { // should never get here log.error("encountered unregistered namespace in name of primary item", e); return ntd.getName().toString(); } }
/** * Returns the <code>Name</code> of this node type. * * @return the name */ public Name getQName() { return ntd.getName(); }
/** * @return <code>true</code> if supertypes diff */ public int supertypesDiff() { Set<Name> set1 = new HashSet<Name>(Arrays.asList(oldDef.getSupertypes())); Set<Name> set2 = new HashSet<Name>(Arrays.asList(newDef.getSupertypes())); return !set1.equals(set2) ? MAJOR : NONE; }
/** * @see EffectiveNodeType#checkAddNodeConstraints(org.apache.jackrabbit.spi.Name,QNodeTypeDefinition, ItemDefinitionProvider) */ public void checkAddNodeConstraints(Name name, QNodeTypeDefinition nodeTypeDefinition, ItemDefinitionProvider definitionProvider) throws ConstraintViolationException, NoSuchNodeTypeException { if (nodeTypeDefinition.isAbstract()) { throw new ConstraintViolationException("not allowed to add node " + name + ": " + nodeTypeDefinition.getName() + " is abstract and cannot be used as primary node type."); } if (nodeTypeDefinition.isMixin()) { throw new ConstraintViolationException("not allowed to add node " + name + ":" + nodeTypeDefinition.getName() + " is a mixin and cannot be used as primary node type."); } QNodeDefinition nd = definitionProvider.getQNodeDefinition(this, name, nodeTypeDefinition.getName()); 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"); } }
/** * {@inheritDoc} */ public PropertyDefinition[] getDeclaredPropertyDefinitions() { QPropertyDefinition[] pda = ntd.getPropertyDefs(); PropertyDefinition[] propDefs = new PropertyDefinition[pda.length]; for (int i = 0; i < pda.length; i++) { propDefs[i] = new PropertyDefinitionImpl(pda[i], null, resolver, valueFactory); } return propDefs; } }
/** * Creates a new indexing rule base on an existing one, but for a * different node type name. * * @param original the existing rule. * @param nodeTypeDef the node type definition for the rule. * @param effectiveNodeType the EffectiveNodeType of the rule */ IndexingRule(IndexingRule original, QNodeTypeDefinition nodeTypeDef, EffectiveNodeType effectiveNodeType) { this.nodeTypeName = nodeTypeDef.getName(); this.mixinNodeType = nodeTypeDef.isMixin(); this.effectiveNodeType = effectiveNodeType; this.propConfigs = original.propConfigs; this.namePatterns = original.namePatterns; this.condition = original.condition; this.boost = original.boost; }
/** * {@inheritDoc} */ public boolean isMixin() { return ntd.isMixin(); }
/** Test for node type item definitions. */ public void testItemNodeType() { QNodeTypeDefinition def = getNodeType("itemNodeType"); assertEquals("itemNodeType primaryItemName", FACTORY.create(TEST_NAMESPACE, "emptyItem"), def.getPrimaryItemName()); assertEquals("itemNodeType propertyDefs", 10, def.getPropertyDefs().length); QPropertyDefinition pdef = getPropDef("itemNodeType", null); assertTrue("itemNodeType wildcard property", pdef.definesResidual()); }
/** * {@inheritDoc} */ public NodeDefinition[] getDeclaredChildNodeDefinitions() { QItemDefinition[] cnda = ntd.getChildNodeDefs(); NodeDefinition[] nodeDefs = new NodeDefinition[cnda.length]; for (int i = 0; i < cnda.length; i++) { nodeDefs[i] = new NodeDefinitionImpl(cnda[i], null, resolver); } return nodeDefs; }
/** * {@inheritDoc} */ public boolean hasOrderableChildNodes() { return ntd.hasOrderableChildNodes(); }
/** * @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"); } }
/** * {@inheritDoc} */ public boolean isAbstract() { return ntd.isAbstract(); }
/** * {@inheritDoc} */ public boolean isQueryable() { return ntd.isQueryable(); }
QNodeTypeDefinition ntDef) throws RepositoryException { NodeId id = calculateStableId(ntDef.getName().toString()); VirtualNodeState ntState = createNodeState(parent, ntDef.getName(), id, NameConstants.NT_NODETYPE); ntState.setPropertyValue(NameConstants.JCR_NODETYPENAME, InternalValue.create(ntDef.getName())); ntState.setPropertyValues(NameConstants.JCR_SUPERTYPES, PropertyType.NAME, InternalValue.create(ntDef.getSupertypes())); ntState.setPropertyValue(NameConstants.JCR_ISMIXIN, InternalValue.create(ntDef.isMixin())); ntState.setPropertyValue(NameConstants.JCR_HASORDERABLECHILDNODES, InternalValue.create(ntDef.hasOrderableChildNodes())); if (ntDef.getPrimaryItemName() != null) { ntState.setPropertyValue(NameConstants.JCR_PRIMARYITEMNAME, InternalValue.create(ntDef.getPrimaryItemName())); QPropertyDefinition[] propDefs = ntDef.getPropertyDefs(); for (int i = 0; i < propDefs.length; i++) { VirtualNodeState pdState = createPropertyDefState(ntState, propDefs[i], ntDef, i); QNodeDefinition[] cnDefs = ntDef.getChildNodeDefs(); for (int i = 0; i < cnDefs.length; i++) { VirtualNodeState cnState = createChildNodeDefState(ntState, cnDefs[i], ntDef, i);
Set<Name> supportedMixins = null; Name ntName = ntd.getName(); Name[] smixins = ntd.getSupportedMixinTypes(); for (QNodeDefinition nd : ntd.getChildNodeDefs()) { for (QPropertyDefinition pd : ntd.getPropertyDefs()) { Name[] supertypes = ntd.getSupertypes(); if (supertypes.length > 0) { EffectiveNodeTypeImpl effSuperType = (EffectiveNodeTypeImpl) getEffectiveNodeType(supertypes, ntdMap);
/** Test for the empty node type. */ public void testEmptyNodeType() { QNodeTypeDefinition def = getNodeType("emptyNodeType"); assertNotNull("emptyNodeType exists", def); assertEquals("emptyNodeType mixin", false, def.isMixin()); assertEquals("emptyNodeType hasOrderableChildNodes", false, def.hasOrderableChildNodes()); assertEquals("emptyNodeType primaryItemName", null, def.getPrimaryItemName()); assertEquals("emptyNodeType childNodeDefs", 0, def.getChildNodeDefs().length); assertEquals("emptyNodeType propertyDefs", 0, def.getPropertyDefs().length); }