Rename/Move a folder using java api
![]()
How do you Rename/Move a folder with a workspace component
using the java api?? |
One answer
![]()
IVersionable filePath = (IVersionable) iconfig.fetchCompleteItem(filePathHandle, MONITOR);
if (!(filePath.hasFullState())) { msg += "File " + fileNamePaths + " does not exists in component"; continue; } // Check if file or dir if (filePath.getItemType() == IFileItem.ITEM_TYPE) { // Get working copy IFileItem file = (IFileItem) filePath.getFullState(); file = (IFileItem) file.getWorkingCopy(); file.setFileTimestamp(new Date()); file.setName(newName); // Get delete operation fileOps.add(workspace.configurationOpFactory().save(file)); msg += "Rename File " + fileNamePaths + " to " + newName + "\n"; } else { IVersionable tmp_filePath = (IVersionable) filePath.getWorkingCopy(); tmp_filePath.setName(newName); // Get delete operation fileOps.add(workspace.configurationOpFactory().save(tmp_filePath)); msg += "Rename Dir " + fileNamePaths + " to " + newName + "\n"; } |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.