cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Folder Created But Name is UUID?

cpaul
Champ on-the-rise
Champ on-the-rise
Hi all,

I'm writing a Java-backed webscript that creates a custom folder (a type that extends "cm:folder" with a few additional attributes). The folder is created without a problem, but the "cm:name" attribute is set to the node's UUID and not the file name I'm passing into the FileFolderService. I'm using the following command, where "filename" is a String that I'd like to use as the object's name (e.g., "Test Folder").


FileInfo fileInfo = fileFolderService.create(parentNodeRef, filename, customQName);
When I view it in Share, instead of the filename, I see the folder with the UUID as its name (e.g., "0b9a49fd-972d-448a-9fb6-f92587755433"). I've even tried explicitly setting the "cm:name" attribute after the node is created:


NodeRef currentNode = fileInfo.getNodeRef();
HashMap<QName, Serializable> propertyMap = new HashMap<QName, Serializable>();
propertyMap.put(ContentModel.PROP_NAME, filename);
propertyMap.put(ContentModel.PROP_DESCRIPTION, description);
propertyMap.put(ContentModel.PROP_TITLE, title);
nodeService.setProperties(currentNode, propertyMap);
Not only does the "cm:name" attribute not get set, but the "cm:title" and "cm:description" fields are blank when I look at the node in Share. The really WEIRD thing is if I attempt to run the webscript again and create the folder with the same filename ("Test Folder"), I get a DB error tells me there's already a node with that name, even though it's clearly the UUID in Share and the node browser. Any idea what I'm doing wrong? Is there another/better way to do this?

Thanks,
Chris
1 REPLY 1

cpaul
Champ on-the-rise
Champ on-the-rise
Aha!

Turns out the nodeService.setProperties() method clears all attributes that are not in the HashMap. I was adding more properties later on down the line to the same node via another setProperties() call, thus clearing the name, etc.

Cautionary tale!  :mrgreen: