I am working on a Java backed webscript for Alfresco that needs to create a folder structure based on the path that is sent to it. Some of the folders that have been sent may already exist and some may not. This is the code I've got:
for( int i = 0; i < folderPathParts.length; i++){
createdFolder = serviceRegistry.getFileFolderService().searchSimple(contextFolder, folderPathParts[i]);
if( createdFolder == null){
try{
FileInfo subfolderInfo = serviceRegistry.getFileFolderService().create(contextFolder, folderPathParts[i], ContentModel.TYPE_FOLDER);
contextFolder = subfolderInfo.getNodeRef();
}catch(FileExistsException fee){
contextFolder = serviceRegistry.getFileFolderService().searchSimple(contextFolder, folderPathParts[i]);
}
}
}
Debugging the script I can see that the new node refs are created, but there is nothing actually being created when I go to share.
I read that I might need to use transactions since this script will be accessed by multiple threads, and I have tried using the retrying transaction helper but I have the same result.