}
public static void autoCreateItems(Tree tree, Tree type, Tree typeRoot, String userID)
throws RepositoryException {
// TODO: use a separate rep:autoCreatePropertyDefinitions
Tree properties = type.getChild(REP_NAMED_PROPERTY_DEFINITIONS);
for (Tree definitions : properties.getChildren()) {
String name = definitions.getName();
if (name.equals(NodeTypeConstants.REP_PRIMARY_TYPE)
|| name.equals(NodeTypeConstants.REP_MIXIN_TYPES)) {
continue;
} else if (name.equals(NodeTypeConstants.REP_UUID)) {
name = JCR_UUID;
}
for (Tree definition : definitions.getChildren()) {
if (getBoolean(definition, JCR_AUTOCREATED)) {
if (!tree.hasProperty(name)) {
PropertyState property =
autoCreateProperty(name, definition, userID);
if (property != null) {
tree.setProperty(property);
} else {
throw new RepositoryException(
"Unable to auto-create value for "
+ PathUtils.concat(tree.getPath(), name));
}
}
break;
}
}
}
// TODO: use a separate rep:autoCreateChildNodeDefinitions
// Note that we use only named, non-SNS child node definitions
// as there can be no reasonable default values for residual or
// SNS child nodes
Tree childNodes = type.getChild(REP_NAMED_CHILD_NODE_DEFINITIONS);
for (Tree definitions : childNodes.getChildren()) {
String name = definitions.getName();
for (Tree definition : definitions.getChildren()) {
if (getBoolean(definition, JCR_AUTOCREATED)) {
if (!tree.hasChild(name)) {
String typeName =