class AlarmService {

    public Alarm updateAlarm(final Alarm alarm) {
        LOGGER.debug("Update alarm to: " + alarm);

        validateUpdatable(alarm);

        try {
            seyrenRepository.updateAlarm(alarm);

            if(alarm.isEnabled()) {
                notificationHandler.sendAlarmHasBeenModified(alarm);
            } else{
                notificationHandler.sendAlarmHasBeenDeactivated(alarm);
            }

            return this.searchAlarmByName(alarm.getName());
        } catch (RuntimeException exception) {
            LOGGER.error("Error updating alarm", exception);
            throw new CerebroException(ErrorCode.CEREBRO_UNKNOWN_ERROR, "Error updating alarm", exception);
        }
    }

}