It's all about the answers!

Ask a question

java api, how to get an IInteropManager obj. from repository


Chris Ratcliffe (2633330) | asked Oct 28 '10, 12:55 p.m.
Hi,

I am trying to write an external application that will allow me to automatically keep my ClearQuest to RTC synchronization rule for userid mapping up to date. I know that I need to get a handle on the particular ISyncRule object, and I can use the importDefinition method to refresh it from a .xml file, and I know that I can use the findSyncRule method of the IInteropManager object to get a handle on the sync rule. The problem is, I am having trouble determining what APIs I need to use to get from the ITeamRepository object to the IInteropManager object. I looked at the method of the ITeamRepository, and I don't see anything that looks right. Any help would be appreciated.

Thanks,
Chris

6 answers



permanent link
sam detweiler (12.5k6195201) | answered Oct 28 '10, 2:17 p.m.
here is my code



ITeamRepository repo = login(sPm);
// get operations handle to repository
IInteropManager interop = (IInteropManager) repo.getClientLibrary(IInteropManager.class);

URI uri = URI.create(IssuePrefix+problemNumber);
IExternalProxy proxy = createExternalProxy(repo, uri, sPm);
IExternalState externalState = InteropFactory.INSTANCE.createExternalState();
ISyncRule sr = ((IInteropManager) repo.getClientLibrary(IInteropManager.class)).findSyncRule(syncrule_name_string,sPm);
proxy=(IExternalProxy)proxy.getWorkingCopy();
proxy.setSyncRule(sr);


and the login method gets the repository handle like this

ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(REPOSITORY_ADDRESS);

where REPOSITORY_ADDRESS = "http://server_url/jazz"

permanent link
Chris Ratcliffe (2633330) | answered Oct 28 '10, 2:44 p.m.
That's great, than you very much. I will give it a try.

permanent link
Chris Ratcliffe (2633330) | answered Oct 29 '10, 9:13 a.m.
Perfect, it works. Thanks.

permanent link
Chris Ratcliffe (2633330) | answered Dec 01 '10, 10:20 a.m.
Sorry, I spoke a little too soon. My code to export out the sync rule is working fine, but the code to import doesn't seem to be working. Here is what I have:


public static void importSyncRule(ISyncRule syncRule, IProgressMonitor monitor) throws TeamRepositoryException
{
// use the ISyncRule.importDefinition method to import the xml definitions for the sync rule
String inputFile = syncRuleName + ".xml";
System.out.println("Importing sync rule: " + syncRuleName + " from file " + inputFile);
try {
// get a working copy
syncRule = (ISyncRule) syncRule.getWorkingCopy();

FileReader input = new FileReader(inputFile);

syncRule.importDefinition(input);
syncRule.save(monitor);
} catch (FileNotFoundException e3) {
System.out.println("Error: " + e3.getMessage());
// throw new TeamRepositoryException();
}
}


The syncRule.save(monitor) line doesn't compile properly because the ISyncRule class and none of its parent classes implement that method I guess, but I see references to a save() method in some of the documentation, through it is unclear how it applies. If I take out the .save() call, it compiles and runs without any errors, but of course, the changes aren't committed to the repository.

I realize that my code is not the same as yours exactly, mainly because I don't understand what the proxy or uri objects are used for, or even how to properly generate the URI object. Is it not possible to do an inplace update to the sync rule? I thought that was what the .getWorkingCopy method gave me the ability to do, but perhaps not.

permanent link
John Vasta (2.6k15) | answered Dec 01 '10, 5:03 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
To save a working copy of an ISyncRule item, use the saveSyncRule method in the IInteropManager interface.

permanent link
Chris Ratcliffe (2633330) | answered Dec 02 '10, 10:16 a.m.
Thanks John, that worked.

Your answer


Register or 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.