public interface DarkFeatureManager
Provides a cross-product method for determining whether a dark feature is enabled.
Implementing products can back these checks with their own internal dark feature management system, but must
follow the enable and disable dark features on startup based on system properties and the contents of an optional
properties file. To avoid clashes with other system properties all features specified as system property must be
prefixed with ATLASSIAN_DARKFEATURE_PREFIX
. The prefix is removed from the feature key
when it is processed later. Values must be either true or false. The location of the dark features property file can
be overridden with the DARKFEATURES_PROPERTIES_FILE_PROPERTY
system property.
See SystemDarkFeatureInitializer in sal-core for an implementation.
Modifier and Type | Field and Description |
---|---|
static String |
ATLASSIAN_DARKFEATURE_PREFIX
Prefix for all dark feature specified as system property.
|
static String |
DARKFEATURES_PROPERTIES_FILE_PROPERTY
System property for overriding location of dark features property file.
|
static String |
DARKFEATURES_PROPERTIES_FILE_PROPERTY_DEFAULT
Default properties file name.
|
static String |
DISABLE_ALL_DARKFEATURES_PROPERTY
System property for disabling all dark features.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canManageFeaturesForAllUsers()
Returns true if the current acting user has permission to change dark features for all users.
|
void |
disableFeatureForAllUsers(String featureKey)
Disable the given dark feature for all users.
|
void |
disableFeatureForCurrentUser(String featureKey)
Disable a dark feature for the current user only.
|
void |
disableFeatureForUser(UserKey userKey,
String featureKey)
Disable a dark feature for the given user only.
|
void |
enableFeatureForAllUsers(String featureKey)
Enable the given dark feature all users.
|
void |
enableFeatureForCurrentUser(String featureKey)
Enable a dark feature for the current user only.
|
void |
enableFeatureForUser(UserKey userKey,
String featureKey)
Enable a dark feature for the given user only.
|
EnabledDarkFeatures |
getFeaturesEnabledForAllUsers() |
EnabledDarkFeatures |
getFeaturesEnabledForCurrentUser()
Return features enabled for the current user (must be called within the context of a request).
|
EnabledDarkFeatures |
getFeaturesEnabledForUser(UserKey userKey)
Return enabled features for a given user.
|
boolean |
isFeatureEnabledForAllUsers(String featureKey)
Checks if a dark feature is enabled for all users, regardless whether the feature can be changed during runtime
or not.
|
boolean |
isFeatureEnabledForCurrentUser(String featureKey)
Checks if a dark feature is enabled for all users or for the current user only (must be called within the context
of a request).
|
boolean |
isFeatureEnabledForUser(UserKey userKey,
String featureKey)
Checks if a dark feature is enabled for all users or just for the given user.
|
static final String ATLASSIAN_DARKFEATURE_PREFIX
static final String DISABLE_ALL_DARKFEATURES_PROPERTY
static final String DARKFEATURES_PROPERTIES_FILE_PROPERTY
static final String DARKFEATURES_PROPERTIES_FILE_PROPERTY_DEFAULT
boolean isFeatureEnabledForAllUsers(String featureKey)
featureKey
- key of the feature to be checkedtrue
if the feature key is valid and enabled, false otherwiseValidFeatureKeyPredicate
boolean isFeatureEnabledForCurrentUser(String featureKey)
featureKey
- key of the feature to be checkedtrue
if the feature is valid and enabled, either for all users or the current user only;
false
otherwise.ValidFeatureKeyPredicate
boolean isFeatureEnabledForUser(@Nullable UserKey userKey, String featureKey)
userKey
- the key of the user being queried; null
represents the anonymous userfeatureKey
- key of the feature to be checkedtrue
if the feature key is valid and enabled, either for all users or the current user only;
false
otherwise.IllegalArgumentException
- if the user doesn't existValidFeatureKeyPredicate
boolean canManageFeaturesForAllUsers()
true
iff the current acting user has permission to change dark features for all users,
false
otherwisevoid enableFeatureForAllUsers(String featureKey)
featureKey
- key of the feature to be enabledInvalidFeatureKeyException
- if the feature key is not validMissingPermissionException
- if the user has not the required permissionIllegalStateException
- if the update failedValidFeatureKeyPredicate
,
canManageFeaturesForAllUsers()
void disableFeatureForAllUsers(String featureKey)
featureKey
- key of the feature to be disabledInvalidFeatureKeyException
- if the feature key is not validMissingPermissionException
- if the user has not the required permissionIllegalStateException
- if the update failedValidFeatureKeyPredicate
,
canManageFeaturesForAllUsers()
void enableFeatureForCurrentUser(String featureKey)
featureKey
- key of the feature to enableInvalidFeatureKeyException
- if the feature key is not validIllegalStateException
- if the current user could not be resolved, is anonymous or the update failed due to
any other reasonValidFeatureKeyPredicate
void enableFeatureForUser(UserKey userKey, String featureKey)
userKey
- key of the user to enable the feature for; not null
featureKey
- key of the feature to be enabledIllegalArgumentException
- if the user does not exist or is anonymousInvalidFeatureKeyException
- if the feature key is not validIllegalStateException
- if the update failedValidFeatureKeyPredicate
void disableFeatureForCurrentUser(String featureKey)
featureKey
- key of the feature to be disabledInvalidFeatureKeyException
- if the feature key is not validIllegalStateException
- if the current user could not be resolved, is anonymous or the update failed due to
any other reasonValidFeatureKeyPredicate
void disableFeatureForUser(UserKey userKey, String featureKey)
userKey
- key of the user to disable the feature for; not null
featureKey
- key of the feature to be disabledIllegalArgumentException
- if the user does not exist or is anonymousInvalidFeatureKeyException
- if the feature key is not validIllegalStateException
- if the update failedValidFeatureKeyPredicate
EnabledDarkFeatures getFeaturesEnabledForAllUsers()
EnabledDarkFeatures getFeaturesEnabledForCurrentUser()
EnabledDarkFeatures getFeaturesEnabledForUser(@Nullable UserKey userKey)
userKey
- key of the user being queried; null
represents the anonymous userIllegalArgumentException
- if the user doesn't existCopyright © 2015 Atlassian. All rights reserved.