an exception when unassign a licesne i get com.ibm.team.repository.service.compatibility.util.http.CrossServerHttpClient$RestCommunicationException
eran meiri (21●5●12)
| asked Apr 13 '15, 2:08 a.m.
edited Apr 13 '15, 5:04 a.m. by Ralph Schoon (63.5k●3●36●46)
hello , I am trying to unassign a license and getting this exception:
com.ibm.team.repository.service.compatibility.util.http.CrossServerHttpClient$RestCommunicationException
this is my code:
NullProgressMonitor monitor = new NullProgressMonitor();
LoginHandler login = new LoginHandler("????", "?????");
teamRepository.registerLoginHandler(login);
try {
teamRepository.login(monitor);
} catch (TeamRepositoryException e) {
e.printStackTrace();
System.out.print("this is not good");
}
ILicenseAdminService licenseAdmin = (ILicenseAdminService) ((TeamRepository) teamRepository).getServiceInterface(ILicenseAdminService.class);
System.out.print(licenseAdmin.toString());
//IContributorManager contributorManager = teamRepository.contributorManager();
IContributorHandle aUser;
try {
aUser = teamRepository.contributorManager().fetchContributorByUserId("user_id", null);
licenseAdmin.unassignLicense(aUser, "_0yFhJOGeEeSqbuNMcGcLkA"); // - exception !!
} catch (TeamRepositoryException e1) {
System.out.print(e1.toString());
e1.printStackTrace();
}
many thanks
|
4 answers
Ralph Schoon (63.5k●3●36●46)
| answered Apr 13 '15, 5:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Apr 13 '15, 5:13 a.m.
Dependent of this being a client side automation or a server extension the call to get the license manager would be:
Client API: ILicenseAdminService licAdin = (ILicenseAdminService)teamRepository.getClientLibrary(ILicenseAdminService.class); licAdin.unassignLicense(contributorHande, licenseId); Server API (assuming you extend AbstractService): ILicenseAdminService licAdin = this.getService(ILicenseAdminService.class); licAdin.unassignLicense(contributorHande, licenseId); Provided the license ID would be valid, I would assume that this works. Comments
eran meiri
commented Apr 13 '15, 5:43 a.m.
thanks for the answer. the problem is that if I make the change you mentioned I get a null reference to the ILicenseAdminService object. I am using client api...
thanks again |
Ralph Schoon (63.5k●3●36●46)
| answered Apr 13 '15, 6:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Fascinating and you are right. The LicenseAdminService does not seem to be a regular client library and getClientLibrary does not work.
This code works for me: ILicenseAdminService licAdin = (ILicenseAdminService) ((IClientLibraryContext) teamRepository).getServiceInterface(ILicenseAdminService.class); IContributor licenseUser = teamRepository.contributorManager().fetchContributorByUserId(licenseuser, monitor); licAdin.unassignLicense(licenseUser, licenseID); Where the user licenseuser is the ID as string, and licenseID is something like "com.ibm.team.rtc.developer". I got the licenseID's this way: /** * Build the license map only once * * @param licenseService * @param monitor * @return * @throws TeamRepositoryException */ private static HashMap Comments
eran meiri
commented Apr 13 '15, 7:36 a.m.
it is not working for me. the
unassignLicense method is part of the ILicenseAdminService so I can't call it from the LicenseAdminLibrary. I can't import the LicenseAdminLibrary so I can't even test to see if the method is in there.
is it working for you that way? |
Ralph Schoon (63.5k●3●36●46)
| answered Apr 13 '15, 7:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This is my working code:
I call it with parameters: "https://clm.example.com:9443/jts" "adminID" "adminPasswd" "userToDeleteLicense" "com.ibm.rtc.developer-iep.floating" I use ILicenseAdminService as you did above. Note, it apears NOT to be a typical ClientLibrary, so you need to get it with the code you show in your original question. /******************************************************************************* * Licensed Materials - Property of IBM * (c) Copyright IBM Corporation 2008. All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *******************************************************************************/ package com.ibm.team.workitem.ide.ui.example; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import com.ibm.team.repository.client.ITeamRepository; import com.ibm.team.repository.client.ITeamRepository.ILoginHandler; import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo; import com.ibm.team.repository.client.TeamPlatform; import com.ibm.team.repository.client.util.IClientLibraryContext; import com.ibm.team.repository.common.IContributor; import com.ibm.team.repository.common.ILicenseAdminService; import com.ibm.team.repository.common.TeamRepositoryException; /** * Example code, see * https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation. */ public class LicenseDelete { private static class LoginHandler implements ILoginHandler, ILoginInfo { private String fUserId; private String fPassword; private LoginHandler(String userId, String password) { fUserId = userId; fPassword = password; } public String getUserId() { return fUserId; } public String getPassword() { return fPassword; } public ILoginInfo challenge(ITeamRepository repository) { return this; } } public static void main(String[] args) { boolean result; TeamPlatform.startup(); try { result = run(args); } catch (TeamRepositoryException x) { x.printStackTrace(); result = false; } finally { TeamPlatform.shutdown(); } if (!result) System.exit(1); } private static boolean run(String[] args) throws TeamRepositoryException { if (args.length != 5) { System.out .println("Usage: LicenseDelete |
still no go. I still get the original error CrossServerHttpClient$RestCommunicationException with a cause reason null. here is my code :
Comments
Ralph Schoon
commented Apr 13 '15, 10:04 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I can only tell you, that my code works for me. Try to set up a test system on Tomcat and Derby. Have a look into your server logs to try to figure out what the issue is.
|
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.