How to check whether a workitem has either a changeset or an attachment
One answer
Comments
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.
Please see above
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.
Yes.
How to retrieve the content in an attachment file in server side extensions.
IContent content = attachment.getContent();
String contentType = content.getContentType();
All that information is on https://rsjazz.wordpress.com/ For example:
https://rsjazz.wordpress.com/2012/09/21/downloading-attachments-from-work-items/
https://rsjazz.wordpress.com/2012/08/01/uploading-attachments-to-work-items/
Although that is client API it is pretty much the same in the server API.
Comments
Chandan M B
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);
}
}