AnsweredAssumed Answered

Problem moving node in new folder

Question asked by carotti on Apr 9, 2009
Latest reply on Aug 21, 2013 by alf_kin
Hi!!
I have a problem, inside an action, when trying to move actionedUponNodeRef into new folder I've created just before.
I create new folder A (where A is a parameter generated dynamically by the first part of the action) as a child of companyHome with fileFolderService.create and then put my actionedUponNodeRef in. Here is the code:


NodeRef folderA=fileFolderService.create(companyHomeNode, A, ContentModel.TYPE_FOLDER).getNodeRef();
       
try {
         NodeRef movedNode=fileFolderService.move(actionedUponNodeRef, folderA, null).getNodeRef();
      } catch (FileExistsException e) {
         e.printStackTrace();
      } catch (FileNotFoundException e) {
         e.printStackTrace();
      }

Executing the action I get a "null pointer" exception; It seems like "fileFolderService.move" method doesn't found the new folderA I've just created; probably because the new folder isn't really created (phisically) until the action ends successfully ( in fact, when I get the exception, action is stopped and new folder isn't created).

How can I solve this problem?? Is there any method like commit, flush, or .save() in js that makes me sure the folder is created (effectively in the repository) before moving the node??
I think a method like preceedings should exist, just thinking that methods dealing with repository inside an action take effectiveness only when the action ends succesfully (otherwise, they don't take effect); unfortunately, nowadays, I don't yet found such methods.

Any suggest, help or comment is appreciated
Thanks a lot!!

Outcomes