escapeLocalNodeName will replace all illegal chars, findAvailableNodeName will return a name with an increment if a node with the same name already exists in currentNode.
For example, you can write your own algorithm to replace spaces wit a dash like in the Jahia UI.