It's all about the answers!

Ask a question

How to programmatically update Process Configuration Source


SEC Servizi (97123860) | asked Jun 27 '12, 9:34 a.m.
edited Oct 24 '13, 3:05 a.m.
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.

One answer



permanent link
SEC Servizi (97123860) | answered Jun 27 '12, 11:26 a.m.
edited Jun 27 '12, 11:27 a.m.
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);

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.