It's all about the answers!

Ask a question

how to Update project area with process template content through RTC API


1
1
ast java (4511847) | asked Sep 04 '15, 1:13 a.m.
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.

Comments
Geoffrey Clemm commented Sep 11 '15, 8:40 p.m. | edited Sep 11 '15, 8:44 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.  

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered Sep 04 '15, 3:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I created an example some time ago. Please note, you can corrupt your process configuration....

In the main:
		Map pd = 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);
		}

and
	/**
	 * @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();
		}
	}

ast java selected this answer as the correct answer

One other answer



permanent link
Ralph Schoon (63.1k33645) | answered Sep 04 '15, 2:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see https://www.google.com/search?q=process+sharing+api+site:jazz.net and look into the first few results.

Comments
Ralph Schoon commented Sep 04 '15, 2:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


ast java commented Sep 04 '15, 2:52 a.m. | edited Sep 11 '15, 8:36 p.m.

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.


Ralph Schoon commented Sep 04 '15, 3:03 a.m. | edited Sep 11 '15, 8:41 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Ralph Schoon commented Sep 04 '15, 3:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I was able to figure the code from the posts I found.


1
ast java commented Sep 07 '15, 2:18 a.m. | edited Sep 11 '15, 8:41 p.m.

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.


Ralph Schoon commented Sep 07 '15, 5:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Process specification references iteration 'Release 1.0', which does not exist.

check your process configuration.

showing 5 of 6 show 1 more comments

Your answer


Register or to post your answer.