It's all about the answers!

Ask a question

License & repo permission information using RTC Plain Java API ?


Florian Georg (19031818) | asked Jul 16 '13, 8:39 a.m.
edited Jul 16 '13, 8:40 a.m.
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.



Accepted answer


permanent link
Jared Burns (4.4k29) | answered Jul 16 '13, 11:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 16 '13, 11:36 a.m.
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

Comments
Florian Georg commented Jul 16 '13, 12:06 p.m.

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(...)


Jared Burns commented Jul 16 '13, 12:20 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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
praveen patidar (8612544) | answered Jul 07 '14, 9:58 p.m.
edited Jul 07 '14, 9:59 p.m.
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


permanent link
Ralph Schoon (56.0k23642) | answered Mar 29 '17, 8:23 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.