private void checkNodeTypeConstraints(NodeState after) throws CommitFailedException { EffectiveType effective = getEffective(); Set<String> properties = effective.getMandatoryProperties(); for (PropertyState ps : after.getProperties()) { properties.remove(ps.getName()); checkPropertyTypeConstraints(ps); } // verify the presence of all mandatory items if (!properties.isEmpty()) { constraintViolation(21, "Mandatory property " + properties.iterator().next() + " not found in a new node"); } List<String> names = Lists.newArrayList(after.getChildNodeNames()); for (String child : effective.getMandatoryChildNodes()) { if (!names.remove(child)) { constraintViolation(25, "Mandatory child node " + child + " not found in a new node"); } } if (!names.isEmpty()) { for (String name : names) { NodeState child = after.getChildNode(name); String primary = child.getName(JCR_PRIMARYTYPE); Iterable<String> mixins = child.getNames(JCR_MIXINTYPES); NodeBuilder childBuilder = builder.getChildNode(name); TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, false); if (!effective.isValidChildNode(name, editor.getEffective())) { constraintViolation(25, "Unexpected child node " + name + " found in a new node"); } } } }
private void checkNodeTypeConstraints(NodeState after) throws CommitFailedException { EffectiveType effective = getEffective(); Set<String> properties = effective.getMandatoryProperties(); for (PropertyState ps : after.getProperties()) { properties.remove(ps.getName()); checkPropertyTypeConstraints(ps); } // verify the presence of all mandatory items if (!properties.isEmpty()) { constraintViolation(21, "Mandatory property " + properties.iterator().next() + " not found in a new node"); } List<String> names = Lists.newArrayList(after.getChildNodeNames()); for (String child : effective.getMandatoryChildNodes()) { if (!names.remove(child)) { constraintViolation(25, "Mandatory child node " + child + " not found in a new node"); } } if (!names.isEmpty()) { for (String name : names) { NodeState child = after.getChildNode(name); String primary = child.getName(JCR_PRIMARYTYPE); Iterable<String> mixins = child.getNames(JCR_MIXINTYPES); NodeBuilder childBuilder = builder.getChildNode(name); TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, false); if (!effective.isValidChildNode(name, editor.getEffective())) { constraintViolation(25, "Unexpected child node " + name + " found in a new node"); } } } }
private void checkNodeTypeConstraints(NodeState after) throws CommitFailedException { EffectiveType effective = getEffective(); Set<String> properties = effective.getMandatoryProperties(); for (PropertyState ps : after.getProperties()) { properties.remove(ps.getName()); checkPropertyTypeConstraints(ps); } // verify the presence of all mandatory items if (!properties.isEmpty()) { constraintViolation(21, "Mandatory property " + properties.iterator().next() + " not found in a new node"); } List<String> names = Lists.newArrayList(after.getChildNodeNames()); for (String child : effective.getMandatoryChildNodes()) { if (!names.remove(child)) { constraintViolation(25, "Mandatory child node " + child + " not found in a new node"); } } if (!names.isEmpty()) { for (String name : names) { NodeState child = after.getChildNode(name); String primary = child.getName(JCR_PRIMARYTYPE); Iterable<String> mixins = child.getNames(JCR_MIXINTYPES); NodeBuilder childBuilder = builder.getChildNode(name); TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, false); if (!effective.isValidChildNode(name, editor.getEffective())) { constraintViolation(25, "Unexpected child node " + name + " found in a new node"); } } } }
@Override public TypeEditor childNodeChanged( String name, NodeState before, NodeState after) throws CommitFailedException { String primary = after.getName(JCR_PRIMARYTYPE); Iterable<String> mixins = after.getNames(JCR_MIXINTYPES); if (primary == null && effective != null) { // no primary type defined, find and apply a default type primary = effective.getDefaultType(name); if (primary != null) { builder.setProperty(JCR_PRIMARYTYPE, primary, NAME); } else { constraintViolation( 4, "No default primary type available " + " for child node " + name); } } // if node type didn't change no need to validate child node boolean validate = primaryChanged(before, primary) || mixinsChanged(before, mixins); NodeBuilder childBuilder = builder.getChildNode(name); TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, validate); if (checkThisNode && validate && !effective.isValidChildNode(name, editor.getEffective())) { constraintViolation( 1, "No matching definition found for child node " + name + " with effective type " + editor.getEffective()); } return editor; }
@Override public TypeEditor childNodeChanged( String name, NodeState before, NodeState after) throws CommitFailedException { String primary = after.getName(JCR_PRIMARYTYPE); Iterable<String> mixins = after.getNames(JCR_MIXINTYPES); if (primary == null && effective != null) { // no primary type defined, find and apply a default type primary = effective.getDefaultType(name); if (primary != null) { builder.setProperty(JCR_PRIMARYTYPE, primary, NAME); } else { constraintViolation( 4, "No default primary type available " + " for child node " + name); } } // if node type didn't change no need to validate child node boolean validate = primaryChanged(before, primary) || mixinsChanged(before, mixins); NodeBuilder childBuilder = builder.getChildNode(name); TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, validate); if (checkThisNode && validate && !effective.isValidChildNode(name, editor.getEffective())) { constraintViolation( 1, "No matching definition found for child node " + name + " with effective type " + editor.getEffective()); } return editor; }
@Override public TypeEditor childNodeChanged( String name, NodeState before, NodeState after) throws CommitFailedException { String primary = after.getName(JCR_PRIMARYTYPE); Iterable<String> mixins = after.getNames(JCR_MIXINTYPES); if (primary == null && effective != null) { // no primary type defined, find and apply a default type primary = effective.getDefaultType(name); if (primary != null) { builder.setProperty(JCR_PRIMARYTYPE, primary, NAME); } else { constraintViolation( 4, "No default primary type available " + " for child node " + name); } } // if node type didn't change no need to validate child node boolean validate = primaryChanged(before, primary) || mixinsChanged(before, mixins); NodeBuilder childBuilder = builder.getChildNode(name); TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, validate); if (checkThisNode && validate && !effective.isValidChildNode(name, editor.getEffective())) { constraintViolation( 1, "No matching definition found for child node " + name + " with effective type " + editor.getEffective()); } return editor; }