int segmLength = defaultDepth +1;
while (intermediateFolderNeeded(escapedId, folder)) {
String folderName = Text.escapeIllegalJcrChars(id.substring(0, segmLength));
if (folder.hasNode(folderName)) {
NodeImpl n = (NodeImpl) folder.getNode(folderName);
// validation check: folder must be of type rep:AuthorizableFolder
// and not an authorizable node.
if (n.isNodeType(NT_REP_AUTHORIZABLE_FOLDER)) {
// expected nodetype -> no violation
folder = n;
} else if (n.isNodeType(NT_REP_AUTHORIZABLE)){
/*
an authorizable node has been created before with the
name of the intermediate folder to be created.
this may only occur if the 'autoExpandTree' option has
been enabled later on.
Resolution:
- abort auto-expanding and create the authorizable
at the current level, ignoring that max-size is reached.
- note, that this behavior has been preferred over tmp.
removing and recreating the colliding authorizable node.
*/
log.warn("Auto-expanding aborted. An existing authorizable node '" + n.getName() +"'conflicts with intermediate folder to be created.");
break;
} else {
// should never get here: some other, unexpected node type
String msg = "Failed to create authorizable node: Detected conflict with node of unexpected nodetype '" + n.getPrimaryNodeType().getName() + "'.";
log.error(msg);
throw new ConstraintViolationException(msg);
}
} else {
// folder doesn't exist nor does another colliding child node.