/
GetOperationOptions.java
1091 lines (959 loc) · 37.9 KB
/
GetOperationOptions.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
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2010-2018 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.schema;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.UniformItemPath;
import com.evolveum.midpoint.prism.path.ItemPathCollectionsUtil;
import com.evolveum.midpoint.util.ShortDumpable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.GetOperationOptionsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.IterationMethodType;
import org.apache.commons.collections4.CollectionUtils;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**
* @author semancik
*
*/
public class GetOperationOptions extends AbstractOptions implements Serializable, Cloneable, ShortDumpable {
private static final long serialVersionUID = 1L;
public static final GetOperationOptions EMPTY = new GetOperationOptions();
/**
* Specifies whether to return specific items. It is used for optimizations.
* Some requests only needs a subset of items therefore fetching them all is a waste
* of resources. Other requests may need expensive data that are not normally returned by default.
* <p>
* If no retrieve option is set in the entire options set then it
* means that the whole object with a default set of properties has to be
* returned. This is equivalent to specifying DEFAULT retrieve root option.
* <p>
* If there is at least one retrieve option in the set then the following rules apply:
* <ul>
* <li>Items marked as INCLUDE will be returned.</li>
* <li>Any item marked as EXCLUDE may not be returned. (Note: Excluded items may still be returned if their retrieval is cheap.)</li>
* <li>Items marked as DEFAULT will be returned if they would also be returned without any options (by default).</li>
* <li>Items that are not marked (have no option or have null retrieve option) but their superitem is marked (have retrieve option)
* behave in the same way as superitem. E.g. if a superitem is marked as
* INCLUDE they will also be included in the result. This also applies transitively (e.g. superitem of superitem).
* <li>If a superitem is marked as EXCLUDE and subitem is marked as INCLUDE then the behavior is undefined. Do not do this. Strange things may happen.</li>
* <li>For items that are not marked in any way and for which the superitem is also not marked the "I do not care" behavior is assumed.
* This means that they may be returned or they may be not. The implementation will return them if their retrieval is cheap
* but they will be most likely omitted from the result.</li>
* </ul>
*/
private RetrieveOption retrieve;
/**
* Resolve the object reference. This only makes sense with a (path-based) selector.
*/
private Boolean resolve;
/**
* Resolve the object reference names.
*/
private Boolean resolveNames;
/**
* No not fetch any information from external sources, e.g. do not fetch account data from resource,
* do not fetch resource schema, etc.
* Such operation returns only the data stored in midPoint repository.
*/
private Boolean noFetch;
/**
* 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;
/**
* Tolerate "raw" data in returned object. In some cases, raw data are tolerated by default (e.g. if raw=true
* and the object is ResourceType or ShadowType). But generally, toleration of raw data can be explicitly requested
* by setting this flag to TRUE.
*/
private Boolean tolerateRawData;
/**
* Force to get object from the resource even if some of the error occurred.
* If the any copy of the shadow is fetched, we can't delete this object
* from the gui, for example
*/
private Boolean doNotDiscovery;
private RelationalValueSearchQuery relationalValueSearchQuery;
/**
* This flag indicated if the "object not found" error is critical for
* processing the original request. If it is not, we just ignore it and
* don't log it. In other cases, error in logs may lead to misleading
* information..
*/
private Boolean allowNotFound;
/**
* Return read-only object. The returned object will be only read by the client. The client will not modify it.
* Immutable object is returned if it is possible.
* This option allows to turn on internal optimization (e.g. avoid cloning the values). It should be used
* at all times when the client do not plan to modify the returned object.
*/
private Boolean readOnly;
/**
* Specifies the point in time for the returned data. This option controls whether fresh or cached data will
* be returned or whether future data projection will be returned. MidPoint usually deals with fresh data
* that describe situation at the current point in time. But the client code may want to get data from the
* cache that may be possibly stale. Or the client code may want a projection about the future state of the
* data (e.g. taking running asynchronous operation into consideration).
* If this option is not specified then the current point in time is the default if no staleness option is
* specified or if it is zero. If non-zero staleness option is specified then this option defaults to cached
* data.
*/
private PointInTimeType pointInTimeType;
/**
* Requirement how stale or fresh the retrieved data should be. It specifies maximum age of the value in millisecods.
* The default value is zero, which means that a fresh value must always be returned. This means that caches that do
* not guarantee fresh value cannot be used. If non-zero value is specified then such caches may be used. In case that
* Long.MAX_VALUE is specified then the caches are always used and fresh value is never retrieved.
*
* Null value is special in one more aspect: it allows to return partial cached data in case that the original is not
* accessible. E.g. in that case provisioning can return repository shadow in case that the resource is not reachable.
* Explicit specification of staleness=0 disables this behavior.
*/
private Long staleness;
/**
* Force refresh of object before the data are retrieved. This option is a guarantee that we get the freshest
* data that is possible. However, strange things may happen here. E.g. object that existed before this operation
* may get deleted during refresh because it has expired in the meantime. Or get operation may in fact attempt
* to create, modify and even delete of an account. This may happen in case that there are some unfinished
* operations in the shadow. Therefore when using this option you have to be really prepared for everything.
*/
private Boolean forceRefresh;
/**
* Should the results be made distinct.
* Not all providers support this option.
*
* BEWARE:
* - may bring a potentially huge performance penalty
* - may interfere with paging (!)
*
* So please consider this option an EXPERIMENTAL, for now.
*/
private Boolean distinct;
/**
* Whether to attach diagnostics data to the returned object(s).
*/
private Boolean attachDiagData;
/**
* TODO
*/
private DefinitionProcessingOption definitionProcessing;
/**
* Whether to override default iteration method (in searchObjectsIterative) configured for particular DBMS.
*/
private IterationMethodType iterationMethod;
/**
* Whether this operation is already part of the execution phase. I.e. the request authorization was already
* processed. This means that the operation is in fact operation invoked within another operation,
* e.g. invoked from script or expression evaluator.
*
* WARNING: THIS OPTION MUST NOT BE AVAILABLE FROM REMOTE INTERFACES.
* This is safe to use from a secure area of JVM, where the components can trick model to circumvent
* authorizations anyway. But it must not be available outside of the secure area.
*/
private Boolean executionPhase;
/*
* !!! After adding option here don't forget to update equals, clone, merge, etc. !!!
*/
public RetrieveOption getRetrieve() {
return retrieve;
}
public void setRetrieve(RetrieveOption retrieve) {
this.retrieve = retrieve;
}
public static RetrieveOption getRetrieve(GetOperationOptions options) {
if (options == null) {
return null;
}
return options.retrieve;
}
public static GetOperationOptions createRetrieve(RetrieveOption retrieve) {
GetOperationOptions options = new GetOperationOptions();
options.retrieve = retrieve;
return options;
}
/**
* Specifies whether to return specific items. It is used for optimizations.
* Some requests only needs a subset of items therefore fetching them all is a waste
* of resources. Other requests may need expensive data that are not normally returned by default.
* <p>
* If no retrieve option is set in the entire options set then it
* means that the whole object with a default set of properties has to be
* returned. This is equivalent to specifying DEFAULT retrieve root option.
* <p>
* If there is at least one retrieve option in the set then the following rules apply:
* <ul>
* <li>Items marked as INCLUDE will be returned.</li>
* <li>Any item marked as EXCLUDE may not be returned. (Note: Excluded items may still be returned if their retrieval is cheap.)</li>
* <li>Items marked as DEFAULT will be returned if they would also be returned without any options (by default).</li>
* <li>Items that are not marked (have no option or have null retrieve option) but their superitem is marked (have retrieve option)
* behave in the same way as superitem. E.g. if a superitem is marked as
* INCLUDE they will also be included in the result. This also applies transitively (e.g. superitem of superitem).
* <li>If a superitem is marked as EXCLUDE and subitem is marked as INCLUDE then the behavior is undefined. Do not do this. Strange things may happen.</li>
* <li>For items that are not marked in any way and for which the superitem is also not marked the "I do not care" behavior is assumed.
* This means that they may be returned or they may be not. The implementation will return them if their retrieval is cheap
* but they will be most likely omitted from the result.</li>
* </ul>
*/
public static GetOperationOptions createRetrieve() {
return createRetrieve(RetrieveOption.INCLUDE);
}
/**
* Specifies whether to return specific items. It is used for optimizations.
* Some requests only needs a subset of items therefore fetching them all is a waste
* of resources. Other requests may need expensive data that are not normally returned by default.
* <p>
* If no retrieve option is set in the entire options set then it
* means that the whole object with a default set of properties has to be
* returned. This is equivalent to specifying DEFAULT retrieve root option.
* <p>
* If there is at least one retrieve option in the set then the following rules apply:
* <ul>
* <li>Items marked as INCLUDE will be returned.</li>
* <li>Any item marked as EXCLUDE may not be returned. (Note: Excluded items may still be returned if their retrieval is cheap.)</li>
* <li>Items marked as DEFAULT will be returned if they would also be returned without any options (by default).</li>
* <li>Items that are not marked (have no option or have null retrieve option) but their superitem is marked (have retrieve option)
* behave in the same way as superitem. E.g. if a superitem is marked as
* INCLUDE they will also be included in the result. This also applies transitively (e.g. superitem of superitem).
* <li>If a superitem is marked as EXCLUDE and subitem is marked as INCLUDE then the behavior is undefined. Do not do this. Strange things may happen.</li>
* <li>For items that are not marked in any way and for which the superitem is also not marked the "I do not care" behavior is assumed.
* This means that they may be returned or they may be not. The implementation will return them if their retrieval is cheap
* but they will be most likely omitted from the result.</li>
* </ul>
*/
public static GetOperationOptions createDontRetrieve() {
return createRetrieve(RetrieveOption.EXCLUDE);
}
/**
* Specifies whether to return specific items. It is used for optimizations.
* Some requests only needs a subset of items therefore fetching them all is a waste
* of resources. Other requests may need expensive data that are not normally returned by default.
* <p>
* If no retrieve option is set in the entire options set then it
* means that the whole object with a default set of properties has to be
* returned. This is equivalent to specifying DEFAULT retrieve root option.
* <p>
* If there is at least one retrieve option in the set then the following rules apply:
* <ul>
* <li>Items marked as INCLUDE will be returned.</li>
* <li>Any item marked as EXCLUDE may not be returned. (Note: Excluded items may still be returned if their retrieval is cheap.)</li>
* <li>Items marked as DEFAULT will be returned if they would also be returned without any options (by default).</li>
* <li>Items that are not marked (have no option or have null retrieve option) but their superitem is marked (have retrieve option)
* behave in the same way as superitem. E.g. if a superitem is marked as
* INCLUDE they will also be included in the result. This also applies transitively (e.g. superitem of superitem).
* <li>If a superitem is marked as EXCLUDE and subitem is marked as INCLUDE then the behavior is undefined. Do not do this. Strange things may happen.</li>
* <li>For items that are not marked in any way and for which the superitem is also not marked the "I do not care" behavior is assumed.
* This means that they may be returned or they may be not. The implementation will return them if their retrieval is cheap
* but they will be most likely omitted from the result.</li>
* </ul>
*/
public static GetOperationOptions createRetrieve(RelationalValueSearchQuery query) {
GetOperationOptions options = new GetOperationOptions();
options.retrieve = RetrieveOption.INCLUDE;
options.setRelationalValueSearchQuery(query);
return options;
}
public Boolean getResolve() {
return resolve;
}
public void setResolve(Boolean resolve) {
this.resolve = resolve;
}
public GetOperationOptions resolve(Boolean resolve) {
this.resolve = resolve;
return this;
}
public static boolean isResolve(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.resolve == null) {
return false;
}
return options.resolve;
}
/**
* Resolve the object reference. This only makes sense with a (path-based) selector.
*/
public static GetOperationOptions createResolve() {
GetOperationOptions opts = new GetOperationOptions();
opts.setResolve(true);
return opts;
}
public Boolean getNoFetch() {
return noFetch;
}
public void setNoFetch(Boolean noFetch) {
this.noFetch = noFetch;
}
public GetOperationOptions noFetch(Boolean noFetch) {
this.noFetch = noFetch;
return this;
}
public static boolean isNoFetch(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.noFetch == null) {
return false;
}
return options.noFetch;
}
/**
* No not fetch any information from external sources, e.g. do not fetch account data from resource,
* do not fetch resource schema, etc.
* Such operation returns only the data stored in midPoint repository.
*/
public static GetOperationOptions createNoFetch() {
GetOperationOptions opts = new GetOperationOptions();
opts.setNoFetch(true);
return opts;
}
public Boolean getResolveNames() {
return resolveNames;
}
public void setResolveNames(Boolean resolveNames) {
this.resolveNames = resolveNames;
}
public GetOperationOptions resolveNames(Boolean resolveNames) {
this.resolveNames = resolveNames;
return this;
}
public static boolean isResolveNames(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.resolveNames == null) {
return false;
}
return options.resolveNames;
}
/**
* Resolve the object reference names.
*/
public static GetOperationOptions createResolveNames() {
GetOperationOptions opts = new GetOperationOptions();
opts.setResolveNames(true);
return opts;
}
public Boolean getTolerateRawData() {
return tolerateRawData;
}
public void setTolerateRawData(Boolean value) {
this.tolerateRawData = value;
}
public GetOperationOptions tolerateRawData(Boolean value) {
this.tolerateRawData = value;
return this;
}
public static boolean isTolerateRawData(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.tolerateRawData == null) {
return false;
}
return options.tolerateRawData;
}
/**
* Tolerate "raw" data in returned object. In some cases, raw data are tolerated by default (e.g. if raw=true
* and the object is ResourceType or ShadowType). But generally, toleration of raw data can be explicitly requested
* by setting this flag to TRUE.
*/
public static GetOperationOptions createTolerateRawData() {
GetOperationOptions opts = new GetOperationOptions();
opts.setTolerateRawData(true);
return opts;
}
public Boolean getRaw() {
return raw;
}
public void setRaw(Boolean raw) {
this.raw = raw;
}
public GetOperationOptions raw(Boolean raw) {
this.raw = raw;
return this;
}
public static boolean isRaw(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.raw == null) {
return false;
}
return options.raw;
}
/**
* Avoid any smart processing of the data except for schema application. Do not synchronize the data, do not apply
* any expressions, etc.
*/
public static GetOperationOptions createRaw() {
GetOperationOptions opts = new GetOperationOptions();
opts.setRaw(true);
return opts;
}
/**
* Avoid any smart processing of the data except for schema application. Do not synchronize the data, do not apply
* any expressions, etc.
*/
public static Collection<SelectorOptions<GetOperationOptions>> createRawCollection() {
return SelectorOptions.createCollection(createRaw());
}
/**
* No not fetch any information from external sources, e.g. do not fetch account data from resource,
* do not fetch resource schema, etc.
* Such operation returns only the data stored in midPoint repository.
*/
public static Collection<SelectorOptions<GetOperationOptions>> createNoFetchCollection() {
return SelectorOptions.createCollection(createNoFetch());
}
public Boolean getDoNotDiscovery() {
return doNotDiscovery;
}
public void setDoNotDiscovery(Boolean force) {
this.doNotDiscovery = force;
}
public GetOperationOptions doNotDiscovery(Boolean force) {
this.doNotDiscovery = force;
return this;
}
public static boolean isDoNotDiscovery(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.doNotDiscovery == null) {
return false;
}
return options.doNotDiscovery;
}
/**
* Force to get object from the resource even if some of the error occurred.
* If the any copy of the shadow is fetched, we can't delete this object
* from the gui, for example
*/
public static GetOperationOptions createDoNotDiscovery() {
GetOperationOptions opts = new GetOperationOptions();
opts.setDoNotDiscovery(true);
return opts;
}
/**
* This flag indicated if the "object not found" error is critical for
* processing the original request. If it is not, we just ignore it and
* don't log it. In other cases, error in logs may lead to misleading
* information..
*/
public static GetOperationOptions createAllowNotFound() {
GetOperationOptions opts = new GetOperationOptions();
opts.setAllowNotFound(true);
return opts;
}
public Boolean getAllowNotFound() {
return allowNotFound;
}
public void setAllowNotFound(Boolean allowNotFound) {
this.allowNotFound = allowNotFound;
}
public GetOperationOptions allowNotFound(Boolean allowNotFound) {
this.allowNotFound = allowNotFound;
return this;
}
public static boolean isAllowNotFound(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.allowNotFound == null) {
return false;
}
return options.allowNotFound;
}
/**
* Return read-only object. The returned object will be only read by the client. The client will not modify it.
* Immutable object is returned if it is possible.
* This option allows to turn on internal optimization (e.g. avoid cloning the values). It should be used
* at all times when the client do not plan to modify the returned object.
*/
public static GetOperationOptions createReadOnly() {
GetOperationOptions opts = new GetOperationOptions();
opts.setReadOnly(true);
return opts;
}
public static Collection<SelectorOptions<GetOperationOptions>> createReadOnlyCollection() {
return SelectorOptions.createCollection(createReadOnly());
}
public Boolean getReadOnly() {
return readOnly;
}
public void setReadOnly(Boolean readOnly) {
this.readOnly = readOnly;
}
public GetOperationOptions readOnly(Boolean readOnly) {
this.readOnly = readOnly;
return this;
}
public static boolean isReadOnly(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.readOnly == null) {
return false;
}
return options.readOnly;
}
public PointInTimeType getPointInTimeType() {
return pointInTimeType;
}
public void setPointInTimeType(PointInTimeType pointInTimeType) {
this.pointInTimeType = pointInTimeType;
}
public GetOperationOptions pointInTimeType(PointInTimeType pointInTimeType) {
this.pointInTimeType = pointInTimeType;
return this;
}
/**
* Specifies the point in time for the returned data. This option controls whether fresh or cached data will
* be returned or whether future data projection will be returned. MidPoint usually deals with fresh data
* that describe situation at the current point in time. But the client code may want to get data from the
* cache that may be possibly stale. Or the client code may want a projection about the future state of the
* data (e.g. taking running asynchronous operation into consideration).
* If this option is not specified then the current point in time is the default if no staleness option is
* specified or if it is zero. If non-zero staleness option is specified then this option defaults to cached
* data.
*/
public static GetOperationOptions createPointInTimeType(PointInTimeType pit) {
GetOperationOptions opts = new GetOperationOptions();
opts.setPointInTimeType(pit);
return opts;
}
public static PointInTimeType getPointInTimeType(GetOperationOptions options) {
if (options == null) {
return null;
}
if (options.getPointInTimeType() == null) {
return null;
}
return options.getPointInTimeType();
}
public Long getStaleness() {
return staleness;
}
public void setStaleness(Long staleness) {
this.staleness = staleness;
}
public GetOperationOptions staleness(Long staleness) {
this.staleness = staleness;
return this;
}
/**
* Requirement how stale or fresh the retrieved data should be. It specifies maximum age of the value in millisecods.
* The default value is zero, which means that a fresh value must always be returned. This means that caches that do
* not guarantee fresh value cannot be used. If non-zero value is specified then such caches may be used. In case that
* Long.MAX_VALUE is specified then the caches are always used and fresh value is never retrieved.
*/
public static GetOperationOptions createStaleness(Long staleness) {
GetOperationOptions opts = new GetOperationOptions();
opts.setStaleness(staleness);
return opts;
}
public static GetOperationOptions createMaxStaleness() {
GetOperationOptions opts = new GetOperationOptions();
opts.setStaleness(Long.MAX_VALUE);
return opts;
}
public static long getStaleness(GetOperationOptions options) {
if (options == null) {
return 0L;
}
if (options.getStaleness() == null) {
return 0L;
}
return options.getStaleness();
}
public static boolean isMaxStaleness(GetOperationOptions options) {
return GetOperationOptions.getStaleness(options) == Long.MAX_VALUE;
}
public Boolean getForceRefresh() {
return forceRefresh;
}
public void setForceRefresh(Boolean forceRefresh) {
this.forceRefresh = forceRefresh;
}
public GetOperationOptions forceRefresh(Boolean forceRefresh) {
this.forceRefresh = forceRefresh;
return this;
}
public static boolean isForceRefresh(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.forceRefresh == null) {
return false;
}
return options.forceRefresh;
}
public static GetOperationOptions createForceRefresh() {
GetOperationOptions opts = new GetOperationOptions();
opts.setForceRefresh(true);
return opts;
}
public Boolean getDistinct() {
return distinct;
}
public void setDistinct(Boolean distinct) {
this.distinct = distinct;
}
public GetOperationOptions distinct(Boolean distinct) {
this.distinct = distinct;
return this;
}
public static boolean isDistinct(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.distinct == null) {
return false;
}
return options.distinct;
}
/**
* Should the results be made distinct.
* Not all providers support this option.
*
* BEWARE:
* - may bring a potentially huge performance penalty
* - may interfere with paging (!)
*
* So please consider this option an EXPERIMENTAL, for now.
*/
public static GetOperationOptions createDistinct() {
GetOperationOptions opts = new GetOperationOptions();
opts.setDistinct(true);
return opts;
}
public Boolean getAttachDiagData() {
return attachDiagData;
}
public void setAttachDiagData(Boolean value) {
this.attachDiagData = value;
}
public GetOperationOptions attachDiagData(Boolean value) {
this.attachDiagData = value;
return this;
}
public static boolean isAttachDiagData(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.attachDiagData == null) {
return false;
}
return options.attachDiagData;
}
/**
* Whether to attach diagnostics data to the returned object(s).
*/
public static GetOperationOptions createAttachDiagData() {
GetOperationOptions opts = new GetOperationOptions();
opts.setAttachDiagData(true);
return opts;
}
public Boolean getExecutionPhase() {
return executionPhase;
}
public void setExecutionPhase(Boolean executionPhase) {
this.executionPhase = executionPhase;
}
public GetOperationOptions executionPhase(Boolean executionPhase) {
this.executionPhase = executionPhase;
return this;
}
public static boolean isExecutionPhase(GetOperationOptions options) {
if (options == null) {
return false;
}
if (options.executionPhase == null) {
return false;
}
return options.executionPhase;
}
public static GetOperationOptions createExecutionPhase() {
GetOperationOptions opts = new GetOperationOptions();
opts.setExecutionPhase(true);
return opts;
}
public DefinitionProcessingOption getDefinitionProcessing() {
return definitionProcessing;
}
public void setDefinitionProcessing(DefinitionProcessingOption definitionProcessing) {
this.definitionProcessing = definitionProcessing;
}
public GetOperationOptions definitionProcessing(DefinitionProcessingOption definitionProcessing) {
this.definitionProcessing = definitionProcessing;
return this;
}
public static DefinitionProcessingOption getDefinitionProcessing(GetOperationOptions options) {
return options != null ? options.definitionProcessing : null;
}
/**
* TODO
*/
public static GetOperationOptions createDefinitionProcessing(DefinitionProcessingOption value) {
GetOperationOptions opts = new GetOperationOptions();
opts.setDefinitionProcessing(value);
return opts;
}
public IterationMethodType getIterationMethod() {
return iterationMethod;
}
public void setIterationMethod(IterationMethodType iterationMethod) {
this.iterationMethod = iterationMethod;
}
public GetOperationOptions iterationMethod(IterationMethodType iterationMethod) {
this.iterationMethod = iterationMethod;
return this;
}
public static IterationMethodType getIterationMethod(GetOperationOptions options) {
return options != null ? options.iterationMethod : null;
}
/**
* Whether to override default iteration method (in searchObjectsIterative) configured for particular DBMS.
*/
public static GetOperationOptions createIterationMethod(IterationMethodType value) {
GetOperationOptions opts = new GetOperationOptions();
opts.setIterationMethod(value);
return opts;
}
public RelationalValueSearchQuery getRelationalValueSearchQuery() {
return relationalValueSearchQuery;
}
public void setRelationalValueSearchQuery(RelationalValueSearchQuery relationalValueSearchQuery) {
this.relationalValueSearchQuery = relationalValueSearchQuery;
}
public GetOperationOptions relationalValueSearchQuery(RelationalValueSearchQuery relationalValueSearchQuery) {
this.relationalValueSearchQuery = relationalValueSearchQuery;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof GetOperationOptions))
return false;
GetOperationOptions that = (GetOperationOptions) o;
return retrieve == that.retrieve &&
Objects.equals(resolve, that.resolve) &&
Objects.equals(resolveNames, that.resolveNames) &&
Objects.equals(noFetch, that.noFetch) &&
Objects.equals(raw, that.raw) &&
Objects.equals(tolerateRawData, that.tolerateRawData) &&
Objects.equals(doNotDiscovery, that.doNotDiscovery) &&
Objects.equals(relationalValueSearchQuery, that.relationalValueSearchQuery) &&
Objects.equals(allowNotFound, that.allowNotFound) &&
Objects.equals(readOnly, that.readOnly) &&
Objects.equals(pointInTimeType, that.pointInTimeType) &&
Objects.equals(staleness, that.staleness) &&
Objects.equals(attachDiagData, that.attachDiagData) &&
Objects.equals(executionPhase, that.executionPhase);
}
@Override
public int hashCode() {
return Objects
.hash(retrieve, resolve, resolveNames, noFetch, raw, tolerateRawData, doNotDiscovery, relationalValueSearchQuery,
allowNotFound, readOnly, staleness, distinct, definitionProcessing, attachDiagData, executionPhase);
}
public GetOperationOptions clone() {
GetOperationOptions clone = new GetOperationOptions();
clone.noFetch = this.noFetch;
clone.doNotDiscovery = this.doNotDiscovery;
clone.raw = this.raw;
clone.resolve = this.resolve;
clone.resolveNames = this.resolveNames;
clone.retrieve = this.retrieve;
clone.allowNotFound = this.allowNotFound;
clone.readOnly = this.readOnly;
clone.pointInTimeType = this.pointInTimeType;
clone.staleness = this.staleness;
clone.distinct = this.distinct;
clone.attachDiagData = this.attachDiagData;
clone.executionPhase = this.executionPhase;
if (this.relationalValueSearchQuery != null) {
clone.relationalValueSearchQuery = this.relationalValueSearchQuery.clone();
}
clone.definitionProcessing = this.definitionProcessing;
return clone;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("GetOperationOptions(");
shortDump(sb);
sb.append(")");
return sb.toString();
}
@Override
public void shortDump(StringBuilder sb) {
appendFlag(sb, "resolve", resolve);
appendFlag(sb, "resolveNames", resolveNames);
appendFlag(sb, "noFetch", noFetch);
appendFlag(sb, "raw", raw);
appendFlag(sb, "doNotDiscovery", doNotDiscovery);
appendVal(sb, "retrieve", retrieve);
appendFlag(sb, "allowNotFound", allowNotFound);
appendFlag(sb, "readOnly", readOnly);
appendVal(sb, "pointInTimeType", pointInTimeType);
appendVal(sb, "staleness", staleness);
appendVal(sb, "distinct", distinct);
appendVal(sb, "relationalValueSearchQuery", relationalValueSearchQuery);
appendVal(sb, "definitionProcessing", definitionProcessing);
appendFlag(sb, "attachDiagData", attachDiagData);
appendFlag(sb, "executionPhase", executionPhase);
removeLastComma(sb);
}
public static Collection<SelectorOptions<GetOperationOptions>> fromRestOptions(List<String> options, List<String> include,
List<String> exclude, List<String> resolveNames, DefinitionProcessingOption definitionProcessing,
PrismContext prismContext) {
if (CollectionUtils.isEmpty(options) && CollectionUtils.isEmpty(include) && CollectionUtils.isEmpty(exclude)
&& CollectionUtils.isEmpty(resolveNames)) {
if (definitionProcessing != null) {
return SelectorOptions.createCollection(GetOperationOptions.createDefinitionProcessing(definitionProcessing));
}
return null;
}
Collection<SelectorOptions<GetOperationOptions>> rv = new ArrayList<>();
GetOperationOptions rootOptions = fromRestOptions(options, definitionProcessing);
if (rootOptions != null) {
rv.add(SelectorOptions.create(rootOptions));
}
for (ItemPath includePath : ItemPathCollectionsUtil.pathListFromStrings(include, prismContext)) {
rv.add(SelectorOptions.create(prismContext.toUniformPath(includePath), GetOperationOptions.createRetrieve()));
}
for (ItemPath excludePath : ItemPathCollectionsUtil.pathListFromStrings(exclude, prismContext)) {
rv.add(SelectorOptions.create(prismContext.toUniformPath(excludePath), GetOperationOptions.createDontRetrieve()));
}
for (ItemPath resolveNamesPath : ItemPathCollectionsUtil.pathListFromStrings(resolveNames, prismContext)) {
rv.add(SelectorOptions.create(prismContext.toUniformPath(resolveNamesPath), GetOperationOptions.createResolveNames()));
}
// Do NOT set executionPhase here!
return rv;
}
public static GetOperationOptions fromRestOptions(List<String> options, DefinitionProcessingOption definitionProcessing) {
if (options == null || options.isEmpty()) {
if (definitionProcessing != null) {
return GetOperationOptions.createDefinitionProcessing(definitionProcessing);
}
return null;
}
GetOperationOptions rv = new GetOperationOptions();
for (String option : options) {
if (GetOperationOptionsType.F_RAW.getLocalPart().equals(option)) {
rv.setRaw(true);
}
if (GetOperationOptionsType.F_NO_FETCH.getLocalPart().equals(option)) {
rv.setNoFetch(true);
}
if (GetOperationOptionsType.F_NO_DISCOVERY.getLocalPart().equals(option)) {
rv.setDoNotDiscovery(true);
}
if (GetOperationOptionsType.F_RESOLVE_NAMES.getLocalPart().equals(option)) {
rv.setResolveNames(true);
}