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

How to download files from a specific baseline

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?

0 votes


Accepted answer

Permanent link

 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

0 votes


One other answer

Permanent link

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);
            }
        }

1 vote

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
× 12,023
× 1,700

Question asked: May 10 '17, 11:02 p.m.

Question was seen: 2,652 times

Last updated: May 11 '17, 10:17 p.m.

Confirmation Cancel Confirm