View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.provisioning.api.notification;
20  
21  import java.util.List;
22  import org.apache.syncope.common.lib.types.AuditElements;
23  import org.apache.syncope.core.persistence.api.entity.task.NotificationTask;
24  import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
25  import org.apache.syncope.core.provisioning.api.event.AfterHandlingEvent;
26  
27  /**
28   * Create notification tasks that will be executed by NotificationJob.
29   *
30   * @see org.apache.syncope.core.persistence.api.entity.task.NotificationTask
31   */
32  public interface NotificationManager {
33  
34      /**
35       * Count the number of task executions of a given task with a given status.
36       *
37       * @param taskKey task
38       * @param status status
39       * @return number of task executions
40       */
41      long countExecutionsWithStatus(String taskKey, String status);
42  
43      /**
44       * Checks if notifications are available matching the provided conditions.
45       *
46       * @param type event category type
47       * @param category event category
48       * @param subcategory event subcategory
49       * @param event event
50       * @return created notification tasks
51       */
52      boolean notificationsAvailable(
53              AuditElements.EventCategoryType type,
54              String category,
55              String subcategory,
56              String event);
57  
58      /**
59       * Create notification tasks according to the provided event.
60       *
61       * @param event Spring event raised during Logic processing
62       */
63      void createTasks(AfterHandlingEvent event);
64  
65      /**
66       * Create notification tasks for each notification matching provided conditions.
67       *
68       * @param who user triggering the event
69       * @param type event category type
70       * @param category event category
71       * @param subcategory event subcategory
72       * @param event event
73       * @param condition result value condition.
74       * @param before object(s) availabile before the event
75       * @param output object(s) produced by the event
76       * @param input object(s) provided to the event
77       * @return created notification tasks
78       */
79      @SuppressWarnings("squid:S00107")
80      List<NotificationTask> createTasks(
81              String who,
82              AuditElements.EventCategoryType type,
83              String category,
84              String subcategory,
85              String event,
86              AuditElements.Result condition,
87              Object before,
88              Object output,
89              Object... input);
90  
91      long getMaxRetries();
92  
93      /**
94       * Set execution state of NotificationTask with provided id.
95       *
96       * @param taskKey task to be updated
97       * @param executed execution state
98       */
99      void setTaskExecuted(String taskKey, boolean executed);
100 
101     /**
102      * Store execution of a NotificationTask.
103      *
104      * @param execution task execution.
105      * @return merged task execution.
106      */
107     TaskExec<NotificationTask> storeExec(TaskExec<NotificationTask> execution);
108 }