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

Programaticly appending comments to work items

I've been using the Plain-Java API to fetch work items from an RTC team area. I then try to append a comment to the work item. When doing so a com.ibm.team.repository.common.internal.ImmutablePropertyException is thrown.

I followed the example here to connect to the repository https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation#Plain_Java_Client and the comments here https://jazz.net/forums/viewtopic.php?t=2959&highlight=api+comments to try and append a comment.

Below is the relevant code snippet:

TeamPlatform.startup();
ITeamRepository teamRepository= TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);

IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);

URI uri= URI.create( "My Project Area".replaceAll(" ", "%20") );
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
if (projectArea == null) {
System.out.println("Project area not found.");
}

IWorkItem workingCopy = workItemClient.findWorkItemById(456, IWorkItem.FULL_PROFILE, null);
System.out.println("State: " + workingCopy.getState2().getStringIdentifier());
System.out.println("Resolution: " + workingCopy.getResolution2().getStringIdentifier());
IComments comments= workingCopy.getComments();
System.out.println("Listing Comments: ");
for(IComment c: comments.getContents() ){
System.out.println(" " + c.getHTMLContent().getPlainText());
}
IComment comment= comments.createComment( teamRepository.loggedInContributor(),
XMLString.createFromPlainText( "This is my new commend from the java api"));
comments.append(comment);


Any ideas as to why I'm unable to modify the work item?

0 votes



2 answers

Permanent link
Hi jmilam,

Now I got an answer about this!I suffer from same thing.
IWorkItem workingCopy =
workItemClient.findWorkItemById(456,IWorkItem.FULL_PROFILE, null);


You got *Immutable* WorkItem at this line.
If you momdify workitem, you get WorkingCopy from WorkItem.
WorkingCopy has same interface from that Object.so I'll show you the statements.

IWorkItem workitem = workItemClient.findWorkItemById(456,IWorkItem.FULL_PROFILE,
null);
IWorkItem workingCopy = (IWorkItem)workitem.getWorkingCopy();

Regards,
Hiroki Kondo

jmilam wrote:
I've been using the Plain-Java API to fetch work items from an RTC
team area. I then try to append a comment to the work item. When
doing so a
com.ibm.team.repository.common.internal.ImmutablePropertyException is
thrown.

I followed the example here to connect to the repository
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation#Plain_Java_Client
and the comments here
https://jazz.net/forums/viewtopic.php?t=2959&highlight=api+comments
to try and append a comment.

Below is the relevant code snippet:

TeamPlatform.startup();
ITeamRepository teamRepository=
TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new
LoginHandler(userId, password));
teamRepository.login(null);

IProcessClientService processClient=
(IProcessClientService)
teamRepository.getClientLibrary(IProcessClientService.class);
IWorkItemClient workItemClient= (IWorkItemClient)
teamRepository.getClientLibrary(IWorkItemClient.class);

URI uri= URI.create( "My Project
Area".replaceAll(" ", "%20") );
IProjectArea projectArea= (IProjectArea)
processClient.findProcessArea(uri, null, null);
if (projectArea == null) {
System.out.println("Project area not found.");
}

IWorkItem workingCopy = workItemClient.findWorkItemById(456,
IWorkItem.FULL_PROFILE, null);
System.out.println("State: " +
workingCopy.getState2().getStringIdentifier());
System.out.println("Resolution: " +
workingCopy.getResolution2().getStringIdentifier());
IComments comments= workingCopy.getComments();
System.out.println("Listing Comments: ");
for(IComment c: comments.getContents() ){
System.out.println(" " +
c.getHTMLContent().getPlainText());
}
IComment comment= comments.createComment(
teamRepository.loggedInContributor(),
XMLString.createFromPlainText( "This is my new commend
from the java api"));
comments.append(comment);


Any ideas as to why I'm unable to modify the work item?

0 votes


Permanent link
The Wiki page
https://jazz.net:443/wiki/bin/view/Main/ProgrammaticWorkItemCreation

also has some examples of how to create work items in a plain Java context.

--
Regards,
Patrick
Jazz Work Item Team

0 votes

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

Question asked: Jan 19 '09, 4:08 p.m.

Question was seen: 7,982 times

Last updated: Jan 19 '09, 4:08 p.m.

Confirmation Cancel Confirm