How to get the content of a change set, which is linked to a work item, exactly how it is visible in the RTC web client using Jazz SDK ver. 5.0.2.05
Accepted answer
Comments
Hello, Geoffrey.
Thanks for your response!
I managed to implement it exactly as you suggest. I found an "extra info" string (from com.ibm.team.links.common.IReference#getExtraInfo()) and get the workspace from there.
Now I have another issue though. Whenever I try to access the workspace, but do not have permissions for it, then I catch a "PermissionDenied" exception. However Team Advisor automatically appears in RTC reporting to the user about it.
Is it possible to disallow the advisor to appear?
In my code I check if I can access the workspace. If I don't have permissions then I will not show any file path, but don't want the end user understands what the internal logic does.
Thanks!
You can only try to catch the Exceptions. Try to catch very high level such as RuntimeException, Throwable,... the advisor should not show an exception if it is not thrown.
It looks like WorkspaceManager.getWorkspaceConnection(..) implicitly shows the Team Advisor view
Then it passes the "PermissionDeniedException" to the caller.
I have tried to outline the method invocations below and inserted some comments (see Step 1 to 7 in the code - I have put the code as an answer in this topic as the number of characters exceed the allowed limit here )
Is there a way to avoid the internal call of the Team Advisor view?
I want to check if I can get a workspace and fetch the CS file paths.
If I encounter an error (including an exception such as PermissionDeniedException) I will not show the file paths.
However I don't want the plug-in users to receive information by the team advisor view exactly how it is implemented in RTC
That is, if the file paths cannot be found (i.e. there is no workspace context) then file paths are substituted with <unknown>\file.c, for example.
2 other answers
Comments
I am sure there are ways to do that, since the RTC Client does it, but I don't know how and have no examples.
What i know is here: https://rsjazz.wordpress.com/2013/10/15/extracting-an-archive-into-jazz-scm-using-the-plain-java-client-libraries/ and the other direction is described here http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html both work on workspaces that are not loaded, but access the relative path.
Thanks a lot!
Best Regards,
K. Malchev
1) my code tries to get a workspace connection (context) in order to get the full path of all changed files in a changeset: wsManager.getWorkspaceConnection(...)
2) com.ibm.team.scm.client.internal.WorkspaceManager.getWorkspaceConnection(...) calls getServerConfigurationService().refreshWorkspaces(...)
3) getServerConfigurationService().refreshWorkspaces(...) calls com.ibm.team.scm.client.internal.ScmServiceInterfaceProxy.invoke(...)
4) ScmServiceInterfaceProxy.invoke(...) calls ScmServiceInterfaceProxy.invokeCancelableService(...);
4.1. ScmServiceInterfaceProxy.invokeCancelableService(...) throws a PermissionDeniedException
4.2. ScmServiceInterfaceProxy.invoke(...) catches the exception
4.2.1. shows Team Advisor view using the notifyProcess(...) (see Step 4 in the code below)
4.2.2. and finally passes the exception to the caller IWorkspaceConnection getWorkspaceConnection(...) (see Step 5 in the code below)
5) IWorkspaceConnection getWorkspaceConnection(...) passes the exception to my code which is processed as well. (see Step 7 in the code below)
My plug-in code:
....
try {
if(wsHandle != null) {
// Step 1: IWorkspaceConnection getWorkspaceConnection(...) is executed
IWorkspaceConnection wsConn =
wsManager.getWorkspaceConnection(
(IWorkspaceHandle) wsHandle,
child.newChild(25));
...
}//if
...
}//try
catch(Throwable e) {
// Step 7: The exception PermissionDeniedException is processed here as well
System.out.println("Throwable: " + e.getMessage());
return result;
}
================================================
class: com.ibm.team.scm.client.internal.WorkspaceManager
public IWorkspaceConnection getWorkspaceConnection(
IWorkspaceHandle workspace,
IProgressMonitor monitor) throws TeamRepositoryException {
// Step 6: The exception is passed to the caller - my plug-in code
...
if (conn == null) {
// Step 2: getServerConfigurationService().refreshWorkspaces(...) is executed.
// It calls ScmServiceInterfaceProxy. invoke(...)
WorkspaceRefreshResult refreshed = getServerConfigurationService().refreshWorkspaces(
new WorkspaceRefreshParameter[]{createEmptyWorkspaceRefreshParameter(workspace)},
SCMClientUtil.monitorFor(monitor))[0];
...
}
========================================================
//Proxy helper which wraps all RPC service interface objects to common progress monitoring and
cancellation support
class: com.ibm.team.scm.client.internal.ScmServiceInterfaceProxy
public Object invoke(Object proxy, final Method method, final Object[] args)
throws Throwable {
try {
...
// Step 3: ScmServiceInterfaceProxy.invokeCancelableService(...) is executed.
// it throws PermissionDeniedException which is processed in ScmServiceInterfaceProxy. invoke(...)
returnVal = invokeCancelableService(method, args, monitor);
...
} catch (Throwable e) {
TeamRepositoryException tre = null;
...
tre = (TeamRepositoryException)e;
...
if (tre != null) {
// Step 4: The exception is caught and Team Advisor is shown here
// with the error message: Team Advisor Problem: Permission denied during
// "Source Control Operation". User '...' does not have permission to read workspace '...'
// The exception is still thrown so that clients can
// clean-up and react accordingly.
if(!calledByTeamAdvisorView &&
(tre instanceof TeamOperationCanceledException
|| tre instanceof PermissionDeniedException)) {
notifyProcess(tre, method); // shows TeamAdvisor view informing PermissionDeniedException error
}
// Step 5: The exception is passed to the caller
throw tre;
}//end of if (tre != null)
} //end of invoke method
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 10 '16, 5:20 a.m.Even the code review IBM provides in RTC 6.0.1 needs a stream to be selected to provide the path. I don't think that you can do what they can't. They have a work item context as well in their review.
Krasimir Malchev
May 10 '16, 5:42 a.m.Hello, Ralf.
That is being said, it is not possible to get the full paths of the files in a change set exactly how they are shown in RTC web client, as we don't have a context (baseline, stream, workspace)?
Anyway I am wondering how RTC knows this information (it provides the full paths). I wanted to attach a screenshot to visually present what I mean but I am not able to attach a file as I don't have enough reputation (>60) in this forum.
Is it possible that RTC 5.0.2.005 takes a default / current configuration somehow to show the file paths?
Thanks a lot for your assistance!
Regards,
K. Malchev
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER May 10 '16, 5:51 a.m.I don't have the slightest idea, to be honest. I have followed similar discussions and basically our development says it can't be done. I wonder what the web UI shows and how. You can upload the image to a different site and put a link into your post.
Krasimir Malchev
May 10 '16, 9:33 a.m.Hello Ralf,
A folder with 3 files is uploaded here: https://drive.google.com/folderview?id=0B29oETNDToVTclNVOXNFQ0RSVjQ&usp=sharing
The first file shows the related CS in the "Links" tab of a work item of type "Task" in the web client.
If I hover the mouse over the CS, its URL is shown in the browser status bar. The URL contains the IDs of the PA and a workspace.
It looks like either the web client stores a workspace or a default/current one is used?
The second file shows the contents of the CS using the selected WS configuration - BTO__fpf.src.dev.
The third file shows the contents of the CS related to the same work item in the RTC desktop client. As no configuration is specified the files and folders in the CS are grouped by their parent folder which is "unresolved" .
Q: How can I get and group the files and folders by their parent folder (as shown in the third file)?
Thanks a lot!