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

[Java] Get the full path of a file at change set

Hello,
I am searching for a NEW CREATED ,not edited yet, .txt file that is located at change set WITHIN a specific work item.
Then I need to create locally over my pc  the full path directory of this file.

For example if there a file called"test.txt" that it's located at:
Project1-->Folder1-->Folder2-->test.txt

Till now I have managed to search for this file.
Now I need to fetch the full directory and create similar one over my pc:
Result at my pc:
Folder1-->Folder2-->test.txt

That's what I did to search for the file within a changeset:

    public IFileItem getTextFileFile(IChangeSet changeSet, ITeamRepository repository) throws TeamRepositoryException{
        IVersionableManager vm = SCMPlatform.getWorkspaceManager(repository).versionableManager();
        List changes = changeSet.changes();
        IFileItem toReturn = null;
        for(int i=0;i<changes.size();i++) {
            Change change = (Change) changes.get(i);
            IVersionableHandle after = change.afterState();
            if( after != null && after instanceof IFileItemHandle) {
                IFileItem fileItem = (IFileItem) vm.fetchCompleteState(after, null);
                if(fileItem.getName().contains(".txt")) {
                       toReturn = fileItem;
                       break;
                } else {
                   continue;
                }
            }
        }
        if(toReturn == null){
            throw new TeamRepositoryException("Could not find the file");
        }
        return toReturn;
    }

Thanks in advance.

0 votes



One answer

Permanent link
This has already been answered in other questions. I've posted a reply to your followup in one of the other questions. If you have any questions about those answers, please clarify because you haven't provided here what went wrong with your attempts given those answers.

0 votes

Comments

Thanks Tim.
I have updated the other question as well.
Sorry for inconvenience.

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,936
× 411

Question asked: Feb 20 '13, 12:22 p.m.

Question was seen: 8,865 times

Last updated: Feb 21 '13, 3:30 p.m.

Confirmation Cancel Confirm