Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Rename/Move a folder using java api

How do you Rename/Move a folder with a workspace component
using the java api??

0 votes



One answer

Permanent link
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";
}

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937

Question asked: Nov 29 '10, 12:23 p.m.

Question was seen: 6,860 times

Last updated: Nov 29 '10, 12:23 p.m.

Confirmation Cancel Confirm