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

Error in operation participant .

Hello ,

I was facing issues with OperationParticipant which I was write, to update Workitem summary, can any one help me on this issue.

Here is my code

import java.util.Iterator;
import java.util.List;

import org.eclipse.core.runtime.IProgressMonitor;

import com.ibm.team.links.common.IItemReference;
import com.ibm.team.links.common.IReference;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.advice.AdvisableOperation;
import com.ibm.team.process.common.advice.runtime.IOperationParticipant;
import com.ibm.team.process.common.advice.runtime.IParticipantInfoCollector;
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.IWorkItemCommon;
import com.ibm.team.workitem.common.model.IAttribute;
import com.ibm.team.workitem.common.model.IWorkItem;
import com.ibm.team.workitem.common.model.IWorkItemHandle;
import com.ibm.team.workitem.common.model.WorkItemEndPoints;
import com.ibm.team.workitem.service.IWorkItemServer;

public class TestClassDemo extends AbstractService implements IOperationParticipant {

    private static final String SAVE_SUMMARY="summary";
    
    private IWorkItemServer workItemServer;
    private IWorkItemCommon wiCommon;
    
    public void run(AdvisableOperation operation,
            IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException
            
    {
        
        Object data= operation.getOperationData();
        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;
                
        workItemServer = getService(IWorkItemServer.class);
        wiCommon = getService(IWorkItemCommon.class);
        
        IWorkItemHandle currentWIHandle = (IWorkItemHandle)saveParameter.getNewState().getItemHandle();
        IWorkItem workItem=(IWorkItem)workItemServer.getAuditableCommon().resolveAuditable(currentWIHandle,IWorkItem.FULL_PROFILE,monitor).getWorkingCopy();
        IAttribute summaryAttribute = wiCommon.findAttribute(workItem.getProjectArea(),SAVE_SUMMARY, monitor);
        workItem = (IWorkItem)workItem.getWorkingCopy();
        workItem.setValue(summaryAttribute, "hello..");
        workItemServer.saveWorkItem2(workItem, null, null);
    }
}

and here is the  workitem Screen error:

The server is not responding or a page navigation occurred before an operation completed.
Check that your server connection is working and that the server is operational,
then try the action again or refresh the page.







Please give me solution.

0 votes



One answer

Permanent link
Hi,

At the first glance, What I can find in the code is,
you are getting work item's Working copy twice which means, you are getting the working copy of an Working copy.

   IWorkItem workItem=(IWorkItem)workItemServer.getAuditableCommon().resolveAuditable(currentWIHandle,IWorkItem.FULL_PROFILE,monitor).getWorkingCopy();

workItem = (IWorkItem)workItem.getWorkingCopy();

Moreover,

   IWorkItemHandle currentWIHandle = (IWorkItemHandle)saveParameter.getNewState().getItemHandle();
        IWorkItem workItem=(IWorkItem)workItemServer.getAuditableCommon().resolveAuditable(currentWIHandle,IWorkItem.FULL_PROFILE,monitor).getWorkingCopy();

These lines can be replaced with

workItem = (IWorkItem) saveParameter.getNewState();

0 votes

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,938
× 369

Question asked: Aug 09 '12, 9:50 a.m.

Question was seen: 4,837 times

Last updated: Aug 09 '12, 11:57 p.m.

Confirmation Cancel Confirm