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
Krasimir Malchev (56●6●31)
| asked May 10 '16, 4:39 a.m.
edited Jun 08 '16, 1:29 p.m. by David Lafreniere (4.8k●7)
Environment: RTC 5.0.2 ifix05
How can I get the content of a change set (including the full file paths), which is linked to a work item, exactly how it is visible in the RTC web client using Jazz SDK?
I have searched for an answer in internet and found a lot of results.
Though, I was not able to get a satisfactory solution of this question.
In particular, I want to get the full path of a file (but not only its name), since a file with the same name may be present and changed in several folders.
I found that a change set doesn't contain the full file paths (https://jazz.net/forum/questions/135072/unknown-showing-up-on-workspace-in-rtc), because a given change set can be used by multiple configurations.
However the full file path is present in the RTC 5.0.2 web client by opening the linked change set through a given work item. Therefore I assume it has to be possible to get the same information using the Jazz SDK for RTC 5.0.2.05.
Can I get a reference to the related configuration to show same information present in RTC (including the full paths)?
I need that to update an RTC peer review plugin used by the development departments in the company I am working for.
Thank you for your support!
Best Regards.
|
Accepted answer
Geoffrey Clemm (30.1k●3●30●35)
| answered Jun 07 '16, 10:28 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
As I recall, when a change set is linked to a work item, if there is a "current" workspace at the time of linking, a reference to that workspace is added as a property on that link. Then if a pathname for a member of that change set is requested, some of the clients will check to see if there is a link from that change set to a work item, and if so, they will check to see if that link has that workspace property, and if it does, use that workspace to determine a pathname for that file.
Krasimir Malchev selected this answer as the correct answer
Comments
Krasimir Malchev
commented Jun 08 '16, 1:11 a.m.
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.
Krasimir Malchev
commented Jun 14 '16, 4:37 a.m.
It looks like WorkspaceManager.getWorkspaceConnection(..) implicitly shows the Team Advisor view
|
2 other answers
Hello, Ralf.
It looks like the RTC desktop client picks the repository workspace which has been currently loaded, and displays the path of the files in that workspace (if the files exist in that workspace).
If no workspace is loaded then Eclipse asks us to specify a context (of a stream or repository workspace) as it is shown in the third screenshot in the above post of mine.
In the case of the RTC Web client, the context (in which the change set is created) is enclosed in the URI of the changeset as shown in the second screenshot.
If we assume that the above assumptions are correct, then using the Jazz SDK:
- Is there a way to get the currently loaded workpsace by the current user in the Eclipse client?
- Is there a way to get changeset URI and look for a workspace/stream name if there is such?
- In case that I have specified a context in the change explorer view of the Eclipse client as shown in the screenshots, then is there a way to get it from there?
- How can I traverse the changes in changeset linked to a given workitem, and generate a folder structure with the modified/deleted/added files and folders?
Are there any web tutorials?
Thanks a lot for your time and assistance!
Best Regards!
Comments
Ralph Schoon
commented May 13 '16, 3:07 a.m.
| edited May 13 '16, 3:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.
You can find information on the web, but maybe not what you are looking for and besides what some people like me do there are no tutorials. The RTC SDK/API is a by product of product development and there is few information.
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.
You can try to find the view class for the pending changes view, as that shows the loaded workspaces and components.
Krasimir Malchev
commented May 13 '16, 3:16 a.m.
Thanks a lot!
Best Regards, K. Malchev |
My Analysis showing why Team Advisor pops up with a PermissionDeniedException regardless I catch the exception:
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 |
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
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.
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
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.
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!