I have two questions about a path creation and properties.
This is my scene: I need to create a complete path of folders. Each one has own properties, and in the last folder, the user will put contents. Depends of these contents, the properties of each folder changes.
An user gives me the path. The folders inside may exists or not. For know if folder exists, I obtain the node (and look if is not null) doing something like this:
StringTokenizer tokenizer = new StringTokenizer(path, "/");
while (tokenizer.hasMoreTokens()) {
String folderName = tokenizer.nextToken();
NodeRef newNode = getNodeService().getChildByName(nodeParent, ContentModel.ASSOC_CONTAINS, folderName );
// —> *
}
First question: all ok about this? Is the best way to create a full path?
When I finish the creation of folder and put the content, I need to update the properties of the parents. I'm thinking about this on 3 ways:
1 - Create a list of NodeRefs and store each one while create each folder, in the hasMoreTokens iteration (look at —> *).
2 - Do the same but store the uuids String of each nodeRef, not the NodeRef. And then, obtain the nodeRef from these uuids.
3 - Doing anything on the iteration and out of there, later, use the nodeService.getPrimaryParent(nodeRef).getParentRef() for update the properties of each parent node from the son.
Second question: which option do you think is better? The tree of folders will be very big. I need a efficient and quickly solution because of this.
I think that option 3 is slower than store a list of nodes to acces them quickly, but I'm not sure. And between option 1 and 2, maybe 1 is quickly too (I have the nodeRef directly without doing more operations) but I don't know if it consumes a lot of memory. I don't know if NodeRef is a big objects and having a list of NodeRefs is a handicap for the memory.
Thanks a lot!