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

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

 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

0 votes



2 answers

Permanent link
I dont understand why the follow up action start if I dont "Save" the Workitem? I only "Attach a File"...


1 vote

Comments

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


Permanent link
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.

1 vote

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

Question asked: May 22 '13, 5:57 a.m.

Question was seen: 5,135 times

Last updated: Oct 03 '16, 7:23 a.m.

Confirmation Cancel Confirm