Interface OperationCheck
- All Superinterfaces:
Operation
- All Known Implementing Classes:
BaseOperationCheck
A permission and validation check, for use with
OperationService
.
Implementers are encouraged to extend BaseOperationCheck
.
- Since:
- 5.8
- See Also:
-
Method Summary
Modifier and TypeMethodDescription@NonNull ValidationResult
canPerform
(Person person, Target target) Check whether the specified Person can perform this operation on the specified target.@NonNull Map<Target,
ValidationResult> canPerform
(Person person, Iterable<Target> targets) Check whether the specified Person can perform this operation on ALL of the specified targets.@NonNull ValidationResult
canPerformAccordingToState
(Person person, Target target) Check whether the specified Person can perform this operation on the specified target based on its state.@NonNull Map<Target,
ValidationResult> canPerformAccordingToState
(Person person, Iterable<Target> targets) Check whether the specified Person can perform this operation on each of the specified targets based on their state.@NonNull OperationKey
-
Method Details
-
getOperationKey
@NonNull OperationKey getOperationKey()- Specified by:
getOperationKey
in interfaceOperation
-
canPerform
Check whether the specified Person can perform this operation on the specified target.- Parameters:
person
- the Person on which to perform a permission and validation checktarget
- the Target to check permission for- Returns:
- an authorized and valid result if Person has permission to perform operation on this target in its current state
- an unauthorized result if permissions prevent Person performing the operation on this target
- a not-valid result for the following cases:
- the operation is not currently valid for target due to its state
- target doesn't exist
- Throws:
NullPointerException
- if person or targets is nullIllegalArgumentException
- if target is the wrongTargetType
for thisOperationCheck
UnsupportedTargetException
- if target points to the wrong kind of object for this operation check.BadRequestException
-
canPerformAccordingToState
Check whether the specified Person can perform this operation on the specified target based on its state.This method must not check permissions, except when the state check depends on the result of a permission check.
"Is this target in a state where this operation makes sense?"
- Parameters:
person
- the Person on which to perform a permission and validation checktarget
- the Target to check permission for- Returns:
- an authorized and valid result if Person can perform operation on this target in its current state
- an authorized and invalid result if the state of the target prevents Person performing the operation on this target
- Throws:
NullPointerException
- if person or targets is nullIllegalArgumentException
- if target is the wrongTargetType
for thisOperationCheck
UnsupportedTargetException
- if target points to the wrong kind of object for this operation check.BadRequestException
-
canPerform
Check whether the specified Person can perform this operation on ALL of the specified targets.- Parameters:
person
- the Person on which to perform a permission and validation checktargets
- the Targets to check permission for; must all be of the sameTargetType
- Returns:
- a Map providing a
ValidationResult
for each of the supplied targets. Results for each target will be as follows:- an authorized and valid result if Person can perform operation on this target in its current state
- an unauthorized result if permissions prevent Person performing the operation on this target
- a not-valid result for the following cases:
- the operation is not currently valid for target due to its state
- target doesn't exist
- Throws:
NullPointerException
- if person or targets is null, or any target is nullIllegalArgumentException
- if targets is empty, or if any target is the wrongTargetType
for thisOperationCheck
UnsupportedTargetException
- if any target points to the wrong kind of object for this operation check.BadRequestException
-
canPerformAccordingToState
@NonNull Map<Target,ValidationResult> canPerformAccordingToState(Person person, Iterable<Target> targets) Check whether the specified Person can perform this operation on each of the specified targets based on their state.This method must not check permissions, except when the state check depends on the result of a permission check.
- Parameters:
person
- the Person on which to perform a permission and validation checktargets
- the Targets to check state for; must all be of the sameTargetType
- Returns:
- a Map providing a
ValidationResult
for each of the supplied targets. Results for each target will be as follows:- an authorized and valid result if Person can perform operation on this target in its current state
- an authorized and invalid result if the state of this target prevents Person performing the operation on this target
- Throws:
NullPointerException
- if person or targets is null, or any target is nullIllegalArgumentException
- if targets is empty, or if any target is the wrongTargetType
for thisOperationCheck
UnsupportedTargetException
- if any target points to the wrong kind of object for this operation check.BadRequestException
-