/** * 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; }