how to Update project area with process template content through RTC API
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
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
Comments
Please also note that, once a process template has been applied when creating a project area, the only ways to modify the process is in the process configuration (or in a shared process configuration). The template only plays a role in the beginning.
Hi Ralph,
As we said earlier, through process sharing we are able to update the process template from one project to another project area.
But! Yes, we need to modify the process through process configuration. Is there any RTC API through which we can modify the process template of project area. As now we are able to do manual. Do RTC API support this functionality in pragmatically.
In that case see https://www.google.com/search?q=process+configuration+source+site:jazz.net
I found https://jazz.net/forum/questions/111579/get-process-configuration-source-via-api
You basically can get the whole XML and modify and save it back.
I was able to figure the code from the posts I found.
Hi Ralph,
I tired your code with little modifications:
IProjectArea projectArea = getProjectArea(projectAreaName);
IProcessItemService processItemService = (IProcessItemService) this.teamRepo.getClientLibrary(IProcessItemService.class);
IProjectArea workingCopy = (IProjectArea) processItemService.getMutableCopy(projectArea);
IContent content = (IContent) workingCopy.getProcessData().get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY);
if (content != null) {
IContent newContent = createContentFromString( this.teamRepo, newProcessConfig, monitor);
workingCopy.getProcessData().put(ProcessContentKeys.PROCESS_SPECIFICATION_KEY, newContent);
processItemService.save(workingCopy, monitor); }
and Compilation is success.
Now when i tried to export the Project Area , facing below error?
TeamRepositoryException could not be handled
com.ibm.team.process.common.service.ProcessDataValidationException: Process specification references iteration 'Release 1.0', which does not exist.
at com.ibm.team.process.internal.common.util.ProcessValidationUtil.validateIterationConfigurations(ProcessValidationUtil.java:477) ~[com.ibm.team.process.common-6.0.0.jar:?]
Please Let me know where i am doing wrong.
1 vote
Process specification references iteration 'Release 1.0', which does not exist.
check your process configuration.
Comments
Geoffrey Clemm
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 11 '15, 8:44 p.m.Note that updating the process sharing pointer of a project area and updating the process template of a project area are two very different actions. In particular, the first is possible, and the second is not.