It's all about the answers!

Ask a question

How to programme the prerequisites in plugin.xml?


guoping chen (191014) | asked Nov 27 '13, 12:44 a.m.
edited Nov 27 '13, 12:59 a.m.
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();


}
}

Accepted answer


permanent link
Ralph Schoon (63.3k33646) | answered Nov 27 '13, 4:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

Comments
Ralph Schoon commented Nov 27 '13, 4:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


sam detweiler commented Nov 27 '13, 7:48 a.m.

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 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.