/** * Obtain a new version of this cache with the specified node types removed from the new cache. * * @param removedNodeTypes the node types that are to be removed from the resulting cache; may not be null but may be empty * @return the resulting cache that contains all of the node types within this cache but without the supplied node types; * never null */ protected NodeTypes without( Collection<JcrNodeType> removedNodeTypes ) { if (removedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); nodeTypes.removeAll(removedNodeTypes); return new NodeTypes(this.context, nodeTypes, getVersion() + 1); }
/** * Obtain a new version of this cache with the specified node types removed from the new cache. * * @param removedNodeTypes the node types that are to be removed from the resulting cache; may not be null but may be empty * @return the resulting cache that contains all of the node types within this cache but without the supplied node types; * never null */ protected NodeTypes without( Collection<JcrNodeType> removedNodeTypes ) { if (removedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); nodeTypes.removeAll(removedNodeTypes); return new NodeTypes(this.context, nodeTypes, getVersion() + 1); }
/** * Obtain a new version of this cache with the specified node types added to the new cache. * * @param addedNodeTypes the node types that are to be added to the resulting cache; may not be null but may be empty * @return the resulting cache that contains all of the node types within this cache and the supplied node types; never null */ protected NodeTypes with( Collection<JcrNodeType> addedNodeTypes ) { if (addedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); // if there are updated node types, remove them first (hashcode is based on name alone), // else addAll() will ignore the changes. nodeTypes.removeAll(addedNodeTypes); nodeTypes.addAll(addedNodeTypes); return new NodeTypes(this.context, nodeTypes, getVersion() + 1); }
/** * Obtain a new version of this cache with the specified node types added to the new cache. * * @param addedNodeTypes the node types that are to be added to the resulting cache; may not be null but may be empty * @return the resulting cache that contains all of the node types within this cache and the supplied node types; never null */ protected NodeTypes with( Collection<JcrNodeType> addedNodeTypes ) { if (addedNodeTypes.isEmpty()) return this; Collection<JcrNodeType> nodeTypes = new HashSet<JcrNodeType>(this.nodeTypes.values()); // if there are updated node types, remove them first (hashcode is based on name alone), // else addAll() will ignore the changes. nodeTypes.removeAll(addedNodeTypes); nodeTypes.addAll(addedNodeTypes); return new NodeTypes(this.context, nodeTypes, getVersion() + 1); }
/** * Get the property definition ID. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final PropertyDefinitionId propertyDefinitionId() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); PropertyDefinitionId id = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes).getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return id; } return defn.propDefnId; }
/** * Get the property definition ID. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final PropertyDefinitionId propertyDefinitionId() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); PropertyDefinitionId id = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes).getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return id; } return defn.propDefnId; }
/** * Get the definition for this property. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final JcrPropertyDefinition propertyDefinition() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); JcrPropertyDefinition propDefn = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes); PropertyDefinitionId id = propDefn.getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return propDefn; } return nodeTypes.getPropertyDefinition(defn.propDefnId); }
/** * Get the definition for this property. * * @return the cached property definition ID; never null * @throws ItemNotFoundException if the node that contains this property doesn't exist anymore * @throws ConstraintViolationException if no valid property definition could be found * @throws InvalidItemStateException if the node has been removed in this session's transient state */ final JcrPropertyDefinition propertyDefinition() throws ItemNotFoundException, ConstraintViolationException, InvalidItemStateException { CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session.nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { Name primaryType = node.getPrimaryTypeName(); Set<Name> mixinTypes = node.getMixinTypeNames(); JcrPropertyDefinition propDefn = node.propertyDefinitionFor(property(), primaryType, mixinTypes, nodeTypes); PropertyDefinitionId id = propDefn.getId(); setPropertyDefinitionId(id, nodeTypes.getVersion()); return propDefn; } return nodeTypes.getPropertyDefinition(defn.propDefnId); }
/** * Create a new JCR Property instance given the supplied information. Note that this does not alter the node in any way, since * it does not store a reference to this property (the caller must do that if needed). * * @param property the cached node property; may not be null * @param primaryTypeName the name of the node's primary type; may not be null * @param mixinTypeNames the names of the node's mixin types; may be null or empty * @return the JCR Property instance, or null if the property could not be represented with a valid property definition given * the primary type and mixin types * @throws ConstraintViolationException if the property has no valid property definition */ private final AbstractJcrProperty createJcrProperty( Property property, Name primaryTypeName, Set<Name> mixinTypeNames ) throws ConstraintViolationException { NodeTypes nodeTypes = session.nodeTypes(); JcrPropertyDefinition defn = propertyDefinitionFor(property, primaryTypeName, mixinTypeNames, nodeTypes); int jcrPropertyType = defn.getRequiredType(); jcrPropertyType = determineBestPropertyTypeIfUndefined(jcrPropertyType, property); AbstractJcrProperty prop = null; if (defn.isMultiple()) { prop = new JcrMultiValueProperty(this, property.getName(), jcrPropertyType); } else { prop = new JcrSingleValueProperty(this, property.getName(), jcrPropertyType); } prop.setPropertyDefinitionId(defn.getId(), nodeTypes.getVersion()); return prop; }
/** * Create a new JCR Property instance given the supplied information. Note that this does not alter the node in any way, since * it does not store a reference to this property (the caller must do that if needed). * * @param property the cached node property; may not be null * @param primaryTypeName the name of the node's primary type; may not be null * @param mixinTypeNames the names of the node's mixin types; may be null or empty * @return the JCR Property instance, or null if the property could not be represented with a valid property definition given * the primary type and mixin types * @throws ConstraintViolationException if the property has no valid property definition */ private final AbstractJcrProperty createJcrProperty( Property property, Name primaryTypeName, Set<Name> mixinTypeNames ) throws ConstraintViolationException { NodeTypes nodeTypes = session.nodeTypes(); JcrPropertyDefinition defn = propertyDefinitionFor(property, primaryTypeName, mixinTypeNames, nodeTypes); int jcrPropertyType = defn.getRequiredType(); jcrPropertyType = determineBestPropertyTypeIfUndefined(jcrPropertyType, property); AbstractJcrProperty prop = null; if (defn.isMultiple()) { prop = new JcrMultiValueProperty(this, property.getName(), jcrPropertyType); } else { prop = new JcrSingleValueProperty(this, property.getName(), jcrPropertyType); } prop.setPropertyDefinitionId(defn.getId(), nodeTypes.getVersion()); return prop; }
CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session().nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { assert !this.isRoot(); setNodeDefinitionId(id, nodeTypes.getVersion()); return id;
CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session().nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { assert !this.isRoot(); setNodeDefinitionId(id, nodeTypes.getVersion()); return id;
CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session().nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { assert !this.isRoot(); setNodeDefinitionId(id, nodeTypes.getVersion()); return childDefn;
CachedDefinition defn = cachedDefn; NodeTypes nodeTypes = session().nodeTypes(); if (defn == null || nodeTypes.getVersion() > defn.nodeTypesVersion) { assert !this.isRoot(); setNodeDefinitionId(id, nodeTypes.getVersion()); return childDefn;
throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, ptype, mtypes)); setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion());
jcrProp.setPropertyDefinitionId(defn.getId(), nodeTypes.getVersion()); AbstractJcrProperty otherProp = this.jcrProperties.putIfAbsent(name, jcrProp); if (otherProp != null) {
jcrProp.setPropertyDefinitionId(defn.getId(), nodeTypes.getVersion()); AbstractJcrProperty otherProp = this.jcrProperties.putIfAbsent(name, jcrProp); if (otherProp != null) {
throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, ptype, mtypes)); setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion());
jcrNode.setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion()); return jcrNode; jcrNode.setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion());
jcrNode.setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion()); return jcrNode; jcrNode.setNodeDefinitionId(childDefn.getId(), nodeTypes.getVersion());