How to retrieve the latest ChangeSet/UUID/version-number of a project/file (residing on Jazz server) along with its contents and then locate that project/file from that version-number
Hi All,
I am just started understanding on RTC Java Plain libraray 5.0.2. Also I am very much familiar about the SVN functionality.
I want to know :----
I am using this code to locate a file by its name only....
private static IVersionableHandle findFile(IFolderHandle root,
IConfiguration iconfig, String fileName, IProgressMonitor monitor)
throws TeamRepositoryException
{
String fileNamePath[] = { fileName };
IVersionableHandle filePathHandle = null;
// Check if file at this folder level
filePathHandle = iconfig.resolvePath(root, fileNamePath, monitor);
if (filePathHandle != null)
{
return filePathHandle;
}
// Check this file sub folders
@SuppressWarnings("unchecked")
Map<String, IVersionableHandle> childEntries = iconfig.childEntries(root, monitor);
for (Map.Entry<String, IVersionableHandle> next : childEntries.entrySet())
{
IVersionableHandle nextVersionable = next.getValue();
if (nextVersionable instanceof IFolderHandle)
{
filePathHandle = findFile((IFolderHandle)nextVersionable, iconfig, fileName, monitor);
if (filePathHandle != null)
{
//System.out.println("Found file " + fileName);
break;
}
}
}
return filePathHandle;
}
public static String readFileContent(IWorkspaceHandle streamHandle,
IComponentHandle componentHandle, ITeamRepository repo,
String fileName, IProgressMonitor monitor)
throws TeamRepositoryException, IOException
{
IFileItem fileItem = null;
IFileContentManager contentManager = FileSystemCore.getContentManager(repo);
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repo);
IWorkspaceConnection streamConnection = workspaceManager.getWorkspaceConnection(streamHandle, monitor);
// Find file handle
IConfiguration iconfig = (IConfiguration)streamConnection.configuration(componentHandle);
//IFolderHandle root = iconfig.completeRootFolder(monitor);
IFolderHandle root = iconfig.rootFolderHandle(monitor);
System.out.println("********************* Searching for file " + fileName);
IVersionableHandle filePathHandle = findFile(root, iconfig, fileName, monitor);
// Check if file found
if (filePathHandle == null)
{
throw new FileNotFoundException("********************** File not found.");
}
else
{
System.out.println("*********************** Found file: " + fileName);
}
// Fetch file complete item
IVersionable filePath = (IVersionable)iconfig.fetchCompleteItem(filePathHandle, monitor);
if (filePath.hasFullState())
{
fileItem = (IFileItem)filePath.getFullState();
}
else
{
throw new TeamRepositoryException("Could not find file item");
}
// Get file content
IFileContent content = fileItem.getContent();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
contentManager.retrieveContent(fileItem, content, outputStream, monitor);
String readContent = null;
readContent = outputStream.toString("UTF-8");
System.out.println("Contents of " + filePath.getName() + "++++++++++++++++++++++++++++++++++++++++++++.");
System.out.println(readContent);
return readContent;
}
Thanks in advance
|
One answer
Thanks for understanding the problem.
Actually in an application, I can fetch/chekout the source of a project/file (inside a project) with a particular revision number by using SVNKit APIs very easily.
The same this I want to do for RTC by using Rational Team Concert Java API download: https://jazz.net/downloads/rational-team-concert/releases/5.0.2?p=allDownloads.
Now I am able to do the following task by Java code as:
- Get a list of all projects under a work-space of Jass server for a particular user
- Get a full sources checkout of any project
But I need to do the following more:
- How to see and fetch, if there is any update on that project, which I have already checked-out or known by the name
- And how to see/get, if there is any update in source of a text-file, committed by other developers of that project.
Please tell, if this is possible by Java code similar to SVN functionality.
Comments
Geoffrey Clemm
commented Feb 06 '15, 12:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
A couple of comments:
Yes, exactly I mean "are there any incoming changes to that file from the stream identified as the current flow target of the workspace"?
What's your goal? Why are you trying to do this? I ask because the tasks you are describing seem very similar to subcommands available in the CLI.
Can you achieve the same thing by loading the user's repository workspace? What are you going to do with the full source after you get it?
|
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.
Comments
Can you tell me more about your use case?
Hi Evan, please see the more details of my problem below.