// Is this node referenceable ...
boolean referenceable = false;
try {
referenceable = isReferenceable(node);
} catch (RepositoryException e) {
throw new ValidationException(e.getLocalizedMessage());
}
for (org.jboss.dna.graph.session.GraphSession.PropertyInfo<JcrPropertyPayload> property : node.getProperties()) {
if (property.getName().equals(JcrLexicon.UUID) && !referenceable) continue;
JcrPropertyPayload propPayload = property.getPayload();
JcrPropertyDefinition definition = findBestPropertyDefintion(primaryTypeName,
mixinTypeNames,
property.getProperty(),
propPayload.getPropertyType(),
property.getProperty().isSingle(),
false);
if (definition == null) {
throw new ValidationException(JcrI18n.noDefinition.text("property",
readable(property.getName()),
readable(node.getPath()),
readable(primaryTypeName),
readable(mixinTypeNames)));
}
satisfiedProperties.add(definition);
}
for (org.jboss.dna.graph.session.GraphSession.Node<JcrNodePayload, JcrPropertyPayload> child : node.getChildren()) {
int snsCount = node.getChildrenCount(child.getName());
JcrNodeDefinition definition = nodeTypes().findChildNodeDefinition(primaryTypeName,
mixinTypeNames,
child.getName(),
child.getPayload().getPrimaryTypeName(),
snsCount,
false);
if (definition == null) {
throw new ValidationException(JcrI18n.noDefinition.text("child node",
readable(child.getName()),
readable(node.getPath()),
readable(primaryTypeName),
readable(mixinTypeNames)));
}
satisfiedChildNodes.add(definition);
}
JcrNodeType primaryType = nodeTypes().getNodeType(primaryTypeName);
for (JcrPropertyDefinition definition : primaryType.getPropertyDefinitions()) {
if (definition.isMandatory() && !definition.isProtected() && !satisfiedProperties.contains(definition)) {
throw new ValidationException(JcrI18n.noDefinition.text("property",
definition.getName(),
readable(node.getPath()),
readable(primaryTypeName),
readable(mixinTypeNames)));
}
}
for (JcrNodeDefinition definition : primaryType.getChildNodeDefinitions()) {
if (definition.isMandatory() && !definition.isProtected() && !satisfiedChildNodes.contains(definition)) {
throw new ValidationException(JcrI18n.noDefinition.text("child node",
definition.getName(),
readable(node.getPath()),
readable(primaryTypeName),
readable(mixinTypeNames)));
}
}
if (mixinTypeNames != null) {
for (Name mixinTypeName : mixinTypeNames) {
JcrNodeType mixinType = nodeTypes().getNodeType(mixinTypeName);
for (JcrPropertyDefinition definition : mixinType.getPropertyDefinitions()) {
if (definition.isMandatory() && !definition.isProtected() && !satisfiedProperties.contains(definition)) {
throw new ValidationException(JcrI18n.noDefinition.text("child node",
definition.getName(),
readable(node.getPath()),
readable(primaryTypeName),
readable(mixinTypeNames)));
}
}
for (JcrNodeDefinition definition : mixinType.getChildNodeDefinitions()) {
if (definition.isMandatory() && !definition.isProtected() && !satisfiedChildNodes.contains(definition)) {
throw new ValidationException(JcrI18n.noDefinition.text("child node",
definition.getName(),
readable(node.getPath()),
readable(primaryTypeName),
readable(mixinTypeNames)));
}