Upload/Replace process XML via Jazz API
Hello All,
I would like to replace an existing process XML with a modified version from the file system.
I tried this with the follwing code.
private static void uploadXMLSource(IProjectArea ip,IProgressMonitor sPm) throws TeamRepositoryException,
UnsupportedEncodingException {
ITeamRepository tr = (ITeamRepository) ip.getOrigin();
Map <String, Object> pd = ip.getProcessData();
IContent content = (IContent) pd.get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY);
if (content != null) {
System.out.println("Modify: " + content);
String newProcess = "c:/temp/processXML_JKE Banking (Change Management).xml";
//String newProcessString;
try {
String newProcessString = readFile(newProcess);
System.out.println("ProcessString: " + newProcessString);
IContent newContent = createContentFromString(tr, newProcessString, sPm);
System.out.println("new content: " + newContent);
pd.put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY, newContent);
IProcessItemService processItemService = (IProcessItemService) tr
.getClientLibrary(IProcessItemService.class);
processItemService.save(ip, sPm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But as result I just have the following exception:
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2159)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1027)
....
Could you please support me resolving this problem.
Many thanks,
Christine
Accepted answer
One of the most basic common requirement is to have a WorkingCopy of the object you want to modify. This is true for almost all items. The object itself is immutable. See your error message.