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

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

0 votes



6 answers

Permanent link
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"

0 votes


Permanent link
That's great, than you very much. I will give it a try.

0 votes


Permanent link
Perfect, it works. Thanks.

0 votes


Permanent link
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.

0 votes


Permanent link
To save a working copy of an ISyncRule item, use the saveSyncRule method in the IInteropManager interface.

0 votes


Permanent link
Thanks John, that worked.

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,943

Question asked: Oct 28 '10, 12:55 p.m.

Question was seen: 6,194 times

Last updated: Oct 28 '10, 12:55 p.m.

Confirmation Cancel Confirm