AnsweredAssumed Answered

[Resolved] NodeService doesn't return actual information

Question asked by dranakan on Aug 5, 2009
Latest reply on Aug 6, 2009 by dranakan
Hello,

I need your help to find a bug in my action :)

In the action, I want to create one directory, check it exists, if not, I created. To do that :


NodeRef nodeOnDisk = nodeService.getChildByName(parentDirectoy,
               ContentModel.ASSOC_CONTAINS, nameDirectory);
if (nodeOnDisk != null) {
   …
} else {
   FileInfo fileInfo = fileFolderService.create(parentDirectoy,
                  nameDirectory, ContentModel.TYPE_FOLDER);
All work good if I start action with one file. But if I try to use this action in parallel (send two 2 files to start, which will created the same directory). The nodeService say (for the 2 actions) that the directory (nameDirectory) doesn't exist, but after the fileFolderService generate a error because the directory exist. When a action is running, all of the other wait (I use the synchronisation with lock) :
Start 2 action (action_A and actionB) :

(This is a temporal schema)
action_A  ……………………………………. action_B   
begin (get the nodeService)…………………..begin (get the nodeService)
create directory……………………………….wait
finished, signal other action to start    
………………………………………………..awake
………………………………………………..create directory (and error appears)

I think that the nodeService have old information about the store. Has someone an idea to have actual information about nodeService (or another way to do this) ? :?:


More info : The creation directory si done with this kind of transaction :

boolean resultCreateDirectory = transactionService
                     .getRetryingTransactionHelper()
                     .doInTransaction(
                           new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>() {
                              public Boolean execute()
                                    throws Throwable {
                                 CREATE OF DIRECTORY
                              }
                           });
            }

Thanks

Outcomes