how to create nodes using a CMLCreate[]?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011 10:11 AM
Hi,
suppose I want to take advantage of executing an array of CMLCreate as a single transaction to create a folder and content tree. I've got the first CMLCreate that can work fine, but how can I get the parent reference to create the following CMLCreate so that they refer to the first created content node? I mean, the only way I know to get the reference of a created node is extracting the information from the UpdateResult, but I'd like to have such information before the update is executed, so that I can execute the whole array as a single batch. Any help would be appreciated.
Thanks
suppose I want to take advantage of executing an array of CMLCreate as a single transaction to create a folder and content tree. I've got the first CMLCreate that can work fine, but how can I get the parent reference to create the following CMLCreate so that they refer to the first created content node? I mean, the only way I know to get the reference of a created node is extracting the information from the UpdateResult, but I'd like to have such information before the update is executed, so that I can execute the whole array as a single batch. Any help would be appreciated.
Thanks
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2011 11:06 AM
Uhm…I've find a rude way to create the PathRefernce, but I suspect there must be a smarter one:
So the idea is to compute the name of each node using the root + "/" + name of inner node.
Is there a simpler and smarter way to obtain the path of to-be-created node?
Thanks
ParentReference mainParentReference = …CMLCreate create1 = new CMLCreate();…// now create a reference to the to-be-created nodeParentReference previousNodeParentReference = new ParentReference();previousNodeParentReference.setPath( mainParentReference.getPath() + "/" + ISO9075.encode( mainParentreference.getChildName() ) );
So the idea is to compute the name of each node using the root + "/" + name of inner node.
Is there a simpler and smarter way to obtain the path of to-be-created node?
Thanks
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2011 05:15 AM
Maybe I found a smarter way, but I've got still the doubt if this is correct or no: since each CMLCreate contains a ParentReference I can get the parent reference of each CMLCreate and compose the parent reference path and the parent reference child name to get the final path of the node the CML create refers to. Is a stable way of achieving this?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2011 07:59 AM
There is a way. Here's an example:
…// Create folder (parentFolder where you want to create your folder)CMLCreate createFolder = new CMLCreate("1", parentFolder, null, Constants.ASSOC_CONTAINS, null, Constants.TYPE_FOLDER, folderProperties);// Create document in newly future created folder (notice id "1" - 3rd parameter)CMLCreate create1 = new CMLCreate("2", null, "1", Constants.ASSOC_CONTAINS, null, documentTypeQName, properties);// Create another documentCMLCreate create2 = new CMLCreate("2", null, "1", Constants.ASSOC_CONTAINS, null, documentTypeQName1, properties2);cml.setCreate(new CMLCreate[] { createFolder, create1, create2 });UpdateResult[] results = getRepositoryService().update(cml);…
