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?
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
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:
ListTo 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.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()]);
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.