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

Fetch files from repository

Hi,

I'm developing an Eclipse plug-in that analyses authorship data of projects residing in a jazz repository.
In particular, as a first step I want to show for each line of every single project file, the author and other informations.
I've already figured out how to connect to a team repository, get the components from it, navigate through their folders structure and for every file (IFileItemHandle) found, get the related changeset which contains the authoring info I need.

What I'd like to do now is to get the actual file from the repository so that I can, for example, annotate every single line of it with the retrieved authoring info.
I tried to look around the Wiki and mess around a bit but haven't been able to solve the problem.

Here's is the source code that for every file, retrieves the related changesets:
if(tmp instanceof IFileItemHandle){
List<IChangeSetHandle> cs = FileSystemCore.getFileSystemManager(repository).getFileSystemView(conn).getBlame(comp, (IFileItemHandle)tmp, null, null);
for(Iterator<IChangeSetHandle> csIter = cs.iterator(); csIter.hasNext();){
IChangeSetHandle tempCs = csIter.next();
IChangeSet contribution = (IChangeSet) repository.itemManager().fetchCompleteItem(tempCs, IItemManager.DEFAULT, null);
IContributor author = (IContributor) repository.itemManager().fetchCompleteItem(contribution.getAuthor(), IItemManager.DEFAULT, null);
}


So, in other words, what is the easiest way to get the source file related to a FileItem/FileItemHandle?

cheers
Giacomo

0 votes



2 answers

Permanent link
Using M6ish APIs (some tweaking may be necessary, but this is the
general idea):

IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
IVersionableManager vm = wm.versionableManager();
IContentManager contentManager = teamRepository.contentManager();

IChange c = //; find the change in the change-set for that item
IFileItemHandle after = c.afterState();
if( after != null )
{
IFileItem f = vm.fetchCompleteState(after, null);
IContent content = f.getContent();
InputStream s = contentManager.retrieveContentStream(content, null);
// s is your file
}

HTH,
JohnC
SCM Server

ghezzi wrote:
Hi,

I'm developing an Eclipse plug-in that analyses authorship data of
projects residing in a jazz repository.
In particular, as a first step I want to show for each line of every
single project file, the author and other informations.
I've already figured out how to connect to a team repository, get the
components from it, navigate through their folders structure and for
every file (IFileItemHandle) found, get the related changeset which
contains the authoring info I need.

What I'd like to do now is to get the actual file from the repository
so that I can, for example, annotate every single line of it with the
retrieved authoring info.
I tried to look around the Wiki and mess around a bit but haven't been
able to solve the problem.

Here's is the source code that for every file, retrieves the related
changesets:
if(tmp instanceof IFileItemHandle){
List<IChangeSetHandle> cs =
FileSystemCore.getFileSystemManager(repository).getFileSystemView(conn).getBlame(comp,
(IFileItemHandle)tmp, null, null);
for(Iterator<IChangeSetHandle> csIter = cs.iterator();
csIter.hasNext();){
IChangeSetHandle tempCs = csIter.next();
IChangeSet contribution = (IChangeSet)
repository.itemManager().fetchCompleteItem(tempCs,
IItemManager.DEFAULT, null);
IContributor author = (IContributor)
repository.itemManager().fetchCompleteItem(contribution.getAuthor(),
IItemManager.DEFAULT, null);
}

So, in other words, what is the easiest way to get the source file
related to a FileItem/FileItemHandle?

cheers
Giacomo

0 votes


Permanent link
Thanks, that worked
cheers
Giacomo

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

Question asked: Mar 14 '08, 11:45 a.m.

Question was seen: 8,324 times

Last updated: Mar 14 '08, 11:45 a.m.

Confirmation Cancel Confirm