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

How to programme the prerequisites in plugin.xml?

Problem
The service 'helloworldadvisor.WorkItemSave@332a332a' failed to find the required service 'interface com.ibm.team.workitem.common.IAuditableCommon'.  Check <prerequisites> in plugin.xml.

plugin.xml
	<?xml version="1.0" encoding="UTF-8"?>
	<?eclipse version="3.4"?>
	<plugin>
	   <extension
	         point="com.ibm.team.process.service.operationAdvisors">
	      <operationAdvisor
	            class="helloworldadvisor.WorkItemSave"
id="HelloWorldAdvisor.prohibitSave"
name="Prohibit Save (Hello World Advisor)"
operationId="com.ibm.team.workitem.operation.workItemSave">
</operationAdvisor>
</extension>

</plugin>
WorkItemSave.java
package helloworldadvisor;

import java.sql.Timestamp;

import org.eclipse.core.runtime.IProgressMonitor;
import com.ibm.team.repository.service.AbstractService;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.advice.AdvisableOperation;
import com.ibm.team.process.common.advice.IAdvisorInfo;
import com.ibm.team.process.common.advice.IAdvisorInfoCollector;
import com.ibm.team.process.common.advice.runtime.IOperationAdvisor;
import com.ibm.team.repository.common.IAuditable;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.repository.common.UUID;
import com.ibm.team.workitem.common.IAuditableCommon;
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.IWorkItemType;
import com.ibm.team.workitem.common.model.Identifier;

public class WorkItemSave extends AbstractService implements IOperationAdvisor {
public static final String PROBLEM_TYPE = " HelloWorldAdvisor.prohibitSave";

public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {
System.out.println("--->AbstractService");
Object data = operation.getOperationData();

if (!(data instanceof ISaveParameter))
return;

ISaveParameter saveParameter = (ISaveParameter) data;
IAuditableCommon auditableCommon= (IAuditableCommon) getService(IAuditableCommon.class);

if (!(saveParameter.getNewState() instanceof IWorkItem))
return;

IWorkItem newState= (IWorkItem) saveParameter.getNewState();
String strWorkItemType = newState.getWorkItemType();
System.out.println("strWorkItemType--->" + strWorkItemType + "---");
if (!"task".equals(strWorkItemType.trim())) {
System.out.println("--->return");
return;
}

System.out.println("--->next step001");
Identifier newStateId = newState.getState2();
String state = newStateId.getStringIdentifier();
if (null != state) {
System.out.println("uuidStateId--->" + state);
}

System.out.println("--->next step002");
//set currentUser to owner
newState.setOwner(auditableCommon.getUser());

IWorkItemCommon workItemCommon= this.getService(IWorkItemCommon.class);
//set currentUser to approveaaa
IAttribute target= workItemCommon.findAttribute(newState.getProjectArea(), "approveaaa", monitor);
newState.setValue(target, auditableCommon.getUser());

System.out.println("--->next step003");
//set now to date
long now= System.currentTimeMillis();
IAttribute targetdate= workItemCommon.findAttribute(newState.getProjectArea(), "updatedate", monitor);
newState.setValue(targetdate, new Timestamp(now));
System.out.println("--->next step004");
IAuditable auditable = saveParameter.getNewState();


}
}

0 votes


Accepted answer

Permanent link
Carefully read https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/
You also might want to search this forum. I am pretty sure the question has been asked and answered before.

I think I also sent you a bunch of copies of my blog posts and they also have links to download the code, so you can check e.g. the differences in the plugin XML.

The prerequisites are set this way:


Ralph Schoon selected this answer as the correct answer

0 votes

Comments

https://jazz.net/library/article/1000 also explains this.

A better way to say this

YOU must explicitly define all the dependent services you wish to use in the plugin.xml of your plugin.  RTC does not support open binding.

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,925

Question asked: Nov 27 '13, 12:44 a.m.

Question was seen: 4,417 times

Last updated: Nov 27 '13, 7:48 a.m.

Confirmation Cancel Confirm