It's all about the answers!

Ask a question

Fetch files from repository


Giacomo Ghezzi (161) | asked Mar 14 '08, 11:45 a.m.
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

2 answers



permanent link
John Camelon (1.7k14) | answered Mar 14 '08, 4:02 p.m.
JAZZ DEVELOPER
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

permanent link
Giacomo Ghezzi (161) | answered Mar 15 '08, 10:10 a.m.
Thanks, that worked
cheers
Giacomo

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.