It's all about the answers!

Ask a question

How to check whether a workitem has either a changeset or an attachment


Chandan M B (11314184) | asked Jun 23 '15, 7:25 a.m.
edited Jun 23 '15, 8:27 a.m. by Ralph Schoon (63.7k33648)
Hi,

I need to check whether a workitem has either a changeset or an attachment in my server side extensions.
Please provide me small snippet if anybody has done it !!!

Comments
Chandan M B commented Jun 23 '15, 9:34 a.m.

IWorkItemReferencesworkItemReferences=workItemCommon.resolveWorkItemReferences(newState, monitor);List<IReference> references = workItemReferences.getReferences(WorkItemEndPoints.ATTACHMENT);
for(IReference reference:references){
IAttachmentHandle attachmentHandle=(IAttachmentHandle) reference.resolve();
 IAttachment attachment=(IAttachment) itemService.fetchItem(attachmentHandle, IRepositoryItemService.COMPLETE);if(attachment!=null){
IContributorHandle attachmentContributorHandle = attachment.getCreator();
 IContributor attachmentContributor = (IContributor) itemService.fetchItem(attachmentContributorHandle, IRepositoryItemService.COMPLETE);
                    String attachmentowner = attachmentContributor.getName();
                    System.out.println("Owner is ------- "+attachmentowner);
                }
            }

One answer



permanent link
Ralph Schoon (63.7k33648) | answered Jun 23 '15, 8:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
See https://rsjazz.wordpress.com/ use the search box in the top right to search for attachment.

Comments
Chandan M B commented Jun 23 '15, 9:10 a.m.

I need to know whether the attachment is added to a workitem or not. If in case attachment is added, i need to retrieve the user who added the attachment in my follow up action in the server extension plugin.


Chandan M B commented Jun 23 '15, 9:35 a.m.

Please see above


Ralph Schoon commented Jun 23 '15, 9:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You perform Rational Team Concert Extensions Workshop to understand what you are doing, how and how to debug it and to learn how you can compare the old state and the new state.

Once you understand what the old state and the new state in a participant is and how to access its data, you should be able to understand if there is something new and what.


Chandan M B commented Jun 26 '15, 3:29 a.m.

Yes.
How to retrieve the content in an attachment file in server side extensions.
IContent content = attachment.getContent();
String contentType = content.getContentType();


Ralph Schoon commented Jun 26 '15, 3:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or 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.