1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.flowable.task;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.apache.syncope.common.lib.to.UserTO;
23 import org.apache.syncope.common.lib.types.AuditElements;
24 import org.apache.syncope.core.flowable.impl.FlowableRuntimeUtils;
25 import org.apache.syncope.core.persistence.api.entity.user.User;
26 import org.apache.syncope.core.provisioning.api.notification.NotificationManager;
27 import org.flowable.engine.delegate.DelegateExecution;
28
29
30
31
32
33
34 public class Notify extends FlowableServiceTask {
35
36 protected final NotificationManager notificationManager;
37
38 public Notify(final NotificationManager notificationManager) {
39 this.notificationManager = notificationManager;
40 }
41
42 @Override
43 protected void doExecute(final DelegateExecution execution) {
44 User user = execution.getVariable(FlowableRuntimeUtils.USER, User.class);
45 UserTO userTO = execution.getVariable(FlowableRuntimeUtils.USER_TO, UserTO.class);
46 String event = execution.getVariable(FlowableRuntimeUtils.EVENT, String.class);
47 String wfExecutor = execution.getVariable(FlowableRuntimeUtils.WF_EXECUTOR, String.class);
48
49 if (StringUtils.isNotBlank(event)) {
50 notificationManager.createTasks(
51 wfExecutor,
52 AuditElements.EventCategoryType.CUSTOM,
53 null,
54 null,
55 event,
56 AuditElements.Result.SUCCESS,
57 userTO,
58 null,
59 user.getToken());
60 } else {
61 LOG.debug("Not sending any notification since no event was found");
62 }
63 }
64 }