We have a functionality to create a number of folders when user saves the data in CM. The format would is attached in image:
ParentFolder
ParentFolderConfig
These all are created all the times when user creates it. I have found a way to add nodes one by one using addNode(). But to save the time and increase performance I wanted to find out a way in which I create this files and folder temporary in JAVA and save them to JCR in one call and afterwards dispose these temporary files.
Calling addNode()
multiple times and saving a the end with Session.save()
is a common pattern in JCR, it's perfectly fine to create your structure like that.
To make your code simpler you could use a utility class that takes the path of a node that's deep in your hierarchy, and creates intermediate nodes as needed. The JcrUtils.getOrCreateByPath method provided by the Jackrabbit commons module does that.