It's all about the answers!

Ask a question

Error in operation participant .


Sudeshna Mitra (2332831) | asked Aug 09 '12, 9:50 a.m.
edited Aug 09 '12, 12:10 p.m. by Jared Burns (4.4k29)
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.

One answer



permanent link
Muthukumar C (32712733) | answered Aug 09 '12, 11:51 p.m.
edited Aug 09 '12, 11:57 p.m.
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();

Your answer


Register or to post your answer.