java api, how to get an IInteropManager obj. from repository
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
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
here is my code
and the login method gets the repository handle like this
where REPOSITORY_ADDRESS = "http://server_url/jazz"
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"
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:
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.
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.