EffectiveNodeTypeImpl( NodeTypeImpl primary, NodeTypeImpl[] mixins, ReadOnlyNodeTypeManager ntMgr) { this.ntMgr = ntMgr; addNodeType(checkNotNull(primary)); for (NodeTypeImpl mixin : checkNotNull(mixins)) { addNodeType(mixin); } if (!nodeTypes.containsKey(NT_BASE)) { try { nodeTypes.put( NT_BASE, (NodeTypeImpl) ntMgr.getNodeType(NT_BASE)); // FIXME } catch (RepositoryException e) { // TODO: ignore/warning/error? } } }
@Override public Iterable<NodeDefinition> getMandatoryNodeDefinitions() { return Iterables.filter(getNodeDefinitions(), new Predicate<NodeDefinition>() { @Override public boolean apply(NodeDefinition nodeDefinition) { return nodeDefinition.isMandatory(); } }); }
@Override public Iterable<PropertyDefinition> getMandatoryPropertyDefinitions() { return Iterables.filter(getPropertyDefinitions(), new Predicate<PropertyDefinition>() { @Override public boolean apply(PropertyDefinition propertyDefinition) { return propertyDefinition.isMandatory(); } }); }
@Override public boolean canSetProperty(String propertyName, Value value) { if (value == null) { return canRemoveProperty(propertyName); } try { EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, false, value.getType(), false); return !def.isProtected() && meetsTypeConstraints(value, def.getRequiredType()) && meetsValueConstraints(value, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
throws ConstraintViolationException { for (PropertyDefinition def : getNamedPropertyDefinitions(propertyName)) { int defType = def.getRequiredType(); if (isMultiple == def.isMultiple() for (PropertyDefinition def : getResidualPropertyDefinitions()) { int defType = def.getRequiredType(); if (isMultiple == def.isMultiple()
String childName, EffectiveNodeType childEffective) throws ConstraintViolationException { for (NodeDefinition def : getNamedNodeDefinitions(childName)) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) { for (NodeDefinition def : getResidualNodeDefinitions()) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) {
@Override public void checkRemoveProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } if (!definition.getDeclaringNodeType().canRemoveProperty(property.getName())) { throw new ConstraintViolationException("Cannot remove property '" + property.getName() + '\''); } }
/** * Returns all the node types of the given node, in a breadth-first * traversal order of the type hierarchy. * * @param node node instance * @return all types of the given node * @throws RepositoryException if the type information can not be accessed */ @Override public EffectiveNodeType getEffectiveNodeType(Node node) throws RepositoryException { NodeTypeImpl primary = (NodeTypeImpl) node.getPrimaryNodeType(); // FIXME NodeType[] mixins = node.getMixinNodeTypes(); NodeTypeImpl[] mixinImpls = new NodeTypeImpl[mixins.length]; for (int i = 0; i < mixins.length; i++) { mixinImpls[i] = (NodeTypeImpl) mixins[i]; // FIXME } return new EffectiveNodeTypeImpl(primary, mixinImpls, this); }
private PropertyDefinition getDefinition(PropertyState property) throws RepositoryException { String propertyName = property.getName(); int propertyType = property.getType().tag(); boolean isMultiple = property.isArray(); return getPropertyDefinition(propertyName, isMultiple, propertyType, true); }
@Override public boolean canSetProperty(String propertyName, Value value) { if (value == null) { return canRemoveProperty(propertyName); } try { EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, false, value.getType(), false); return !def.isProtected() && meetsTypeConstraints(value, def.getRequiredType()) && meetsValueConstraints(value, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
throws ConstraintViolationException { for (PropertyDefinition def : getNamedPropertyDefinitions(propertyName)) { int defType = def.getRequiredType(); if (isMultiple == def.isMultiple() for (PropertyDefinition def : getResidualPropertyDefinitions()) { int defType = def.getRequiredType(); if (isMultiple == def.isMultiple()
String childName, EffectiveNodeType childEffective) throws ConstraintViolationException { for (NodeDefinition def : getNamedNodeDefinitions(childName)) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) { for (NodeDefinition def : getResidualNodeDefinitions()) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) {
@Override public void checkRemoveProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } if (!definition.getDeclaringNodeType().canRemoveProperty(property.getName())) { throw new ConstraintViolationException("Cannot remove property '" + property.getName() + '\''); } }
/** * Returns all the node types of the given node, in a breadth-first * traversal order of the type hierarchy. * * @param node node instance * @return all types of the given node * @throws RepositoryException if the type information can not be accessed */ @Override public EffectiveNodeType getEffectiveNodeType(Node node) throws RepositoryException { NodeTypeImpl primary = (NodeTypeImpl) node.getPrimaryNodeType(); // FIXME NodeType[] mixins = node.getMixinNodeTypes(); NodeTypeImpl[] mixinImpls = new NodeTypeImpl[mixins.length]; for (int i = 0; i < mixins.length; i++) { mixinImpls[i] = (NodeTypeImpl) mixins[i]; // FIXME } return new EffectiveNodeTypeImpl(primary, mixinImpls, this); }
private PropertyDefinition getDefinition(PropertyState property) throws RepositoryException { String propertyName = property.getName(); int propertyType = property.getType().tag(); boolean isMultiple = property.isArray(); return getPropertyDefinition(propertyName, isMultiple, propertyType, true); }
@Override public boolean canSetProperty(String propertyName, Value[] values) { if (values == null) { return canRemoveProperty(propertyName); } try { int type = (values.length == 0) ? PropertyType.STRING : values[0].getType(); EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, true, type, false); return !def.isProtected() && meetsTypeConstraints(values, def.getRequiredType()) && meetsValueConstraints(values, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
throws ConstraintViolationException { for (PropertyDefinition def : getNamedPropertyDefinitions(propertyName)) { int defType = def.getRequiredType(); if (isMultiple == def.isMultiple() for (PropertyDefinition def : getResidualPropertyDefinitions()) { int defType = def.getRequiredType(); if (isMultiple == def.isMultiple()
String childName, EffectiveNodeType childEffective) throws ConstraintViolationException { for (NodeDefinition def : getNamedNodeDefinitions(childName)) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) { for (NodeDefinition def : getResidualNodeDefinitions()) { boolean match = true; if (childEffective != null && !childEffective.includesNodeTypes(def.getRequiredPrimaryTypeNames())) {
@Override public Iterable<PropertyDefinition> getAutoCreatePropertyDefinitions() { return Iterables.filter(getPropertyDefinitions(), new Predicate<PropertyDefinition>() { @Override public boolean apply(PropertyDefinition propertyDefinition) { return propertyDefinition.isAutoCreated(); } }); }
@Override public Iterable<NodeDefinition> getAutoCreateNodeDefinitions() { return Iterables.filter(getNodeDefinitions(), new Predicate<NodeDefinition>() { @Override public boolean apply(NodeDefinition nodeDefinition) { return nodeDefinition.isAutoCreated(); } }); }