It's all about the answers!

Ask a question

How to add Process Attachement in a Project Area via the RTC Plain java API ?


Jerome Schertzer (611) | asked Jan 27 '15, 11:03 a.m.
Hello,

I'm trying to upload some Process Attachments via the RTC Plain API.
I started to implement this :

        final URI uri = URI.create(projectAreaName.replaceAll(" ", "%20"));
        final IProjectArea projectArea = (IProjectArea)processClient.findProcessArea(uri, null, null);
        if (projectArea == null)
        {
            System.out.println("Project not found.");
            return;
        }
        IProcessAttachmentHandle attachment = null;
        projectArea.addAttachment(attachment);


My Problem is that I'm not able to create an instance of IProcessAttachmentHandle .
What is the best way to upload a new attachment in the PA?

One answer



permanent link
Ralph Schoon (63.4k33646) | answered Jan 27 '15, 11:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would suggest to follow https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and setup the SDK. You can then search for Java Classes and where they are used. I found this in 15 seconds:


			List attachmentHandles = new ArrayList();
			for (int i = 0; i < attachmentRepresentations.length; i++) {
				String itemId = attachmentRepresentations[i].itemId;
				IProcessAttachmentHandle handle = (IProcessAttachmentHandle) IProcessAttachment.ITEM_TYPE.createItemHandle(UUID.valueOf(itemId), null);
				attachmentHandles.add(handle);
			}
			
			List attachments = fRepo.itemManager().fetchCompleteItems(attachmentHandles, IItemManager.DEFAULT, new SubProgressMonitor(monitor, 500));
			return (IProcessAttachment[]) attachments.toArray(new IProcessAttachment[attachments.size()]);


To my experience it is key to set up the dev environment properly. The API is cpomplex enough. If you can't search, you are doomed.

Comments
Ralph Schoon commented Nov 13 '18, 8:41 a.m. | edited Nov 13 '18, 9:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Searching the SDK shows code like used in this post:




    public IContent uploadContent(String filename, IProgressMonitor monitor)
            throws TeamRepositoryException {
        IContent newContent = null;
        try {
            File uploadFile = new File(filename);
            FileInputStream fin = new FileInputStream(uploadFile);
            try {
                newContent = fTeamRepository.contentManager().storeContent(
                        "image/jpeg", null,
                        LineDelimiter.LINE_DELIMITER_NONE, fin, null, monitor);
            } finally {
                fin.close();
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
        return newContent;
    }

You need to upload an attachment with the content manager and then you will have to use the content to hook it up where it is needed.

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.