public abstract static class PermissionBackend.ForChange extends PermissionBackend.AcceptsReviewDb<PermissionBackend.ForChange>
db
Constructor and Description |
---|
ForChange() |
Modifier and Type | Method and Description |
---|---|
abstract void |
check(ChangePermissionOrLabel perm)
Verify scoped user can
perm , throwing if denied. |
short |
squashByTest(LabelType label,
short val)
Squash a label value to the nearest allowed value using only test methods.
|
short |
squashThenCheck(LabelType label,
short val)
Squash a label value to the nearest allowed value.
|
boolean |
test(ChangePermissionOrLabel perm) |
abstract <T extends ChangePermissionOrLabel> |
test(Collection<T> permSet)
Filter
permSet to permissions scoped user might be able to perform. |
Set<LabelPermission.WithValue> |
test(LabelType label)
Test which values of a label the user may be able to set.
|
BooleanCondition |
testCond(ChangePermissionOrLabel perm) |
Set<LabelPermission.WithValue> |
testLabels(Collection<LabelType> types)
Test which values of a group of labels the user may be able to set.
|
boolean |
testOrFalse(ChangePermissionOrLabel perm)
Test if user may be able to perform the permission.
|
abstract CurrentUser |
user() |
abstract PermissionBackend.ForChange |
user(CurrentUser user) |
database, database
public abstract CurrentUser user()
public abstract PermissionBackend.ForChange user(CurrentUser user)
user
.public abstract void check(ChangePermissionOrLabel perm) throws AuthException, PermissionBackendException
perm
, throwing if denied.public abstract <T extends ChangePermissionOrLabel> Set<T> test(Collection<T> permSet) throws PermissionBackendException
permSet
to permissions scoped user might be able to perform.PermissionBackendException
public boolean test(ChangePermissionOrLabel perm) throws PermissionBackendException
PermissionBackendException
public boolean testOrFalse(ChangePermissionOrLabel perm)
Similar to test(ChangePermissionOrLabel)
except this method returns false
instead of throwing an exception.
perm
- the permission to test.public BooleanCondition testCond(ChangePermissionOrLabel perm)
public Set<LabelPermission.WithValue> test(LabelType label) throws PermissionBackendException
label
- definition of the label to test values of.PermissionBackendException
- if failure consulting backend configuration.public Set<LabelPermission.WithValue> testLabels(Collection<LabelType> types) throws PermissionBackendException
types
- definition of the labels to test values of.PermissionBackendException
- if failure consulting backend configuration.public short squashThenCheck(LabelType label, short val) throws PermissionBackendException
For multi-valued labels like Code-Review with values -2..+2 a user may try to use +2, but only have permission for the -1..+1 range. The caller should have already tried:
check(new LabelPermission.WithValue("Code-Review", 2));and caught
AuthException
. squashThenCheck
will use test(LabelType)
to determine potential values of Code-Review the user can use, and select the nearest value
along the same sign, e.g. -1 for -2 and +1 for +2.label
- definition of the label to test values of.val
- previously denied value the user attempted.0
if no value was allowed.PermissionBackendException
- backend cannot run test or check.public short squashByTest(LabelType label, short val) throws PermissionBackendException
Tests all possible values and selects the closet available to val
while matching
the sign of val
. Unlike #squashThenCheck(LabelType, short)
this method only
uses test
methods and should not be used in contexts like a review handler without
checking the resulting score.
label
- definition of the label to test values of.val
- previously denied value the user attempted.0
if no value was identified.PermissionBackendException
- backend cannot run test.