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

How to fetch all the files and folders from the component.

 Hi,


I am trying to fetch the files and folders from the components using java api.
Can we fetch directly files of the components using java server api.
I am able to fetch workspace/stream and component using server api and trying to fetch the Files and folders inside the componets. 

Can any one help for getting the Files and folders.


Thanks in advance.

0 votes


Accepted answer

Permanent link

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

Anurag Patel selected this answer as the correct answer

0 votes


One other answer

Permanent link

 See http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html


Additional examples are in other posts there.

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

Question asked: Oct 14 '17, 2:07 a.m.

Question was seen: 2,599 times

Last updated: Oct 16 '17, 5:33 a.m.

Confirmation Cancel Confirm