It's all about the answers!

Ask a question

Adding Attachments to a Project Area with Plain Java API


Kevin Wenz (111) | asked Nov 13 '18, 8:08 a.m.
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


Comments
Ralph Schoon commented Nov 13 '18, 11:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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
Emiliano Iannetti (389) | answered Aug 26 '21, 1:38 p.m.

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.

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.