It's all about the answers!

Ask a question

Error when I attach a file in a workitem by plugin Participant


Marcos Sánchez (19711) | asked May 22 '13, 5:57 a.m.
edited May 22 '13, 5:59 a.m.
 Hi all,

I have working fine the Participant plugin (Create approvers:  http://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/)  but  when I try to attach a file in a workitem (after creation) an alert say "Failed save workitem".

The ccm.log error:

2013-05-22 11:32:08,951 [              WebContainer : 3] ERROR com.ibm.team.process.common                         - com.ibm.team.workitem.common.internal.model.impl.AttachmentImpl incompatible with com.ibm.team.workitem.common.model.IWorkItem
java.lang.ClassCastException: com.ibm.team.workitem.common.internal.model.impl.AttachmentImpl incompatible with com.ibm.team.workitem.common.model.IWorkItem
at ev.createapproval.CreateApproval.run(CreateApproval.java:101)

My first lines of run code:

//Get Data
Object data = operation.getOperationData();
ISaveParameter saveParameter = null;
        
      if (data instanceof ISaveParameter) 
      {
saveParameter = (ISaveParameter) data;
IWorkItem newState = (IWorkItem) saveParameter.getNewState(); //line 101 error
Identifier<IState> newStateId = newState.getState2();
Identifier<IState> oldStateId = null;
IWorkItem oldState = (IWorkItem) saveParameter.getOldState();
String tipo = newState.getWorkItemType().toString();
                         //avoid recursive with loop
                        if (saveParameter.getAdditionalSaveParameters().contains("Loop") || !(tipo.equals("proyecto")))
{
return; 
}
//Not new wi
if (oldState != null )
{
IApprovals HasApprovals = oldState.getApprovals();
List<IApproval> hasAppr = HasApprovals.getContents();

...


Anybody know what is wrong with my participant plugin? 

Thanks

2 answers



permanent link
Marcos Sánchez (19711) | answered May 22 '13, 6:53 a.m.
I dont understand why the follow up action start if I dont "Save" the Workitem? I only "Attach a File"...



Comments
Ralph Schoon commented May 22 '13, 7:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Attaching a file saves a work item you attach it to.


permanent link
Ralph Schoon (63.6k33647) | answered May 22 '13, 7:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Marcos, if you look into the code of the participant: http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ and the other one, where you commented, you can see that you have to make sure your follow up action is actually triggered by a work item save. The code mentioned is:


		if (!(data instanceof ISaveParameter))
			return;

		// Check that this was a save operation on a work item
		ISaveParameter saveParameter= (ISaveParameter) data;
		if (!(saveParameter.getNewState() instanceof IWorkItem))
			return;

The instanceof IWorkItem is actually important, so you don't cast something completely different than a IWorkItem and get the error you see.

Comments
Girish Chandra P commented Oct 03 '16, 7:23 a.m.

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.