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

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


0 votes


Accepted answer

Permanent link

 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

0 votes

Comments

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

Question asked: Dec 12 '17, 10:09 a.m.

Question was seen: 856 times

Last updated: Dec 12 '17, 12:46 p.m.

Confirmation Cancel Confirm