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

Adding Attachments to a Project Area with Plain Java API

Hi,

we are using the plain java api libraries to modify project configurations.
Everything works fine but we have some struggle with adding attachments to out project area.

So far we had a few approaches but with none of them we could succeed.
 1. The approach of Ralph Schoon (https://jazz.net/forum/questions/172606/how-to-add-process-attachement-in-a-project-area-via-the-rtc-plain-java-api) was not applicable because we do not have UUIDs which we can use

2. When creating an IProcessAttachment "processItemService.createProcessAttachment()" via the IProcessItemService we were not able to store the attachment because either the attachment had no back pointer to the process container or the process attachment did not exist for the process container, depending on which we tried to store first (ProcessArea or the ProcessAttachment). We used the following source code:
IProcessItemService processItemService = (IProcessItemService) connection.getTeamRepository().getClientLibrary(IProcessItemService.class);IProcessAttachment processAttachment = processItemService.createProcessAttachment();IProcessAttachment mutableProcessAttachment = (IProcessAttachment) processAttachment.getWorkingCopy();IContent content = connection.getTeamRepository().contentManager().storeContent(        IContent.CONTENT_TYPE_UNKNOWN, (new FileInputStream(attachment)).toString(), progressMonitor);mutableProcessAttachment.setContent(content);mutableProcessAttachment.setPath(path.toString());mutableProcessAttachment.setProcessContainer(pch);mutableProcessArea.addAttachment(mutableProcessAttachment);processItemService.save(mutableProcessArea, progressMonitor);processItemService.save(mutableProcessAttachment, progressMonitor);

Can anyone guide us to a working approach? Or give a hint why ours did not work?

Thanks in advance

0 votes

Comments

Have you setup the SDK and searched for examples in it? Unfortunaltely I have no running code. I think however you want to upload first e.g.


newContent = teamRepository.contentManager().storeContent(
                    "application/octet-stream", IContent.ENCODING_UTF_8,
                    LineDelimiter.LINE_DELIMITER_NONE, fin, null, monitor);



I have no code specific for the ProjectArea but can see some code in the SDK.




One answer

Permanent link

Thanks thanks thanks I was going crazy and I was so close, I was missing saving the same IProcessAttachment for that didn't work.

Thank you so much.

0 votes

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
× 6,121

Question asked: Nov 13 '18, 8:08 a.m.

Question was seen: 1,962 times

Last updated: Aug 26 '21, 1:38 p.m.

Confirmation Cancel Confirm