how get Full path of the File from changeset Using API?
I m able to get the name of the file attached with the change set. But not able to get the API to get the Folder path of the file system.
for (IChangeSet changeset : changesets) {
System.out.println("Change Set ITEM_ID_PROPERTY "
+ changeset.getItemId());
List changes = changeset.changes();
for(Object change : changes)
{
Change aChange = (Change)change;
if(aChange.item() instanceof IFileItemHandle)
{
IFileItemHandle fileItemHandle = (IFileItemHandle)aChange.afterState();
IFileItem fileItem = (IFileItem)SCMPlatform.getWorkspaceManager(clientUtil.getTeamRepository()).versionableManager().fetchCompleteState(fileItemHandle,null);
System.out.println("File Name :"+fileItem.getName());
}
}
What my approach is to create an text file that can be used for Load rule file for the SCM CLI. I wan to create this file using the API so that I can access the remote workspace.
for (IChangeSet changeset : changesets) {
System.out.println("Change Set ITEM_ID_PROPERTY "
+ changeset.getItemId());
List changes = changeset.changes();
for(Object change : changes)
{
Change aChange = (Change)change;
if(aChange.item() instanceof IFileItemHandle)
{
IFileItemHandle fileItemHandle = (IFileItemHandle)aChange.afterState();
IFileItem fileItem = (IFileItem)SCMPlatform.getWorkspaceManager(clientUtil.getTeamRepository()).versionableManager().fetchCompleteState(fileItemHandle,null);
System.out.println("File Name :"+fileItem.getName());
}
}
What my approach is to create an text file that can be used for Load rule file for the SCM CLI. I wan to create this file using the API so that I can access the remote workspace.
3 answers
There are several similar recent questions with answers in the forum. Does any of them help?
Comments
1 vote
This is how you find the path:
Notice that versionableHandles is a List of versionableHandle, which mean that it will return a List of IAncestorReport corresponding to the versionableHandles.
List<IVersionableHandle> versionableHandles = getVersionableHandlesFromSomewhere(); List<IAncestorReport> ancestorReports = configuration.locateAncestors(versionableHandles, monitor);
//Lets get the path of the first one, corresponding to the first versionable
IAncestorReport iAncestorReport = ancestorReports.get(0);
List<INameItemPair> reportList = iAncestorReport.getNameItemPairs();
String filePath = "" ;
for (INameItemPair iNameItemPair : reportList){
String temp = iNameItemPair.getName();
if (temp != null) {
filePath += "/" + temp ;
}
}
System.out.println(filePath);
That's it.