How to fetch all the files and folders from the component.
Hi,
Accepted answer
I have done that with plain Java API, not with server API, but I suppose that, once you've got the workspace/stream and the component you have done most of the job.
Basically, you have to retrieve a IWorkspaceConnection from the workspace, and the to get a IConfiguration from the WS connection.
Then you retrieve the "children" (that is, folders and files) of the configuration by cycling over them.
Here are some code snippets (remember, for plain Java API, you should adapt them to server API):
static Hashtable<IVersionableHandle, IComponent> rawFilesHash = new Hashtable<IVersionableHandle, IComponent>();
getRawFilesList(repo, wm, wHandle, component, null, monitor);
private static void getRawFilesList(ITeamRepository repo, IWorkspaceManager wm, IWorkspaceHandle wHandle,
IComponent component, IFolderHandle parent, IProgressMonitor monitor) throws TeamRepositoryException {
IWorkspace workspace = (IWorkspace) repo.itemManager().fetchCompleteItem(wHandle, IItemManager.DEFAULT, null);
IWorkspaceConnection wsConn = wm.getWorkspaceConnection(workspace, null);
IConfiguration configuration = wsConn.configuration((IComponentHandle)component.getItemHandle());
Map <String, IVersionableHandle> children = null;
if (parent == null) {
children = configuration.childEntriesForRoot(null);
} else {
children = configuration.childEntries(parent, null);
}
if (children != null) {
for (String name : children.keySet()) {
IVersionableHandle item = children.get(name);
if (item instanceof IFolderHandle) {
getRawFilesList(repo, wm, wHandle, component, (IFolderHandle)item, monitor);
} else {
if (item instanceof IFileItemHandle) {
if (!rawFilesList.contains(item)) {
rawFilesList.add(item);
rawFilesHash.put(item, component);
}
}
}
}
}
}
One other answer
See http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html