@Override public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException { if (checkThisNode && effective.isMandatoryChildNode(name)) { constraintViolation(26, "Mandatory child node " + name + " can not be removed"); } return null; // no further checking needed for the removed subtree }
@Override public String[] getValueConstraints() { // TODO: namespace mapping? String[] valConstraints = getStrings(JcrConstants.JCR_VALUECONSTRAINTS); if (valConstraints != null) { return valConstraints; } else { return new String[0]; } }
/** * Throws or logs the specified constraint violation. * * @param code code of this violation * @param message description of the violation * @throws CommitFailedException the constraint violation */ private void constraintViolation(int code, String message) throws CommitFailedException { List<String> nodeTypeNames = effective != null ? effective.getDirectTypeNames() : Collections.emptyList(); callback.onConstraintViolation(getPath(), nodeTypeNames, code, message); }
@Override public int getRequiredType() { String string = getString(JcrConstants.JCR_REQUIREDTYPE); if (string != null) { return valueFromName(string); } else { return UNDEFINED; } }
private String getPath() { if (parent == null) { return "/"; } else if (parent.parent == null) { return '/' + nodeName; } else { return parent.getPath() + '/' + nodeName; } }
/** * Constructor * @param oldDef old definition * @param newDef new definition */ private NodeTypeDefDiff(NodeTypeDefinition oldDef, NodeTypeDefinition newDef) { this.oldDef = oldDef; this.newDef = newDef; init(); }
@Override public void propertyChanged(PropertyState before, PropertyState after) throws CommitFailedException { if (checkThisNode) { checkPropertyTypeConstraints(after); } }
ChildItemDefDiff(ItemDefinition oldDef, ItemDefinition newDef) { this.oldDef = oldDef; this.newDef = newDef; init(); }
@Override public void propertyAdded(PropertyState after) throws CommitFailedException { propertyChanged(null, after); }
@Override public Iterable<NodeDefinition> apply(NodeTypeImpl input) { return input.getDeclaredNamedNodeDefinitions(oakName); } }));
private static boolean meetsValueConstraints(Value[] values, String[] constraints) { if (constraints == null || constraints.length == 0) { return true; } // Constraints must be met by all values for (Value value : values) { if (!meetsValueConstraints(value, constraints)) { return false; } } return true; }
@Override public Editor childNodeAdded(String name, NodeState after) throws CommitFailedException { // TODO: add any auto-created items that are still missing return childNodeChanged(name, MISSING_NODE, after); }
/** * Throws or logs the specified constraint violation. * * @param code code of this violation * @param message description of the violation * @throws CommitFailedException the constraint violation */ private void constraintViolation(int code, String message) throws CommitFailedException { List<String> nodeTypeNames = effective != null ? effective.getDirectTypeNames() : Collections.emptyList(); callback.onConstraintViolation(getPath(), nodeTypeNames, code, message); }
@Override public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException { if (checkThisNode && effective.isMandatoryChildNode(name)) { constraintViolation(26, "Mandatory child node " + name + " can not be removed"); } return null; // no further checking needed for the removed subtree }
@Override public String[] getValueConstraints() { // TODO: namespace mapping? String[] valConstraints = getStrings(JcrConstants.JCR_VALUECONSTRAINTS); if (valConstraints != null) { return valConstraints; } else { return new String[0]; } }
private String getPath() { if (parent == null) { return "/"; } else if (parent.parent == null) { return '/' + nodeName; } else { return parent.getPath() + '/' + nodeName; } }
/** * Constructor * @param oldDef old definition * @param newDef new definition */ private NodeTypeDefDiff(NodeTypeDefinition oldDef, NodeTypeDefinition newDef) { this.oldDef = oldDef; this.newDef = newDef; init(); }
/** * Throws or logs the specified constraint violation. * * @param code code of this violation * @param message description of the violation * @throws CommitFailedException the constraint violation */ private void constraintViolation(int code, String message) throws CommitFailedException { List<String> nodeTypeNames = effective != null ? effective.getDirectTypeNames() : Collections.emptyList(); callback.onConstraintViolation(getPath(), nodeTypeNames, code, message); }
@Override public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException { if (checkThisNode && effective.isMandatoryChildNode(name)) { constraintViolation(26, "Mandatory child node " + name + " can not be removed"); } return null; // no further checking needed for the removed subtree }