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

How to programmatically update Process Configuration Source

After found this post (https://jazz.net/forum/questions/6862/where-is-the-xml-file-saved-for-process-configuration-source/6865) from the Jazz Process Team:
We don't have any support for importing into an existing project area, 
though. If you want to change the process configuration source of 
multiple project areas to be the same, you'll currently have to 
copy/paste in the project area editor.
We tried to write a Plain Java Client to programmatically update all existing project areas in our repository.
First we retrieved the Process Configuration Source from a process template:
ITeamRepository repo = ...
IProcessDefinition processTemplate = ...
Map<String, IContent> processTemplateData = processTemplate.getProcessData();
final String PROCESS_CONFIGURATION_SOURCE_KEY = "com.ibm.team.internal.process.compiled.xml";
IContent content = processTemplateData.get(PROCESS_CONFIGURATION_SOURCE_KEY);
OutputStream outStream = new ByteArrayOutputStream();
repo.contentManager().retrieveContent(content, outStream, null);
Then, we tried to update the Process Configuration Source of the project area:
IProjectArea prjArea = ...
IProcessDefinitionHandle prjAreaProcessH = (IProcessDefinitionHandle) prjArea.getProcessDefinition();
IProcessDefinition prjAreaProcess = (IProcessDefinition) repo.itemManager().fetchCompleteItem(prjAreaProcessH, ItemManager.DEFAULT, null);

prjAreaProcess = (IProcessDefinition) prjAreaProcess.getWorkingCopy();
Map<String, IContent>  prjAreaProcessData = prjAreaProcess.getProcessData();
prjAreaProcessData.put(PROCESS_CONFIGURATION_SOURCE_KEY, content);
processClient.save(prjAreaProcess, null);
Although we fetched a working copy of the process, we get a "com.ibm.team.repository.common.internal.ImmutablePropertyException" exception. Any advice?
Thanks in advance.

0 votes



One answer

Permanent link
Ok, we found this post https://jazz.net/forum/questions/49535/how-to-get-process-template-source, and now with the code below it works:
final String xml = outStream.toString(); 
IWorkingCopyManager workingCopyManager = processClient.getWorkingCopyManager();
IProjectAreaWorkingCopy prjAreaFreshCopy = (IProjectAreaWorkingCopy) workingCopyManager.createPrivateWorkingCopy(prjArea);
IDocument document = prjAreaFreshCopy.getProcessSpecification();
document.set(xml);
prjAreaFreshCopy.save(null);

1 vote

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

Question asked: Jun 27 '12, 9:34 a.m.

Question was seen: 3,421 times

Last updated: Oct 24 '13, 3:05 a.m.

Confirmation Cancel Confirm