1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.identitystore.v3.web.service;
35
36 import fr.paris.lutece.plugins.identitystore.v3.business.IExternalAttributeSource;
37 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.common.AttributeDto;
38 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.common.IdentityDto;
39 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.common.RequestAuthor;
40 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.crud.IdentityChangeRequest;
41 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.crud.IdentityChangeResponse;
42 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.exporting.IdentityExportRequest;
43 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.exporting.IdentityExportResponse;
44 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.history.IdentityHistoryGetResponse;
45 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.history.IdentityHistorySearchRequest;
46 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.history.IdentityHistorySearchResponse;
47 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.search.IdentitySearchRequest;
48 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.search.IdentitySearchResponse;
49 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.search.UpdatedIdentitySearchRequest;
50 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.search.UpdatedIdentitySearchResponse;
51 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.task.IdentityTaskCreateRequest;
52 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.task.IdentityTaskCreateResponse;
53 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.task.IdentityTaskGetResponse;
54 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.task.IdentityTaskGetStatusResponse;
55 import fr.paris.lutece.plugins.identitystore.v3.web.rs.dto.task.IdentityTaskListGetResponse;
56 import fr.paris.lutece.plugins.identitystore.web.exception.IdentityStoreException;
57 import fr.paris.lutece.portal.service.util.AppException;
58
59 import java.util.List;
60
61
62
63
64 public class IdentityService
65 {
66
67 protected IIdentityTransportProvider _transportProvider;
68 protected List<IExternalAttributeSource> _listExternalAttributesSource;
69
70
71
72
73 public IdentityService( )
74 {
75 super( );
76 }
77
78
79
80
81
82
83
84 public IdentityService( IIdentityTransportProvider transportProvider )
85 {
86 super( );
87 this._transportProvider = transportProvider;
88 }
89
90
91
92
93
94
95
96 public void setTransportProvider( IIdentityTransportProvider transportProvider )
97 {
98 this._transportProvider = transportProvider;
99 }
100
101
102
103
104
105
106 public void setExternalAttributesSourceList( List<IExternalAttributeSource> listExternalAttributesSource )
107 {
108 this._listExternalAttributesSource = listExternalAttributesSource;
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125 public IdentitySearchResponse getIdentityByConnectionId( final String strConnectionId, final String strClientCode, final RequestAuthor author )
126 throws AppException, IdentityStoreException
127 {
128 final IdentitySearchRequest request = new IdentitySearchRequest( );
129 request.setConnectionId( strConnectionId );
130 return searchIdentities( request, strClientCode, author );
131 }
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147 public IdentitySearchResponse getIdentityByCustomerId( final String strCustomerId, final String strClientCode, final RequestAuthor author )
148 throws AppException, IdentityStoreException
149 {
150 return getIdentity( strCustomerId, strClientCode, author );
151 }
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167 public IdentitySearchResponse getIdentity( final String strCustomerId, final String strClientCode, final RequestAuthor author )
168 throws AppException, IdentityStoreException
169 {
170 IdentitySearchResponse identitySearchResponse = _transportProvider.getIdentity( strCustomerId, strClientCode, author );
171
172 return identitySearchResponseWithAdditionnalData( identitySearchResponse );
173 }
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191 public IdentityChangeResponse updateIdentity( final String customerId, final IdentityChangeRequest identityChange, final String strClientCode,
192 final RequestAuthor author ) throws AppException, IdentityStoreException
193 {
194 return _transportProvider.updateIdentity( customerId, identityChange, strClientCode, author );
195 }
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213 public IdentityChangeResponse createIdentity( final IdentityChangeRequest identityChange, final String strClientCode, final RequestAuthor author )
214 throws AppException, IdentityStoreException
215 {
216 return _transportProvider.createIdentity( identityChange, strClientCode, author );
217 }
218
219
220
221
222
223
224
225
226
227
228
229
230 public IdentityChangeResponse deleteIdentity( final String strCustomerId, final String strClientCode, final RequestAuthor author )
231 throws IdentityStoreException
232 {
233 return _transportProvider.deleteIdentity( strCustomerId, strClientCode, author );
234 }
235
236
237
238
239
240
241
242
243
244
245
246
247
248 public IdentitySearchResponse searchIdentities( final IdentitySearchRequest identitySearchRequest, final String strClientCode, final RequestAuthor author )
249 throws IdentityStoreException
250 {
251 return _transportProvider.searchIdentities( identitySearchRequest, strClientCode, author );
252 }
253
254
255
256
257
258
259
260
261
262
263
264
265 public IdentityHistoryGetResponse getIdentityHistory( final String strCustomerId, final String strClientCode, final RequestAuthor author )
266 throws IdentityStoreException
267 {
268 return _transportProvider.getIdentityHistory( strCustomerId, strClientCode, author );
269 }
270
271
272
273
274
275
276
277
278
279
280
281
282 public IdentityHistorySearchResponse searchIdentityHistory( final IdentityHistorySearchRequest request, final String strClientCode,
283 final RequestAuthor author ) throws IdentityStoreException
284 {
285 return _transportProvider.searchIdentityHistory( request, strClientCode, author );
286 }
287
288
289
290
291
292
293
294
295
296
297
298
299 public UpdatedIdentitySearchResponse getUpdatedIdentities( final UpdatedIdentitySearchRequest request, final String strClientCode,
300 final RequestAuthor author ) throws IdentityStoreException
301 {
302 return _transportProvider.getUpdatedIdentities( request, strClientCode, author );
303 }
304
305
306
307
308
309
310
311
312
313
314 public IdentityExportResponse exportIdentities( final IdentityExportRequest request, final String strClientCode, final RequestAuthor author )
315 throws IdentityStoreException
316 {
317 return _transportProvider.exportIdentities( request, strClientCode, author );
318 }
319
320
321
322
323
324
325
326
327
328 public IdentityTaskCreateResponse createIdentityTask(final IdentityTaskCreateRequest request, final String strClientCode, final RequestAuthor author ) throws IdentityStoreException
329 {
330 return _transportProvider.createIdentityTask( request, strClientCode, author );
331 }
332
333
334
335
336
337
338
339
340
341 public IdentityTaskGetStatusResponse getIdentityTaskStatus( final String taskCode, final String strClientCode, final RequestAuthor author ) throws IdentityStoreException
342 {
343 return _transportProvider.getIdentityTaskStatus( taskCode, strClientCode, author );
344 }
345
346
347
348
349
350
351
352
353
354
355 public IdentityTaskListGetResponse getIdentityTaskList(final String resourceId, final String resourceType, final String strClientCode, final RequestAuthor author ) throws IdentityStoreException
356 {
357 return _transportProvider.getIdentityTaskList( resourceId, resourceType, strClientCode, author );
358 }
359
360
361
362
363
364
365
366
367
368 private IdentitySearchResponse identitySearchResponseWithAdditionnalData( final IdentitySearchResponse identitySearchResponse )
369 throws IdentityStoreException
370 {
371
372 if ( _listExternalAttributesSource == null )
373 {
374 return identitySearchResponse;
375 }
376
377 try
378 {
379
380 for ( IExternalAttributeSource source : _listExternalAttributesSource )
381 {
382
383 for ( final IdentityDto identity : identitySearchResponse.getIdentities( ) )
384 {
385 List<AttributeDto> listAdditionnalAttributes = source.getAdditionnalAttributes( identity.getCustomerId( ) );
386
387 identity.getAttributes( ).addAll( listAdditionnalAttributes );
388 }
389 }
390 }
391 catch( Exception e )
392 {
393 throw new IdentityStoreException( e.getMessage( ) );
394 }
395
396 return identitySearchResponse;
397 }
398
399 }