Class BaseOperationCheck
java.lang.Object
com.atlassian.confluence.api.model.permissions.spi.BaseOperationCheck
- All Implemented Interfaces:
Operation,OperationCheck
Base class for implementing
OperationChecks.
Plugins implementing their own checks should extend this.- Since:
- 5.8
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseOperationCheck(OperationKey operationKey, TargetType expectedTargetType) Construct aBaseOperationCheck. -
Method Summary
Modifier and TypeMethodDescriptionfinal @NonNull ValidationResultcanPerform(Person person, Target target) Delegates tocanPerform(Person, java.lang.Iterable).final @NonNull Map<Target,ValidationResult> canPerform(Person person, Iterable<Target> targets) Validates targets are the correctTargetType, then delegates tocanPerformImpl(Person, java.lang.Iterable).final @NonNull ValidationResultcanPerformAccordingToState(Person person, Target target) Delegates tocanPerformAccordingToState(Person, java.lang.Iterable).final @NonNull Map<Target,ValidationResult> canPerformAccordingToState(Person person, Iterable<Target> targets) Validates targets are the correctTargetType, then delegates tocanPerformAccordingToStateImpl(Person, java.lang.Iterable).protected abstract @NonNull Map<Target,ValidationResult> canPerformAccordingToStateImpl(@NonNull Person person, @NonNull Iterable<Target> targets) Subclass implements this to perform canPerformAccordingToState checks on a collection of targets.protected abstract @NonNull Map<Target,ValidationResult> canPerformImpl(@NonNull Person person, @NonNull Iterable<Target> targets) Subclass implements this to perform canPerform checks on a collection of targets.final @NonNull OperationKey
-
Constructor Details
-
BaseOperationCheck
Construct aBaseOperationCheck.- Parameters:
operationKey- the operation forgetOperationKey().expectedTargetType- the singleTargetTypesupported by this check. This base class will check targets match this before callingcanPerformImpl(Person, java.lang.Iterable)orcanPerformAccordingToStateImpl(Person, java.lang.Iterable).
-
-
Method Details
-
getOperationKey
- Specified by:
getOperationKeyin interfaceOperation- Specified by:
getOperationKeyin interfaceOperationCheck- Returns:
- the
OperationKeypassed to the constructor.
-
canPerform
Delegates tocanPerform(Person, java.lang.Iterable).- Specified by:
canPerformin interfaceOperationCheck- 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
-
canPerformAccordingToState
Delegates tocanPerformAccordingToState(Person, java.lang.Iterable).- Specified by:
canPerformAccordingToStatein interfaceOperationCheck- 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
-
canPerform
public final @NonNull Map<Target,ValidationResult> canPerform(Person person, Iterable<Target> targets) Validates targets are the correctTargetType, then delegates tocanPerformImpl(Person, java.lang.Iterable).- Specified by:
canPerformin interfaceOperationCheck- 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
ValidationResultfor 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
-
canPerformAccordingToState
public final @NonNull Map<Target,ValidationResult> canPerformAccordingToState(Person person, Iterable<Target> targets) Validates targets are the correctTargetType, then delegates tocanPerformAccordingToStateImpl(Person, java.lang.Iterable).- Specified by:
canPerformAccordingToStatein interfaceOperationCheck- 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
ValidationResultfor 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
-
canPerformImpl
protected abstract @NonNull Map<Target,ValidationResult> canPerformImpl(@NonNull Person person, @NonNull Iterable<Target> targets) Subclass implements this to perform canPerform checks on a collection of targets.- Parameters:
person- non-null Persontargets- non-null non-empty collection of Targets, each already validated as being non-null and having the correctTargetTypefor this operation check- Returns:
- a map of validation results indicating whether each target in the list passes the check,
as per contract of
OperationCheck.canPerform(com.atlassian.confluence.api.model.people.Person, java.lang.Iterable) - Throws:
UnsupportedTargetException- if target points to the wrong kind of object for this operation check (e.g. container target vs. specific object target)BadRequestException- See Also:
-
canPerformAccordingToStateImpl
protected abstract @NonNull Map<Target,ValidationResult> canPerformAccordingToStateImpl(@NonNull Person person, @NonNull Iterable<Target> targets) Subclass implements this to perform canPerformAccordingToState checks on a collection of targets.- Parameters:
person- non-null Persontargets- non-null non-empty collection of Targets, each already validated as being non-null and having the correctTargetTypefor this operation check- Returns:
- a map of validation results indicating whether each target in the list passes the check,
as per contract of
OperationCheck.canPerformAccordingToState(com.atlassian.confluence.api.model.people.Person, java.lang.Iterable) - Throws:
UnsupportedTargetException- if target points to the wrong kind of object for this operation check (e.g. container target vs. specific object target)BadRequestException- See Also:
-