Why does a failed work item save in a participant cause the entire save operation to fail?
- Surrounding the entire contents of the run() method in a try/catch(Throwable t) - no effect
- Removed my participant from the process configuration - the save works fine
Accepted answer
com.ibm.team.process.service.IServerProcess#advise() returns a report that will tell you whether or not the user has permission to save. You must pass in the advisable operation. In your case, this would be the save on the work item you created.
Martha (Ruby) Andrews
Jazz L3 Developer
Comments
How do you pass in the save on the work item as an advisable operation? Do you simply cast it? For example, would it look like this:
IServerProcess serverProcess = getService(IServerProcess.class);
IWorkItemServer service = getService(IWorkItemServer.class);
serverProcess.advise((AdvisableOperation) service.SaveWorkItem3(workItem, null, null, additionalParams));
I'm trying to test this via trial-and-error, but I'm experiencing issues with this because the server complains that com.ibm.team.process.service.IServerProcess service is not registered (causes an exception). Adding it to the plugin.xml doesn't seem to resolve the issue. Another forum posting seems to suggest that there may need to be a second prerequisite added to the plugin.xml and I'm investigating that (more trial-and-error). But if you can elaborate on what is required and thus save me time, I'd appreciate any further clarification.
I tried to update the above comment, but evidently I don't have enough "reputation" for that. Instead, I'll post this follow up.
If anyone is using this thread to understand how to instantiate an IServerProcess instance, my example above is incorrect. It should look like this:
IProcessServerService pss = getService(IProcessServerService.class);
IServerProcess sp = pss.getServerProcess(operation.getProcessArea());
Of course this also requires that "com.ibm.team.process.service.IProcessServerService" also be added as a requiredService in the plugin.xml.
After that, I'm still not clear on how to use the IServerProcess object to do the advise operation. It takes an AdvisableOperation as its argument, but I'm not sure how to use my pending changes on the myWorkitem.getWorkingCopy() and convert it to an AdvisableOperation to pass to the advise function call.
had to put my response in an answer below
2 other answers
It is probably very hard to check if the user has permission and the whole mechanism allows to create and edit. The permissions are checked when doing the save.
I also think it would be bad design if you could circumvent such basic permissions.
Comments
If the user has no permissions to create the work item then that's fine - as I mentioned I'm happy to not create the other work item and let the save operation continue. My question/problem is that RTC doesn't seem to let the save of the work item continue if the creation of the other work item fails. If I can't check the permissions that's also fine, I just need a way of allowing the save to continue and not throw an error message.
Jared, are you sure you caught all exceptions? I assume if you fail to create the work item if you wrap that and catch everything you should be able to continue gracefully. I am wondering what you did not catch.
@rschoon 100% sure - as I mentioned in my original question I wrapped my entire run() method in a try/catch, and I can see in the debugger that the catch block is getting hit when the the attempt to create the other work item fails. Despite this the operation to save the work item that triggered the participant still fails with the permissions error.
I will try to find some time to do the same stunt 8-)
Um, I would not wrap the run() method, but the call to create/save the work item (maybe I am miss interpreting something) inside of the participants run() operation.
@rschoon Wrapping the entirety of the run() method was done as an option of last resort to make sure there were no other exceptions being thrown - obviously for my production code I'd only catch the exception from the save operation
the help for that datatype says (I have never built one to pass to advise)
An operation advisable by process. Advisable operations can be configured by end users with pre-condition checks (@see
IOperationAdvisor
) and post-operation participation (@see
IOperationParticipant
).
Advisable operations must be declared via extension so that clients can view the list of available operations to configure when authoring their process. Advisable operations are declared on the client as elements of the extension point
com.ibm.team.process.client.configurationPoints
. Operations are declared on the server as elements of the extension point
com.ibm.team.process.service.configurationPoints
.
For example:
<extension point="com.ibm.team.process.client.configurationPoints"> <operation id="com.ibm.example.operation" name="Example Operation"> <action id="foo"> <action id="bar"/> </action> <action id="foo2"> <action id="bar2"/> </action> </operation> </extension>
Advisable operations may not be executed by clients directly. They should instead be passed to the advise and execute methods on the client or server process (@see com.ibm.team.process.client.IClientProcess and com.ibm.team.process.service.IServerProcess).
- Since:
- 0.5
Comments
>Advisable operations must be declared via extension so that clients can view the list of available operations to configure when authoring their process
this means to me that there must already be a workitem save operation that you should be able to locate in some other configuration. I haven't seen an example of that anywhere, and haven't done this myself.