public abstract class

AbstractPermissionCondition

extends Object
implements Condition
java.lang.Object
   ↳ com.atlassian.bitbucket.web.conditions.AbstractPermissionCondition
Known Direct Subclasses

Class Overview

An abstract base class for creating permission-based conditions. The permission will be parsed from the initialisation context and validated by this base class. Derived classes then implement shouldDisplay(Map) to make the desired check using the PermissionService.

Summary

Constants
String CONTEXT_PARAM
String PERMISSION Defines the key from the initialisation context under which the permission name is expected to be set.
Fields
protected final PermissionService permissionService Allows derived implementations to access the PermissionService.
Protected Constructors
AbstractPermissionCondition(PermissionService permissionService, boolean global)
Constructs a new AbstractPermissionCondition which will perform checks using the specified PermissionService.
Public Methods
Permission getPermission()
Retrieves the initialised permission.
void init(Map<StringString> params)
Retrieves the permission from the context and stores it.
boolean shouldDisplay(Map<StringObject> context)
Protected Methods
String getType()
Retrieves a string describing the required permission type.
boolean hasPermission(Map<StringObject> context, String userName)
boolean hasPermission(Map<StringObject> context, ApplicationUser user)
boolean hasPermission(Map<StringObject> context)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.plugin.web.Condition

Constants

public static final String CONTEXT_PARAM

Constant Value: "contextParam"

public static final String PERMISSION

Defines the key from the initialisation context under which the permission name is expected to be set.

Constant Value: "permission"

Fields

protected final PermissionService permissionService

Allows derived implementations to access the PermissionService.

Protected Constructors

protected AbstractPermissionCondition (PermissionService permissionService, boolean global)

Constructs a new 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.

Parameters
permissionService the service to use when performing the permission check
global true if the initialised permission is required to be global; otherwise, false to required a non-global permission

Public Methods

public Permission getPermission ()

Retrieves the initialised permission.

Returns
  • the initialised permission

public void init (Map<StringString> params)

Retrieves the 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.

Parameters
params the initialisation context
Throws
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<StringObject> context)

Protected Methods

protected String getType ()

Retrieves a string describing the required permission type.

Returns
  • "global" or "non-global depending on the flag set during construction

protected boolean hasPermission (Map<StringObject> context, String userName)

protected boolean hasPermission (Map<StringObject> context, ApplicationUser user)

protected boolean hasPermission (Map<StringObject> context)