You can find below source code that we use to load all files from a workspace. If you use builds and don't have a specific purpose, you should prefer to use JBE.
public static void loadComponents(IWorkspaceConnection workspace) throws TeamRepositoryException, FileNotFoundException {
List components = teamRepository.itemManager().fetchCompleteItems(workspace.getComponents(), IItemManager.DEFAULT, null);
for (Iterator<IComponent> it = components.iterator(); it.hasNext();) {
IComponent component = it.next();
String loadComp = component.getName() + " Ykleniyor";
log.println(loadComp);
String loadComponentAct = buildClient.startBuildActivity(buildRequest.getBuildResult(), loadComp, loadComponentsAct, false, monitor);
loadComponentFileTree(workspace, component, workspace.configuration(component), null, "", monitor);
}
}
private static void loadComponentFileTree(IWorkspaceConnection workspace,
IComponent component, IConfiguration configuration, IFolderHandle parent, String indent, IProgressMonitor monitor) throws TeamRepositoryException, FileNotFoundException {
Map<String> children = null;
if(parent == null) {
children = configuration.childEntriesForRoot(null);
} else {
children = configuration.childEntries(parent, null);
}
if(children != null) {
for (String name : children.keySet()) {
String subIndent = indent + "\\" + name;
IVersionableHandle item = children.get(name);
if(item instanceof IFolderHandle)
{
File folderPath = new File(localWorkspace.getAbsolutePath()+subIndent);
folderPath.mkdirs();
}
else if(item instanceof IFileItemHandle)
{
IFileItem fileItem = (IFileItem) SCMPlatform.getWorkspaceManager(teamRepository).versionableManager().fetchCompleteState(item, null);
IFileContent fileContent = fileItem.getContent();
File outputFile = new File(localWorkspace.getAbsolutePath() + subIndent);
if(!outputFile.getParentFile().exists())
outputFile.getParentFile().mkdirs();
OutputStream output = new FileOutputStream(outputFile.getAbsolutePath());
SCMPlatform.getContentManager(teamRepository).retrieveContent(item, fileContent, output, monitor);
}
}
}
}
I want to write an application by plain Java API.
The application should be able to access our project server,and download source file or document which my colleagues finished from server to local computer's appointed folder.
Now,The application which I finished can access the server and get work items.But I can't download source file or document.
Does RTC's plain Java API provide some method that can satisfy my requirement?(I have searched,but I did not get any answer)