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:
However, this does not work on the client side. The only thing I can get is
This does not seem to provide API for finding out enough about license assignments for contributors.
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.
Accepted answer
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);
}
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
See https://rsjazz.wordpress.com/2017/03/29/managing-contributor-licenses-using-the-plain-java-client-libraries/ for how to get the ILicenseAdminService
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
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