-
Notifications
You must be signed in to change notification settings - Fork 188
/
ModelExecuteOptions.java
608 lines (517 loc) · 17.5 KB
/
ModelExecuteOptions.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.model.api;
import com.evolveum.midpoint.schema.AbstractOptions;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationBusinessContextType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PartialProcessingOptionsType;
import java.io.Serializable;
import java.util.List;
/**
* Options for execution of Model operations. These options influence the way how the operations are executed.
* The options are not mandatory. All options have reasonable default values. They may not be specified at all.
*
* @author semancik
*/
public class ModelExecuteOptions extends AbstractOptions implements Serializable, Cloneable {
/**
* Force the operation even if it would otherwise fail due to external failure. E.g. attempt to delete an account
* that no longer exists on resource may fail without a FORCE option. If FORCE option is used then the operation is
* finished even if the account does not exist (e.g. at least shadow is removed from midPoint repository).
*/
private Boolean force;
/**
* Avoid any smart processing of the data except for schema application. Do not synchronize the data, do not apply
* any expressions, etc.
*/
private Boolean raw;
/**
* Encrypt any cleartext data on write, decrypt any encrypted data on read. Applies only to the encrypted
* data formats (ProtectedString, ProtectedByteArray).
* It is not recommended to use in production environment. This option is provided only for diagnostic
* purposes to be used in development environments.
*/
private Boolean noCrypt;
/**
* Option to reconcile focus and all projections while executing changes.
* (implies reconcileFocus)
*/
private Boolean reconcile;
/**
* Option to reconcile focus while executing changes.
* If this option is set and the reconcile option is not set then the projections
* reconciliation will not be forced (but it may still happen if other configuration
* loads full projection).
*/
private Boolean reconcileFocus;
/**
* Option to reconcile affected objects after executing changes.
* Typical use: after a role is changed, all users that have been assigned this role
* would be reconciled.
*
* Because it is difficult to determine all affected objects (e.g. users that have
* indirectly assigned a role), midPoint does a reasonable attempt to determine
* and reconcile them. E.g. it may be limited to a direct assignees.
*
* Also, because of time complexity, the reconciliation may be executed in
* a separate background task.
*/
private Boolean reconcileAffected;
/**
* Option to execute changes as soon as they are approved. (For the primary stage approvals, the default behavior
* is to wait until all changes are approved/rejected and then execute the operation as a whole.)
*/
private Boolean executeImmediatelyAfterApproval;
/**
* Option to user overwrite flag. It can be used from web service, if we want to re-import some object
*/
private Boolean overwrite;
/**
* Option to simulate import operation. E.g. search filters will be resolved.
*/
private Boolean isImport;
/**
* Causes reevaluation of search filters (producing partial errors on failure).
*/
private Boolean reevaluateSearchFilters;
/**
* Option to limit propagation only for the source resource
*/
private Boolean limitPropagation;
/**
* Is this operation already authorized, i.e. should it be executed without any further authorization checks?
* EXPERIMENTAL. Currently supported only for raw executions.
*/
private Boolean preAuthorized;
/**
* Business context that describes this request.
*/
private OperationBusinessContextType requestBusinessContext;
/**
* Options that control selective execution of model logic.
* Use with extreme care. Some combinations may be dangerous.
*/
private PartialProcessingOptionsType partialProcessing;
public Boolean getForce() {
return force;
}
public void setForce(Boolean force) {
this.force = force;
}
public static boolean isForce(ModelExecuteOptions options) {
if (options == null) {
return false;
}
if (options.force == null) {
return false;
}
return options.force;
}
public static ModelExecuteOptions createForce() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setForce(true);
return opts;
}
public ModelExecuteOptions setForce() {
setForce(true);
return this;
}
public Boolean getRaw() {
return raw;
}
public void setRaw(Boolean raw) {
this.raw = raw;
}
public static boolean isRaw(ModelExecuteOptions options) {
if (options == null) {
return false;
}
if (options.raw == null) {
return false;
}
return options.raw;
}
public static ModelExecuteOptions createRaw() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setRaw(true);
return opts;
}
public ModelExecuteOptions setRaw() {
setRaw(true);
return this;
}
public Boolean getNoCrypt() {
return noCrypt;
}
public void setNoCrypt(Boolean noCrypt) {
this.noCrypt = noCrypt;
}
public static boolean isNoCrypt(ModelExecuteOptions options) {
if (options == null) {
return false;
}
if (options.noCrypt == null) {
return false;
}
return options.noCrypt;
}
public static ModelExecuteOptions createNoCrypt() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setNoCrypt(true);
return opts;
}
public ModelExecuteOptions setNoCrypt() {
setNoCrypt(true);
return this;
}
public Boolean getReconcile() {
return reconcile;
}
public void setReconcile(Boolean reconcile) {
this.reconcile = reconcile;
}
public static boolean isReconcile(ModelExecuteOptions options) {
if (options == null){
return false;
}
if (options.reconcile == null){
return false;
}
return options.reconcile;
}
public static ModelExecuteOptions createReconcile() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setReconcile(true);
return opts;
}
public ModelExecuteOptions setReconcile() {
setReconcile(true);
return this;
}
public Boolean getReconcileFocus() {
return reconcileFocus;
}
public void setReconcileFocus(Boolean reconcileFocus) {
this.reconcileFocus = reconcileFocus;
}
public static ModelExecuteOptions createReconcileFocus() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setReconcileFocus(true);
return opts;
}
public static boolean isReconcileFocus(ModelExecuteOptions options) {
if (options == null){
return false;
}
if (options.reconcileFocus == null){
return false;
}
return options.reconcileFocus;
}
public Boolean getReconcileAffected() {
return reconcileAffected;
}
public void setReconcileAffected(Boolean reconcile) {
this.reconcileAffected = reconcile;
}
public static boolean isReconcileAffected(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.reconcileAffected == null){
return false;
}
return options.reconcileAffected;
}
public static ModelExecuteOptions createReconcileAffected(){
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setReconcileAffected(true);
return opts;
}
public ModelExecuteOptions setReconcileAffected() {
setReconcileAffected(true);
return this;
}
public Boolean getOverwrite() {
return overwrite;
}
public void setOverwrite(Boolean overwrite) {
this.overwrite = overwrite;
}
public static boolean isOverwrite(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.overwrite == null){
return false;
}
return options.overwrite;
}
public static ModelExecuteOptions createOverwrite(){
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setOverwrite(true);
return opts;
}
public ModelExecuteOptions setOverwrite() {
setOverwrite(true);
return this;
}
public Boolean getIsImport() {
return isImport;
}
public void setIsImport(Boolean isImport) {
this.isImport = isImport;
}
public static boolean isIsImport(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.isImport == null){
return false;
}
return options.isImport;
}
public static ModelExecuteOptions createIsImport(){
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setIsImport(true);
return opts;
}
public ModelExecuteOptions setIsImport(){
setIsImport(true);
return this;
}
public void setExecuteImmediatelyAfterApproval(Boolean executeImmediatelyAfterApproval) {
this.executeImmediatelyAfterApproval = executeImmediatelyAfterApproval;
}
public static boolean isExecuteImmediatelyAfterApproval(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.executeImmediatelyAfterApproval == null) {
return false;
}
return options.executeImmediatelyAfterApproval;
}
public static ModelExecuteOptions createExecuteImmediatelyAfterApproval(){
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setExecuteImmediatelyAfterApproval(true);
return opts;
}
public void setLimitPropagation(Boolean limitPropagation) {
this.limitPropagation = limitPropagation;
}
public static boolean isLimitPropagation(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.limitPropagation == null){
return false;
}
return options.limitPropagation;
}
public static ModelExecuteOptions createLimitPropagation() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setLimitPropagation(true);
return opts;
}
public ModelExecuteOptions setLimitPropagation() {
setLimitPropagation(true);
return this;
}
public Boolean getReevaluateSearchFilters() {
return reevaluateSearchFilters;
}
public void setReevaluateSearchFilters(Boolean reevaluateSearchFilters) {
this.reevaluateSearchFilters = reevaluateSearchFilters;
}
public static boolean isReevaluateSearchFilters(ModelExecuteOptions options){
if (options == null){
return false;
}
if (options.reevaluateSearchFilters == null){
return false;
}
return options.reevaluateSearchFilters;
}
public static ModelExecuteOptions createReevaluateSearchFilters(){
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setReevaluateSearchFilters(true);
return opts;
}
public ModelExecuteOptions setReevaluateSearchFilters(){
setReevaluateSearchFilters(true);
return this;
}
public Boolean getPreAuthorized() {
return preAuthorized;
}
public void setPreAuthorized(Boolean value) {
this.preAuthorized = value;
}
public static boolean isPreAuthorized(ModelExecuteOptions options) {
if (options == null) {
return false;
}
if (options.preAuthorized == null){
return false;
}
return options.preAuthorized;
}
public static ModelExecuteOptions createPreAuthorized() {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setPreAuthorized(true);
return opts;
}
public ModelExecuteOptions setPreAuthorized() {
setPreAuthorized(true);
return this;
}
public OperationBusinessContextType getRequestBusinessContext() {
return requestBusinessContext;
}
public void setRequestBusinessContext(OperationBusinessContextType requestBusinessContext) {
this.requestBusinessContext = requestBusinessContext;
}
public static OperationBusinessContextType getRequestBusinessContext(ModelExecuteOptions options) {
if (options == null) {
return null;
}
return options.getRequestBusinessContext();
}
public static ModelExecuteOptions createRequestBusinessContext(OperationBusinessContextType requestBusinessContext) {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setRequestBusinessContext(requestBusinessContext);
return opts;
}
public PartialProcessingOptionsType getPartialProcessing() {
return partialProcessing;
}
public void setPartialProcessing(PartialProcessingOptionsType partialProcessing) {
this.partialProcessing = partialProcessing;
}
public static PartialProcessingOptionsType getPartialProcessing(ModelExecuteOptions options) {
if (options == null) {
return null;
}
return options.getPartialProcessing();
}
public static ModelExecuteOptions createPartialProcessing(PartialProcessingOptionsType partialProcessing) {
ModelExecuteOptions opts = new ModelExecuteOptions();
opts.setPartialProcessing(partialProcessing);
return opts;
}
public ModelExecuteOptionsType toModelExecutionOptionsType() {
ModelExecuteOptionsType retval = new ModelExecuteOptionsType();
retval.setForce(force);
retval.setRaw(raw);
retval.setNoCrypt(noCrypt);
retval.setReconcile(reconcile);
retval.setReconcileFocus(reconcileFocus);
retval.setExecuteImmediatelyAfterApproval(executeImmediatelyAfterApproval);
retval.setOverwrite(overwrite);
retval.setIsImport(isImport);
retval.setLimitPropagation(limitPropagation);
retval.setReevaluateSearchFilters(reevaluateSearchFilters);
// preAuthorized is purposefully omitted (security reasons)
retval.setRequestBusinessContext(requestBusinessContext);
retval.setPartialProcessing(partialProcessing);
return retval;
}
public static ModelExecuteOptions fromModelExecutionOptionsType(ModelExecuteOptionsType type) {
if (type == null) {
return null;
}
ModelExecuteOptions retval = new ModelExecuteOptions();
retval.setForce(type.isForce());
retval.setRaw(type.isRaw());
retval.setNoCrypt(type.isNoCrypt());
retval.setReconcile(type.isReconcile());
retval.setReconcileFocus(type.isReconcileFocus());
retval.setExecuteImmediatelyAfterApproval(type.isExecuteImmediatelyAfterApproval());
retval.setOverwrite(type.isOverwrite());
retval.setIsImport(type.isIsImport());
retval.setLimitPropagation(type.isLimitPropagation());
retval.setReevaluateSearchFilters(type.isReevaluateSearchFilters());
// preAuthorized is purposefully omitted (security reasons)
retval.setRequestBusinessContext(type.getRequestBusinessContext());
retval.setPartialProcessing(type.getPartialProcessing());
return retval;
}
public static ModelExecuteOptions fromRestOptions(List<String> options){
if (options == null || options.isEmpty()){
return null;
}
ModelExecuteOptions retVal = new ModelExecuteOptions();
for (String option : options){
if (ModelExecuteOptionsType.F_RAW.getLocalPart().equals(option)){
retVal.setRaw(true);
}
if (ModelExecuteOptionsType.F_EXECUTE_IMMEDIATELY_AFTER_APPROVAL.getLocalPart().equals(option)){
retVal.setExecuteImmediatelyAfterApproval(true);
}
if (ModelExecuteOptionsType.F_FORCE.getLocalPart().equals(option)){
retVal.setForce(true);
}
if (ModelExecuteOptionsType.F_NO_CRYPT.getLocalPart().equals(option)){
retVal.setNoCrypt(true);
}
if (ModelExecuteOptionsType.F_OVERWRITE.getLocalPart().equals(option)){
retVal.setOverwrite(true);
}
if (ModelExecuteOptionsType.F_RECONCILE.getLocalPart().equals(option)){
retVal.setReconcile(true);
}
if (ModelExecuteOptionsType.F_IS_IMPORT.getLocalPart().equals(option)){
retVal.setIsImport(true);
}
if (ModelExecuteOptionsType.F_LIMIT_PROPAGATION.getLocalPart().equals(option)){
retVal.setIsImport(true);
}
if (ModelExecuteOptionsType.F_REEVALUATE_SEARCH_FILTERS.getLocalPart().equals(option)){
retVal.setReevaluateSearchFilters(true);
}
// preAuthorized is purposefully omitted (security reasons)
}
return retVal;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ModelExecuteOptions(");
appendFlag(sb, "executeImmediatelyAfterApproval", executeImmediatelyAfterApproval);
appendFlag(sb, "force", force);
appendFlag(sb, "isImport", isImport);
appendFlag(sb, "limitPropagation", limitPropagation);
appendFlag(sb, "noCrypt", noCrypt);
appendFlag(sb, "overwrite", overwrite);
appendFlag(sb, "preAuthorized", preAuthorized);
appendFlag(sb, "raw", raw);
appendFlag(sb, "reconcile", reconcile);
appendFlag(sb, "reconcileFocus", reconcileFocus);
appendFlag(sb, "reevaluateSearchFilters", reevaluateSearchFilters);
appendFlag(sb, "reconcileAffected", reconcileAffected);
appendFlag(sb, "requestBusinessContext", requestBusinessContext == null ? null : true);
appendFlag(sb, "partialProcessing", partialProcessing == null ? null : true);
removeLastComma(sb);
sb.append(")");
return sb.toString();
}
public ModelExecuteOptions clone() {
// not much efficient, but...
ModelExecuteOptions clone = fromModelExecutionOptionsType(toModelExecutionOptionsType());
clone.setPreAuthorized(this.preAuthorized);
return clone;
}
}