public abstract class AbstractPermissionCondition extends Object implements com.atlassian.plugin.web.Condition
initialisation context
and validated by this base class. Derived classes then implement
shouldDisplay(Map)
to make the desired check using the PermissionService
.Modifier and Type | Field and Description |
---|---|
static String |
CONTEXT_PARAM |
static String |
PERMISSION
Defines the key from the
initialisation context under which the permission name is expected
to be set. |
protected com.atlassian.bitbucket.permission.PermissionService |
permissionService
Allows derived implementations to access the
PermissionService . |
Modifier | Constructor and Description |
---|---|
protected |
AbstractPermissionCondition(com.atlassian.bitbucket.permission.PermissionService permissionService,
boolean global)
Constructs a new
AbstractPermissionCondition which will perform checks using the specified
PermissionService . |
Modifier and Type | Method and Description |
---|---|
com.atlassian.bitbucket.permission.Permission |
getPermission()
Retrieves the
initialised permission. |
protected String |
getType()
Retrieves a string describing the required permission type.
|
protected boolean |
hasPermission(Map<String,Object> context) |
protected boolean |
hasPermission(Map<String,Object> context,
com.atlassian.bitbucket.user.ApplicationUser user) |
protected boolean |
hasPermission(Map<String,Object> context,
String userName) |
void |
init(Map<String,String> params)
Retrieves the
permission from the context and stores it . |
boolean |
shouldDisplay(Map<String,Object> context) |
public static final String PERMISSION
initialisation context
under which the permission name is expected
to be set.public static final String CONTEXT_PARAM
protected final com.atlassian.bitbucket.permission.PermissionService permissionService
PermissionService
.protected AbstractPermissionCondition(com.atlassian.bitbucket.permission.PermissionService permissionService, boolean global)
AbstractPermissionCondition
which will perform checks using the specified
PermissionService
. The provided global
flag is used during initialisation
,
to validate the global
flag of the parsed permission.permissionService
- the service to use when performing the permission checkglobal
- true
if the initialised permission is required to be global; otherwise,
false
to required a non-global permissionpublic com.atlassian.bitbucket.permission.Permission getPermission()
initialised
permission.public void init(Map<String,String> params) throws com.atlassian.plugin.PluginParseException
permission
from the context and stores it
. The
global
flag of the parsed permission is validated against the flag set when
the instance was constructed.init
in interface com.atlassian.plugin.web.Condition
params
- the initialisation contextcom.atlassian.plugin.PluginParseException
- Thrown if no permission
is set, or if the set value is not a
valid Permission
, or the permission's global
flag does not match the required value.public boolean shouldDisplay(Map<String,Object> context)
shouldDisplay
in interface com.atlassian.plugin.web.Condition
protected boolean hasPermission(Map<String,Object> context, com.atlassian.bitbucket.user.ApplicationUser user)
protected String getType()
"global"
or "non-global
depending on the flag set during constructionCopyright © 2021 Atlassian. All rights reserved.