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

Is it possible to retrieve license information using the plain java API?

Using the plain java API I'd like to get information about what licenses a particular IContributor has assigned to them. Looking at the javadocs, the ILicenseAdminService interface provides the methods I'm after, however as far as I can tell this is only available to server side participants because calling ITeamRepository#getClientLibrary(ILicenseAdminService.class) returns null.

Is there any way of getting a handle to an ILicenseAdminService instance using the client-side java API, or are there any alternative APIs that would allow me to achieve the same result?

Thanks

0 votes


Accepted answer

Permanent link
Here is some code I am using on the client to allocate a license
   
public boolean allocateLicense(Contributor contributor, String license) throws Exception
    {
        ITeamRepository teamRepository = getTeamRepository();  // However you are getting access to this...
        ILicenseAdminService licAdminService =
            (ILicenseAdminService) ((TeamRepository) teamRepository).getServiceInterface(ILicenseAdminService.class);

        if (contributor == null)
        {
            throw new Exception("Contributor is null");
        }
        
        if (license == null)
        {
            System.err.println("Invalid license");
            throw new Exception("Invalid license");
        }
        
        licAdminService.assignLicense(contributor, license);
        return true;
    }
Ralph Schoon selected this answer as the correct answer

0 votes


3 other answers

Permanent link
from the client side it would be in the SDK\plugins  folder, com.ibm.team.repository.common.

because its in the common jar, its usable by both (typically)

1 vote


Permanent link
This does not work with the RTC Plain Java API.
There's something like
repository.getClientLibrary(ILicenseClient.class)
.. however, it does not seem to be too useful.

0 votes

Comments

it works for me.  I wrote getTeamRepository() method, but the rest is Plain Java lib calls.

Found out - the trick is that you have to do a cast to internal API:
Your instance of

com.ibm.team.repository.client.ITeamRepository

must be cast to
com.ibm.team.repository.client.internal.TeamRepository
as this implements com.ibm.team.repository.client.util.IClientLibraryContext.


Then the necessary method getServiceInterface(Class) will be available and works as described above.

This took me some time to figure out and is not nice, as it depends on internal non-public API.



Permanent link

 Here a working example with downloadable code: https://rsjazz.wordpress.com/2017/03/29/managing-contributor-licenses-using-the-plain-java-client-libraries/

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,941
× 110

Question asked: Sep 04 '12, 10:26 a.m.

Question was seen: 5,662 times

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

Confirmation Cancel Confirm