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

Get the full path of FileItem

I have the following IConfiguration that I fetched by the following:

=========================================

IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);

IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();

wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);

wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName);

List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, Application.getMonitor()); 

IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),Application.getMonitor());

IComponentHandle component = changeSet.getComponent();

IConfiguration configuration = workspaceConnection.configuration(component);

List lst = new ArrayList<String>();

lst=configuration.locateAncestors(lst,Application.getMonitor());

=========================================

Now I need to get the full path of the file item and I made the following method I get from :

https://jazz.net/forum/questions/94927/how-do-i-find-moved-from-location-for-a-movedreparented-item-using-rtc-4-java-api

=========================================

private String getFullPath(List ancestor, ITeamRepository repository)

throws TeamRepositoryException {

String directoryPath = "";

for (Object ancestorObj : ancestor) {

IAncestorReport ancestorImpl = (IAncestorReport) ancestorObj;

for (Object nameItemPairObj : ancestorImpl.getNameItemPairs()) {

NameItemPairImpl nameItemPair = (NameItemPairImpl) nameItemPairObj;

Object item = SCMPlatform.getWorkspaceManager(repository)

.versionableManager()

.fetchCompleteState(nameItemPair.getItem(), null);

String pathName = "";

if (item instanceof IFolder) {

pathName = ((IFolder) item).getName();

}

else if (item instanceof IFileItem) {

pathName = ((IFileItem) item).getName();

}

if (!pathName.equals(""))

directoryPath = directoryPath + "\\" + pathName;

}

}

return directoryPath;

}

=========================================

However,nothing is appeared !

Thanks in advance.

1

0 votes


Accepted answer

Permanent link
Is there a typo in the following code?

List lst = new ArrayList<string>();

lst=configuration.locateAncestors(lst,Application.getMonitor());

The first parameter to IConfiguration#locateAncestors() should be a list of versionable handles representing the versionables whose ancestors you want to locate (i.e. your FileItem).  However, the code above appears to be passing it a freshly-allocated empty list.  Under those circumstances, getting no results back wouldn't be too surprising :-)
Fatla 777 selected this answer as the correct answer

1 vote

Comments

That's not a typo ... that's stupidity :)

Sorry and thanks again:)

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: Feb 22 '13, 3:30 p.m.

Question was seen: 7,355 times

Last updated: Feb 22 '13, 5:24 p.m.

Confirmation Cancel Confirm