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

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.

1

1 vote

Comments

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

0 votes


One other answer

Permanent link
Please see https://www.google.com/search?q=process+sharing+api+site:jazz.net and look into the first few results.

0 votes

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.

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.

showing 5 of 6 show 1 more comments

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
× 10,927

Question asked: Sep 04 '15, 1:13 a.m.

Question was seen: 3,058 times

Last updated: Sep 11 '15, 8:44 p.m.

Confirmation Cancel Confirm