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

Finding a file in a component using java api

I can find a file that is at the root folder using the folliwng methods

IConfiguration iconfig = (IConfiguration) workspace.configuration(component);
IFolderHandle root = iconfig.rootFolderHandle(MONITOR);
IVersionableHandle filePathHandle = iconfig.resolvePath(root,fileName, MONITOR);

How do I find the file if it is not at the root folder level??

0 votes



One answer

Permanent link
there should be a simpler way.......


public IVersionableHandle findfile(IFolderHandle root,IConfiguration iconfig,String fileName)
throws TeamRepositoryException {
String fileNamePath[] = {fileName};
IVersionableHandle filePathHandle = null;

// Check if file at this folder level
filePathHandle = iconfig.resolvePath(root,fileNamePath, MONITOR);
if (filePathHandle != null) {
return filePathHandle;
}

// Check this file sub folders
Map<String> childEntries = iconfig.childEntries(root,MONITOR);
for(Map.Entry<String> next : childEntries.entrySet()) {
IVersionableHandle nextVersionable = next.getValue();
if (nextVersionable instanceof IFolderHandle) {
filePathHandle = findfile((IFolderHandle) nextVersionable,iconfig,fileName);

if (filePathHandle != null) {
break;
}
}
}
return filePathHandle;
}

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,950

Question asked: Aug 05 '10, 8:08 a.m.

Question was seen: 6,392 times

Last updated: Aug 05 '10, 8:08 a.m.

Confirmation Cancel Confirm