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.
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
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();
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();