It's all about the answers!

Ask a question

Upload/Replace process XML via Jazz API


Christine Makasy (731123) | asked Dec 12 '17, 10:09 a.m.

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


permanent link
Ralph Schoon (63.1k33645) | answered Dec 12 '17, 12:34 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Dec 12 '17, 12:36 p.m.

 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.


As an example https://rsjazz.wordpress.com/2014/11/28/the-process-sharing-api/ should show how to do that. There are other examples on that blog.

Christine Makasy selected this answer as the correct answer

Comments
Ralph Schoon commented Dec 12 '17, 12:46 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

PS. You are hopefully aware, that you can seriously damage a project area if you do this and so far the statements from support I have heard in this area is that it is discouraged and not supported. You are doing this at about pwn risk.

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.