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.pushpull;
20  
21  import java.util.Collections;
22  import java.util.Set;
23  import org.apache.syncope.common.lib.to.ProvisioningReport;
24  import org.apache.syncope.core.persistence.api.entity.Entity;
25  import org.quartz.JobExecutionException;
26  
27  /**
28   * Interface for actions to be performed during push.
29   * All methods can throw {@link IgnoreProvisionException} to make the current entity ignored by the push process.
30   */
31  public interface PushActions extends ProvisioningActions {
32  
33      /**
34       * Return additional attributes to include in the result from the underlying connector.
35       *
36       * @param profile profile of the pull being executed.
37       * @param entity entity
38       * @return additional attributes to include in the result from the underlying connector
39       */
40      default Set<String> moreAttrsToGet(ProvisioningProfile<?, ?> profile, Entity entity) {
41          return Collections.emptySet();
42      }
43  
44      /**
45       * Action to be executed before to assign (link &amp; provision) a pushed entity to the resource.
46       *
47       * @param profile profile of the push being executed.
48       * @param entity entity to be created.
49       * @return entity.
50       * @throws JobExecutionException in case of generic failure
51       */
52      default Entity beforeAssign(
53              ProvisioningProfile<?, ?> profile,
54              Entity entity) throws JobExecutionException {
55  
56          return entity;
57      }
58  
59      /**
60       * Action to be executed before to provision a pushed entity to the resource.
61       *
62       * @param profile profile of the push being executed.
63       * @param entity entity to be created.
64       * @return entity.
65       * @throws JobExecutionException in case of generic failure
66       */
67      default Entity beforeProvision(
68              ProvisioningProfile<?, ?> profile,
69              Entity entity) throws JobExecutionException {
70  
71          return entity;
72      }
73  
74      /**
75       * Action to be executed before to update a pushed entity on the resource.
76       *
77       * @param profile profile of the push being executed.
78       * @param entity entity to be updated.
79       * @return entity.
80       * @throws JobExecutionException in case of generic failure
81       */
82      default Entity beforeUpdate(
83              ProvisioningProfile<?, ?> profile,
84              Entity entity) throws JobExecutionException {
85  
86          return entity;
87      }
88  
89      /**
90       * Action to be executed before to link a pushed entity to the resource.
91       *
92       * @param profile profile of the push being executed.
93       * @param entity entity to be created.
94       * @return entity.
95       * @throws JobExecutionException in case of generic failure
96       */
97      default Entity beforeLink(
98              ProvisioningProfile<?, ?> profile,
99              Entity entity) throws JobExecutionException {
100 
101         return entity;
102     }
103 
104     /**
105      * Action to be executed before to unlink a pushed entity from the resource.
106      *
107      * @param profile profile of the push being executed.
108      * @param entity entity to be created.
109      * @return entity.
110      * @throws JobExecutionException in case of generic failure
111      */
112     default Entity beforeUnlink(
113             ProvisioningProfile<?, ?> profile,
114             Entity entity) throws JobExecutionException {
115 
116         return entity;
117     }
118 
119     /**
120      * Action to be executed before to unassign a pushed entity from the resource.
121      *
122      * @param profile profile of the push being executed.
123      * @param entity entity to be created.
124      * @return entity.
125      * @throws JobExecutionException in case of generic failure
126      */
127     default Entity beforeUnassign(
128             ProvisioningProfile<?, ?> profile,
129             Entity entity) throws JobExecutionException {
130 
131         return entity;
132     }
133 
134     /**
135      * Action to be executed before to unassign a pushed entity from the resource.
136      *
137      * @param profile profile of the push being executed.
138      * @param entity entity to be created.
139      * @return entity.
140      * @throws JobExecutionException in case of generic failure
141      */
142     default Entity beforeDeprovision(
143             ProvisioningProfile<?, ?> profile,
144             Entity entity) throws JobExecutionException {
145 
146         return entity;
147     }
148 
149     /**
150      * Action to be executed before delete a pushed entity locally and from the resource.
151      *
152      * @param profile profile of the push being executed.
153      * @param entity entity to be created.
154      * @return entity.
155      * @throws JobExecutionException in case of generic failure
156      */
157     default Entity beforeDelete(
158             ProvisioningProfile<?, ?> profile,
159             Entity entity) throws JobExecutionException {
160 
161         return entity;
162     }
163 
164     /**
165      * Action to be executed after entity push goes on error.
166      *
167      * @param profile profile of the push being executed.
168      * @param entity pushed entity.
169      * @param result operation result.
170      * @param error error being reported
171      * @throws JobExecutionException in case of generic failure
172      */
173     default void onError(
174             ProvisioningProfile<?, ?> profile,
175             Entity entity,
176             ProvisioningReport result,
177             Exception error) throws JobExecutionException {
178 
179         // do nothing
180     }
181 
182     /**
183      * Action to be executed after each local entity push.
184      *
185      * @param profile profile of the push being executed.
186      * @param entity pushed entity.
187      * @param result operation result.
188      * @throws JobExecutionException in case of generic failure
189      */
190     default void after(
191             ProvisioningProfile<?, ?> profile,
192             Entity entity,
193             ProvisioningReport result) throws JobExecutionException {
194 
195         // do nothing
196     }
197 }