Hello,
I'm working on retrieving information from RTC repository. I've managed to successfully gather information from: add, modify, delete operations. Unfortunately I have no idea how to get any information from move and reparent changes.
here is sample of my code:
IVersionable before = versionableManager.fetchCompleteState(change.beforeState(), monitor);
IVersionable after = versionableManager.fetchCompleteState(change.afterState(), monitor);
String beforePath = getFilePath(before, workspaceConnection.configuration(changeSet.getComponent()), monitor, true);
String afterPath = getFilePath(after, workspaceConnection.configuration(changeSet.getComponent()), monitor, false)
where change is instance of IChange and versionableManager is IVersionableManager.
This part of code suppose to get information about relative path of file/directory before change has been made and relative path after change has occured.
private String getFilePath(IVersionableHandle folder, IConfiguration config, IProgressMonitor monitor, Boolean searchInHistory) throws TeamRepositoryException {
List lst = new ArrayList<IVersionableHandle>(), ancestors;
lst.add(folder);
if (searchInHistory) {
ancestors = config.determineAncestorsInHistory(lst, monitor);
} else {
ancestors = config.locateAncestors(lst, monitor);
}
return getFullPath(ancestors);
}
private String getFullPath(List ancestor) throws TeamRepositoryException {
String directoryPath = "";
for (Object ancestorObj : ancestor) {
IAncestorReport ancestorImpl = (IAncestorReport) ancestorObj;
for (Object nameItemPairObj : ancestorImpl.getNameItemPairs()) {
INameItemPair nameItemPair = (INameItemPair) nameItemPairObj;
String pathName = nameItemPair.getName();
if (pathName != null && !pathName.equals("")) {
directoryPath = directoryPath + "\\" + pathName;
}
}
}
return directoryPath;
}
Unfortunately instead of getting 2 different relative path, I'm getting same ones. What am I doing wrong?