It's all about the answers!

Ask a question

Get the full path of FileItem


0
1
Fatla 777 (263712) | asked Feb 22 '13, 3:30 p.m.
edited Feb 22 '13, 3:51 p.m.

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.

Accepted answer


permanent link
John Riendeau (46626) | answered Feb 22 '13, 4:16 p.m.
JAZZ DEVELOPER
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

Comments
Fatla 777 commented Feb 22 '13, 5:24 p.m.

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

Sorry and thanks again:)

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.