how to Update project area with process template content through RTC API
Hi All,
I wanted to know how to Update project area with process template content.
I tried with process sharing concepts, its works fine. But i want to try with RTC API.
Below is the code i tried for attaching the attachment of process template to the project area:
RtcTemplateFileStructure rtcTemplateFileStructure = new RtcTemplateFileStructure(assembleTemplateDownloadPath);
File attachment = new File(rtcTemplateFileStructure.readAttachmentsList() + System.getProperty(""));
System.out.println("attachment :" + attachment);
IProcessAttachmentHandle handle = (IProcessAttachmentHandle) IProcessAttachment.ITEM_TYPE.createItemHandle(UUID.valueOf(itemId), null);
attachment.add(handle);
But Its not working.
I wanted to know how to Update project area with process template content.
I tried with process sharing concepts, its works fine. But i want to try with RTC API.
Below is the code i tried for attaching the attachment of process template to the project area:
RtcTemplateFileStructure rtcTemplateFileStructure = new RtcTemplateFileStructure(assembleTemplateDownloadPath);
File attachment = new File(rtcTemplateFileStructure.readAttachmentsList() + System.getProperty(""));
System.out.println("attachment :" + attachment);
IProcessAttachmentHandle handle = (IProcessAttachmentHandle) IProcessAttachment.ITEM_TYPE.createItemHandle(UUID.valueOf(itemId), null);
attachment.add(handle);
But Its not working.
Accepted answer
I created an example some time ago. Please note, you can corrupt your process configuration....
In the main:
In the main:
Mapandpd = projectArea.getProcessData(); IContent content = (IContent) pd .get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY); if (content != null) { String processConfig = createStringFromContent(teamRepository, content, monitor); String newProcessConfig = processConfig.replace( "this-is-a-fake-url", "http://localhost/index.html"); IContent newContent = createContentFromString(teamRepository, newProcessConfig, monitor); pd.put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY, newContent); IProcessItemService processItemService = (IProcessItemService) teamRepository .getClientLibrary(IProcessItemService.class); processItemService.save(projectArea, monitor); }
/** * @param teamRepository * @param content * @param monitor * @return * @throws TeamRepositoryException */ private static IContent createContentFromString( ITeamRepository teamRepository, String content, IProgressMonitor monitor) throws TeamRepositoryException { return teamRepository.contentManager().storeContent( IContent.CONTENT_TYPE_XML, content, monitor); } /** * @param repo * @param content * @param monitor * @return * @throws TeamRepositoryException * @throws UnsupportedEncodingException */ private static String createStringFromContent(ITeamRepository repo, IContent content, IProgressMonitor monitor) throws TeamRepositoryException, UnsupportedEncodingException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); repo.contentManager().retrieveContent(content, stream, monitor); return new String(stream.toByteArray(), content.getCharacterEncoding()); } // save the process source for the project /** * @param ip * @param ic * @param icm * @param name * @param monitor */ private static void saveXMLSource(IProjectArea ip, IContent ic, IContentManager icm, String name, IProgressMonitor monitor) { // make an output stream for the content manager OutputStream os = new ByteArrayOutputStream(); // get the content of the content object. try { icm.retrieveContent(ic, os, null); // write xml content to file // project name + data name FileOutputStream fo = new FileOutputStream(ip.getName() + name + "." + "xml"); // write fo.write(os.toString().getBytes(), 0, os.toString().length()); // close fo.close(); } catch (Exception e) { e.printStackTrace(); } }
One other answer
Please see https://www.google.com/search?q=process+sharing+api+site:jazz.net and look into the first few results.
Comments
1 vote
showing 5 of 6
show 1 more comments
Comments
Geoffrey Clemm
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 11 '15, 8:44 p.m.