Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get User ID who has loaded RTC component to sandbox ?

We are trying to fetch the user details who has loaded the RTC component into sandbox (Local Workspace).
Is the below approach correct? or do we have any better way to get the user details?

Thanks in advance.


try {
TeamPlatformUtils.startupTeamPlatform();

      ITeamRepository teamRepository =
          accessProvider.logIn(RepositoryURL, new NullProgressMonitor());

      final IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(teamRepository);

      final IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(
          (IWorkspaceHandle) connectionHandle, new NullProgressMonitor());

      IAuditableHandle auditableHandle = workspaceConnection.getOwner();

      final IContributor contributorDetails = RTCUtils.getCompleteItem((IContributorHandle) auditableHandle,
          IContributor.class, false, teamRepository, new NullProgressMonitor());

      this.loggerStorage.getLogger().info("Component Owned By User ID - " + contributorDetails.getUserId());
    }
finally {
      TeamPlatformUtils.shutdownTeamPlatform();
    }

1

0 votes

Comments

 I would like to rephrase the question here!. We were actually looking for the user who is owning the repository workspace and with the help of the above code snippet it is possible to get the repository owner and not the User ID who loaded the repository workspace to sandbox. 


Accepted answer

Permanent link
With your added comment it looks like you are just trying to get the owner of the repository workspace (and not really who loaded it into some arbitrary sandbox location).

Your code would work for that purpose, however fetching the IWorkspaceConnection (using workspaceManager.getWorkspaceConnection) is a little heavy-weight for what you are trying to achieve. This is because the IWorkspaceConnection has to compute a lot of other details (such as the component hierarchy) that would not be needed if the only thing you care about is the workspace owner.

Just like you are already fetching the full IContributor from a given IContributorHandle, you would fetch the full IWorkspace from the IWorkspaceHandle. Once you have the IWorkspace, you would use workspace.getOwner() and use that to fetch the IContributor. Note: Streams and repository workspaces are both IWorkspace instances. So
the .getOwner() call will always return an IProcessAreaHandle, and it will always return an IContributorHandle for repository workspaces (something to keep in might to avoid possible ClassCastExceptions if your code might even have Streams in the future...)

Another minor note is that your code snippet says: "Component Owned By User ID - " when you probably mean to write: "Repository workspace owned by user ID - "
Praveen Kalawad selected this answer as the correct answer

0 votes

Comments

Thanks for your input David.


One other answer

Permanent link

 That gets you the owner of the workspace connection and not the user who loaded something into a sandbox.

0 votes

Comments

 Thank You, Ralph for your quick response.

Could you please give us a clue to get the right details(i.e) who has loaded to sandbox.

Thanks in advance.

Sorry, I can't I have never looked into that and I am not even sure if that is information that is available. 

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 1,700

Question asked: Oct 09 '18, 4:00 a.m.

Question was seen: 1,125 times

Last updated: Oct 10 '18, 5:27 a.m.

Confirmation Cancel Confirm