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

License & repo permission information using RTC Plain Java API ?

Is there a way to get a list of assigned licenses and repository roles (jazzUser, jazzAdmin ...) from the RTC Plain Java Client ?

I found some info for the server-side API:
 ILicenseAdminService licAdminService =             (ILicenseAdminService) ((TeamRepository) teamRepository).getServiceInterface(ILicenseAdminService.class);


However, this does not work on the client side. The only thing I can get is
teamRepository.getClientLibrary(ILicenseClient.class)
 
This does not seem to provide API for finding out enough about license assignments for contributors.



0 votes


Accepted answer

Permanent link
There isn't a client library for the license admin service, but your client code can invoke the remote service itself. In your client library, it would look something like this:

public IContributorLicenseType[] getLicenseTypes(IProgressMonitor monitor) throws TeamRepositoryException {
final ILicenseAdminService licenseAdminService = (ILicenseAdminService) clientLibraryContext.getServiceInterface(ILicenseAdminService.class);
return (IContributorLicenseType[]) clientLibraryContext.callCancelableService(new IClientLibraryContext.IServiceRunnable() {
public Object run(IProgressMonitor monitor) throws TeamRepositoryException {
return licenseAdminService.getLicenseTypes();
}
}, monitor);
}
Florian Georg selected this answer as the correct answer

0 votes

Comments

thanks, but from where do I get the "clientLibraryContext"  from your example?

All I have is an

com.ibm.team.repository.client.ITeamRepository
object, which for example provides
.getClientLibrary(Class)
.itemManager(),
.contributorManager()

 - but no "getServiceInterface(...)

If you are defining your own client library, an IClientLibraryContext gets passed to your factory class when the client library is instantiated.


If you aren't creating a client library (actually I'm not sure if you can do this with the plain Java client), a hack you can try is to just cast your ITeamRepository to an IClientLibraryContext. This isn't something that's officially supported as an API, but we have code doing this in the product and it's worked for 5+ years. So the risk of it being broken is very low.


2 other answers

Permanent link

 See https://rsjazz.wordpress.com/2017/03/29/managing-contributor-licenses-using-the-plain-java-client-libraries/ for how to get the ILicenseAdminService

0 votes


Permanent link
Hey ,

with the same context I am getting null pointer exception on line 3 of code below. remeber my teamRepository object is not null and logged in before I come to this line of code.
==============================================================
System.out.println("Logged In  "+teamRepository.loggedIn());
        IClientLibraryContext clientLibraryContext = (IClientLibraryContext) teamRepository.getClientLibrary(IClientLibraryContext.class);
        final ILicenseAdminService licenseAdminService = (ILicenseAdminService) clientLibraryContext.getServiceInterface(ILicenseAdminService.class);

==============================================================

it says
true
NULL pointer Exception.

============================================================

Am I missing something ?

Thanks -
Praveen

0 votes

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
× 10,930
× 169
× 51

Question asked: Jul 16 '13, 8:39 a.m.

Question was seen: 7,271 times

Last updated: Mar 29 '17, 8:23 a.m.

Confirmation Cancel Confirm