It's all about the answers!

Ask a question

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


Jared Russell (1.3k12019) | asked Sep 04 '12, 10:26 a.m.
retagged Oct 04 '12, 5:06 p.m. by Guido Schneider (3.4k1383110)
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

Accepted answer


permanent link
Kevin Mayfield (4358) | answered Jun 07 '13, 11:32 a.m.
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

3 other answers



permanent link
sam detweiler (12.5k6185201) | answered Sep 04 '12, 11:27 a.m.
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)

permanent link
Florian Georg (19031918) | answered Jul 16 '13, 8:32 a.m.
edited Jul 16 '13, 8:33 a.m.
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.

Comments
Kevin Mayfield commented Jul 18 '13, 12:28 p.m.

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


Florian Georg commented Jul 18 '13, 3:54 p.m.

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
Ralph Schoon (60.5k33643) | answered Mar 29 '17, 8:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.