Plugin Participant fails when saveWorkItem2
Hi,
I want to create a plugin (IOperationParticipant) thats auto create Approvers (with the creator)
I want to create a plugin (IOperationParticipant) thats auto create Approvers (with the creator)
public class WIAprovalsParticipand extends AbstractService implements IOperationParticipant {
private static final String APPROVAL_NAME = "Aprobacion DA";
private IWorkItemServer fWorkItemServer = null;
private IProcessServerService fProcessServerService = null;
private IAuditableCommon fAuditableCommon = null;
public void run(AdvisableOperation operation,IProcessConfigurationElement participantConfig,IParticipantInfoCollector collector, IProgressMonitor monitor) throws TeamRepositoryException {
Object data= operation.getOperationData();
fWorkItemServer = getService(IWorkItemServer.class);
fAuditableCommon = getService(IAuditableCommon.class);
if (data instanceof ISaveParameter) {
IAuditable auditable = ((ISaveParameter)data).getNewState();
if (auditable instanceof IWorkItem) {
IWorkItem workItem = (IWorkItem) auditable;IWorkItem workingCopy = (IWorkItem) fWorkItemServer .getAuditableCommon() .resolveAuditable(workItem, IWorkItem.FULL_PROFILE, monitor) .getWorkingCopy();
Approvals approvals = workingCopy.getApprovals();
IApprovalDescriptor descriptor= approvals.createDescriptor(WorkItemApprovals.REVIEW_TYPE.getIdentifier(), APPROVAL_NAME);
IContributorHandle reviewer = workingCopy.getCreator();
IApproval approval= approvals.createApproval(descriptor, reviewer); approvals.add(approval);
IStatus saveStatus = fWorkItemServer.saveWorkItem2(workingCopy, null, null ); ...
I Can add the follow action to Save WI, but doesnt work, the server is "Saving" loop and dont stop, the ccm log is full with:
2013-04-30 15:08:57,021 [ WebContainer : 6] ERROR com.ibm.team.workitem.common - Error invoking value provider 'com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._QNifQGC9EeKTg8I24BTQkg'java.lang.NullPointerException
I Can add the follow action to Save WI, but doesnt work, the server is "Saving" loop and dont stop, the ccm log is full.
think my error is in the SaveWorkitem? because I prove and I access to the attributes of the WorkItem.
Anybody can help me?
Thanks.
Accepted answer
Marcos,
here a description how such a participant can be developed: https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ - with code - and here a deeper reasoning on how to avoid recursions https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ look at the end of the post if you are in a hurry.
Hope that helps.
here a description how such a participant can be developed: https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ - with code - and here a deeper reasoning on how to avoid recursions https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ look at the end of the post if you are in a hurry.
Hope that helps.
Comments
1 vote