0

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.

Mardoz
  • 1,617
  • 1
  • 13
  • 26
Loshmeey
  • 341
  • 1
  • 5
  • 18
  • 1
    Is there any error in alfresco.log? I would also assume it's related to transactions. Does it work when you just try to create one folder (not looped), just for testing? – Mathias Conradt Jul 30 '15 at 11:03
  • Unfortunately there is nothing in the log that could point me :/. Creating just one folder works when executing create(). Im also assuming that it has to do with transactions im just having a bit of trouble finding docs for developing with transactions for alfersco 5 :/ – Loshmeey Jul 30 '15 at 11:12
  • 1
    Regarding log: did you add the package name, where your web script is in, to log4j.properties? Folder paths: Ok, I assume you want to create a whole path like /my/path/to/folder, where the last three folders might not yet exist. This is definitely transaction related, since you want to add a child node to a parent that was created within the same transaction. But I agree, the Alfresco docs doesn't say too much about it; I am also not sure about the best solution here right away. – Mathias Conradt Jul 30 '15 at 11:15
  • Yup, i modified the log4j.properties to print out logs from the webscript. I will continue researching and experimenting and hopefully get to a solution. Thanks! – Loshmeey Jul 30 '15 at 11:23
  • Please add ,what is the value of folderPathParts or add code for that – Krutik Jayswal Jul 30 '15 at 13:18
  • what is folderPathParts ? please add – Sanjay Dec 29 '16 at 10:22

0 Answers0