Hi Luisa,
The code fragment you found was published by me, and now I have run into the same issue during an upgrade project. Anyhow, although finding these following code lines was all but trivial, the solution is shorter than it was before:
String pathFrom = "pcd:portal_content/original_path/to/original_role";
String pathTo = "pcd:portal_content/folder_path/to_copy_role_to"; IUser user = request.getUser(); String sessionID = request.getServletRequest().getSession().getId();
AbstractAdvancedOperation copyOperation = new CopyOperation();
copyOperation.init(pathFrom, pathTo, sessionID, null, null, user);
copyOperation.execute(pathFrom, pathTo, sessionID, user);
Keep in mind: pathFrom is a full ID including the role itself; whereas pathTo is just the folder object to copy that role to.
The API is - exactly as the old version - not published by SAP and therefore not to be used officially. It is also counterintuitive (to pass all elements twice), but hey, it's just an API which should never see the public daylight, so, it was not developed by API designers. Anyhow: It works!
If you would want to learn a bit more about it, decompile "AbstractAdvancedOperation", then you'd learn how "execute" is just a helper around "deBefore", "doOperation", "doAfter" & "doOperationCleanup". The parameters of "execute" are totally superflous, so you also could call "execute" with "null, null, null, null".
Hope it helps
Detlev
Add comment