Apache Syncope can be instructed to send out notification e-mails when certain events occur.
In this post, we provide two examples to send notification: one while creating a new user (predefined event), and the other while executing a custom task.
First, we need to create a new template, from Configuration -> Notifications, choose the Templates tab and click on add button
After creating the new template, you can customize this template for plain-text and HTML e-mails
Then, from Notifications tab, add a new notification as follows:
Custom events can be used to trigger notifications from non-predefined joint points.
Here, we are going to define a simple custom task, the logic behind it is just to find a specific user and send a notification.
To create a new custom task, the implementation can be done either by Java or Groovy; in the case of Java, it is required to add a new class as the example below:
public class NewSchedTask extends AbstractSchedTaskJobDelegate {
@Autowired
private UserDataBinder userDataBinder;
@Autowired
private UserDAO userDAO;
@Override
protected String doExecute(boolean bln) throws JobExecutionException {
final User user = userDAO.findByUsername("newUser");
final UserTO userTO = userDataBinder.getUserTO(user, false);
LOG.info("Send notification after excuting New Task");
notificationManager.createTasks(AuditElements.EventCategoryType.CUSTOM,
null,
null,
"excuteNewTask",
AuditElements.Result.SUCCESS,
userTO,
null,
(Object) null);
return "SUCCESS";
}
}
Then from Configuration -> Implementations, TASKJOB_DELEGATE tab, click on add button, then choose:
Now follow the same steps as before to create the template, and then add a new notification taking into consideration the following different configuration:
NOTE: e-mail configuration is needed in order to fully complete the two examples before and effectively deliver the notification e-mails.