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

RTC Extension - Participant

Hi Jazz Team,

I am creating RTC extension which will change some attr values after save but even when I am creating sample example I received error after save. Maybe somebody will have some ideas

Error: Problem An error occurred during "Save Work Item". java.lang.StackOverflowError

import org.eclipse.core.runtime.IProgressMonitor;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.advice.AdvisableOperation;
import com.ibm.team.process.common.advice.IProcessReport;
import com.ibm.team.process.common.advice.IReportInfo;
import com.ibm.team.process.common.advice.runtime.IOperationParticipant;
import com.ibm.team.process.common.advice.runtime.IParticipantInfoCollector;
import com.ibm.team.repository.common.IAuditable;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.repository.service.AbstractService;
import com.ibm.team.workitem.common.ISaveParameter;
import com.ibm.team.workitem.common.model.IWorkItem;
import com.ibm.team.workitem.service.IWorkItemServer;
public class OperationParticipant extends AbstractService implements
IOperationParticipant {
@Override
public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

Object data = operation.getOperationData();
if (data instanceof ISaveParameter)
{
ISaveParameter save = (ISaveParameter)data;
IAuditable audi = save.getNewState();
if(audi instanceof IWorkItem)
{

IWorkItem wi = (IWorkItem)audi;
IWorkItemServer server = getService(com.ibm.team.workitem.service.IWorkItemServer.class);
IWorkItem itemCopy=(IWorkItem)server.findWorkItemById(wi.getId(), IWorkItem.FULL_PROFILE, null).getWorkingCopy(); 
itemCopy.setHTMLSummary(XMLString.createFromPlainText("Test"));
server.saveWorkItem2(itemCopy, null, null);
}
}

}
}

plugin.xml 


	
		
			
					
						
						
					
				
		
	

	

2 votes


Accepted answer

Permanent link
    // setup
    private static final String Recursion = "Approvalsbypass";   // can be anything u want must be unique
    private static Set<String> bypass =
           new HashSet<String>(new ArrayList<String>(Arrays.asList(Recursion)));

    // in handler
        Object data = operation.getOperationData();
        ISaveParameter saveParameter = null;
        if (data instanceof ISaveParameter)
        {
            saveParameter = (ISaveParameter) data;
            // check to see if we are being called again from our save
            // if not, process, otherwise skip the work
            //  if no parms, or the parm is not ours, process request.
            if (          (saveParameter.getAdditionalSaveParameters() == null)
                          ||
                          ((saveParameter.getAdditionalSaveParameters() != null)
                    && (!saveParameter.getAdditionalSaveParameters().contains(Recursion)))
                 )
            {       
             // do all your normal processing here
            ...
            // if u need to update the workitem you are processing for
            // this will cause this plugin to be called again
            saveStatus = fWorkItemServer.saveWorkItem3(workingCopy, null, null, bypass);      
            }
       }
Bartosz Chrabski selected this answer as the correct answer

1 vote

Comments

SWEET!!!!  You have just made my day!

Thanks a lot  


One other answer

Permanent link
Normally this means that you are recursing through this until you run out of memory.

Remember that when you do the Save, it will invoke this same participant again (because you saved the work item).

So basically, first time, you go in, save html summary.  This calls the same one, it sets the html summary and saves, which sets the HTML summary and saves, which calls it again and sets the html summary and saves .....

So you have to have something where you decide you do *not* need to set the HTML summary and you get out.

Susan

0 votes

Comments

or you use saveworkitem3 and pass a parameter in the last parm that tells your code its you invoking the extension, and ignore it

I looked at this and it gives me these options ... which of them would tell my code that I am invoking the extension again??

additionalSaveParameters contains the additional save parameter. Supported types for additionalSaveParameters are: IAdditionalSaveParameters.IGNORE_COMMENT_UPDATES IAdditionalSaveParameters.IGNORE_BACKLINK_PROBLEMS IAdditionalSaveParameters.UPDATE_BACKLINKS IAdditionalSaveParameters.SKIP_VALIDATION_ATTRIBUTE_NAME

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,936
× 51

Question asked: Jun 24 '14, 5:24 p.m.

Question was seen: 7,267 times

Last updated: Jun 25 '14, 5:43 a.m.

Confirmation Cancel Confirm