AnsweredAssumed Answered

Problem using childByNamePath and upper / lower case

Question asked by damiar on Apr 13, 2009
Latest reply on Feb 3, 2011 by ziggypcl
Hey guys,

actually I'm checking if a node already exists before creating it, so I can handle this case properly.
For example, suppose you want to create the node 'day' but a node named 'Day' (upper case D) already exists. What is happening now is that the function childByNamePath is returning 'null' if I use parentNode.childByNamePath('day'). That would be ok, since 'day' != 'Day', but the problem here is that if I want to create the node I get the error "Existing file or folder day already exists".

This is the code I'm using:

var documentExists = parentNode.childByNamePath('day') != null;
if (documentExists == true) { // documentExists is false, never is true
  status.code = 500;
  status.message = "Document already exist, please pick another name";
  status.redirect = true;
}

// stuff

var newDocument = parentNode.createFolder('day'); // Throws an exception ("Existing file or folder day already exists")

I cannot figure out of what is happening here… Any suggestion?

Alfresco Labs 3B running on Windows XP (development) and CentOS Linux (Production).

Outcomes