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

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

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?

0 votes



One answer

Permanent link
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.

0 votes

Comments

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 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
× 169

Question asked: Jan 27 '15, 11:03 a.m.

Question was seen: 3,983 times

Last updated: Nov 13 '18, 9:35 a.m.

Confirmation Cancel Confirm