On 25/04/2012 09:30, Bob Lannoy wrote:
Hi,
I'm looking at the workflow functionality in Syncope but there's very little
info on this.
This is definitely true: I've just added something about the workflow
documentation in the roadmap.
I have several questions:
- Do you create the workflow file by hand or do you use a tool like Activiti
designer?
You can do as you prefer: only, consider that currently the only way to
update the workflow definition is via REST (a more handful way is via
admin console, of course): hence, if you want to use Activiti Eclipse
Designer, you have to manually take care of exporting / importing XML data.
I don't know if Activiti Eclipse Designer or Signavio [1] can handle
load / save from something like WebDAV: in this case we could think to
provide such kind of access to workflow definition.
- When is the workflow triggered?
Workflow is currently triggered for every REST operation about users.
Consider that Activiti is just the default implementation
(ActivitiUserWorkflowAdapter class), but you can provide your own by
implementing UserWorkflowAdapter or extending AbstractUserWorkflowAdapter.
Workflow triggering can also be disabled by using the provided
NoOpUserWorkflowAdapter class.
You can choose which workflow adapter to use in the workflow.properties
file.
- There's a "generateToken" in the workflow.xml. From an earlier discussion I
though that this might send an email to the user? Do I need to enable the notifications
for that? (i tried setting notifications but get no mail)
Notifications are bound to one or more workflow events (serviceTask for
Activiti), but separated from actual workflow implementation. This in
order to provide a way - independent from your particular
UserWorkflowAdapter implementation - to manage notifications at high level.
However, if the specific implementation allows e-mail sending - and
Activiti does - you can of course send e-mails from within the workflow
definition.
The "generateToken" service task in userWorkflow.bpmn20.xml is commented
out because it is part of an example about how to implement a simple
double opt-in process.
If you want to try this out, comment
<sequenceFlow id="flow4" sourceRef="activate" targetRef="active"/>
and uncomment
<serviceTask id="generateToken" name="Generate token"
activiti:class="org.apache.syncope.core.workflow.activiti.GenerateToken"/>
<sequenceFlow id="flowN+1" sourceRef="generateToken" targetRef="Created"/>
<userTask id="created" name="Created"/>
<sequenceFlow id="flowN+2" sourceRef="created" targetRef="createdGw"/>
<exclusiveGateway id="createdGw"/>
<sequenceFlow id="created2Activate" sourceRef="createdGw"
targetRef="activate">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${task == 'activate' && syncopeUser.checkToken(token)}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="created2Created" sourceRef="createdGw"
targetRef="created">
<conditionExpression xsi:type="tFormalExpression">
<![CDATA[${task == 'activate' && !syncopeUser.checkToken(token)}]]>
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="created2Delete" sourceRef="createdGw" targetRef="delete">
<conditionExpression xsi:type="tFormalExpression">${task ==
'delete'}</conditionExpression>
</sequenceFlow>
<scriptTask id="activate" name="Activate" scriptFormat="juel">
<script>
syncopeUser.removeToken()
</script>
</scriptTask>
<sequenceFlow id="flowN+3" sourceRef="activate" targetRef="active"/>
Basically, this flow will first generate a random token for the current
user (by the class
org.apache.syncope.core.workflow.activiti.GenerateToken), then if the
required task is 'activate', the generated token will be compared with
the token provided as input to the 'activate' task and the current user
moved to the 'activate' scriptTask only if the tokens match. If,
instead, the required task is 'delete', the user will be simply moved to
the 'delete' task.
If you want to send an e-mail to the user right after the token is
generated, you will need to change
<sequenceFlow id="flowN+1" sourceRef="generateToken" targetRef="Created"/>
<userTask id="created" name="Created"/>
to something like
<sequenceFlow id="flowN+1" sourceRef="generateToken"
targetRef="NotifyToken"/>
<serviceTask id="notifyToken" name="NotifyToken"
activiti:class="my.package.SendTokenByMail"/>
<sequenceFlow id="flowN+1.5" sourceRef="notifyToken" targetRef="Created"/>
<userTask id="created" name="Created"/>
and also to provide the logic for composing and sending the e-mail in
the SendTokenByMail class; if you want an example, take a look at
NotificationJob.executeSingle() [2].
You can also use a predefined Activiti Email task (
http://activiti.org/userguide/index.html#bpmnEmailTask).
- Is there a way to follow the workflows steps in some sort of debug mode?
Hum, you can for example add two new log appenders for
"org.apache.syncope.core.workflow.ActivitiUserWorkflowAdapter" and
"org.activiti" at DEBUG level in your logback.xml and then watch your logs.
Regards.
[1] http://code.google.com/p/signavio-core-components/
[2]
http://svn.apache.org/repos/asf/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/scheduling/NotificationJob.java
[3] http://activiti.org/userguide/index.html#bpmnEmailTask
--
Francesco Chicchiriccò
Apache Cocoon PMC and Apache Syncope PPMC Member
http://people.apache.org/~ilgrosso/