It's all about the answers!

Ask a question

How to download files from a specific baseline


vicky wang (233) | asked May 10 '17, 11:02 p.m.

Now we have the requirement that download all compoent files that included in a specific baseline,  if anyone know how to do it by java?

Accepted answer


permanent link
Ralph Schoon (63.4k33646) | answered May 11 '17, 2:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 The posts in this series https://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/ show how to create repository workspaces, add components, rebase components. The blog post Getting your stuff – using the RTC SDK to zip a repository workspace explains how to download data.  

vicky wang selected this answer as the correct answer

One other answer



permanent link
vicky wang (233) | answered May 11 '17, 10:17 p.m.

Thanks Ralph, attached the code I used based on the code  from the website;

List<IWorkspaceHandle> workspaces = manager.findWorkspaces(criteria,Integer.MAX_VALUE, null);
IWorkspaceConnection workspace = manager.getWorkspaceConnection(workspaces.get(0), null);

List<IComponentHandle> components = workspace.getComponents();
IComponentHandle requiredComponent = null;
for(IComponentHandle component : components)
{
                IComponent tmp = (IComponent)repo.itemManager().fetchCompleteItem(component, IItemManager.DEFAULT, null);
                System.out.println("compoent:" + tmp.getName());
                if(tmp.getName().equals("MyComponentName"))
                {
                requiredComponent = component;
                }
}

IBaselineSearchCriteria  baselineQuery = IBaselineSearchCriteria.FACTORY.newInstance();
baselineQuery.setExactName("MyBaseLineName");
baselineQuery.setComponentRequired(requiredComponent);
List<IBaselineHandle> baselines = manager.findBaselines(baselineQuery, Integer.MAX_VALUE, null);

IBaselineConnection baselineConn = manager.getBaselineConnection(baselines.get(0), null);
IConfiguration config = baselineConn.changeHistory().configuration();
IFolderHandle rootFolder = config.rootFolderHandle(null);

 Map<String,IVersionableHandle> kids = config.childEntries(rootFolder , null);
        for (java.util.Map.Entry<String, IVersionableHandle> folderEntry : kids.entrySet()) {
            path = path + "/" + folderEntry.getKey();
            IVersionableHandle child = folderEntry.getValue();
            if (child instanceof IFolderHandle) {
                printFolder(path, (IFolderHandle) child, config, monitor);
            } else if(item instanceof IFileItemHandle){
               IFileItem fileItem = (IFileItem)SCMPlatform.getWorkspaceManager(repo).versionableManager().fetchCompleteState(item, null);
IFileContent fileContent = fileItem.getContent();
File outputFile = new File(subIndent);
System.out.println("outputFile:" + outputFile);
OutputStream output = new FileOutputStream(outputFile.getAbsolutePath());
SCMPlatform.getContentManager(repo).retrieveContent(item, fileContent, output, null);
            }
        }


Your answer


Register or 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.