com.atlassian.sal.core.features
Class DefaultDarkFeatureManager

java.lang.Object
  extended by com.atlassian.sal.core.features.DefaultDarkFeatureManager
All Implemented Interfaces:
DarkFeatureManager

public class DefaultDarkFeatureManager
extends Object
implements DarkFeatureManager

Default implementation of DarkFeatureManager - sufficient for any product which does not already have its own dark feature framework. Does not implement per-user enabling.


Field Summary
 
Fields inherited from interface com.atlassian.sal.api.features.DarkFeatureManager
ATLASSIAN_DARKFEATURE_PREFIX, DARKFEATURES_PROPERTIES_FILE_PROPERTY, DARKFEATURES_PROPERTIES_FILE_PROPERTY_DEFAULT, DISABLE_ALL_DARKFEATURES_PROPERTY
 
Constructor Summary
DefaultDarkFeatureManager(UserManager userManager, SiteDarkFeaturesStorage siteDarkFeaturesStorage)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDarkFeatureManager

public DefaultDarkFeatureManager(UserManager userManager,
                                 SiteDarkFeaturesStorage siteDarkFeaturesStorage)
Method Detail

isFeatureEnabledForAllUsers

public boolean isFeatureEnabledForAllUsers(String featureKey)
Description copied from interface: DarkFeatureManager
Checks if a dark feature is enabled for all users, regardless whether the feature can be changed during runtime or not.

Specified by:
isFeatureEnabledForAllUsers in interface DarkFeatureManager
Parameters:
featureKey - key of the feature to be checked
Returns:
true if the feature key is valid and enabled, false otherwise
See Also:
ValidFeatureKeyPredicate

isFeatureEnabledForCurrentUser

public boolean isFeatureEnabledForCurrentUser(String featureKey)
Description copied from interface: DarkFeatureManager
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). If the user couldn't be resolved or is anonymous, only features enabled for all users are considered.

Specified by:
isFeatureEnabledForCurrentUser in interface DarkFeatureManager
Parameters:
featureKey - key of the feature to be checked
Returns:
true if the feature is valid and enabled, either for all users or the current user only; false otherwise.
See Also:
ValidFeatureKeyPredicate

isFeatureEnabledForUser

public boolean isFeatureEnabledForUser(@Nullable
                                       UserKey userKey,
                                       String featureKey)
Description copied from interface: DarkFeatureManager
Checks if a dark feature is enabled for all users or just for the given user. In case the user is anonymous, only features enabled for all users are considered.

Specified by:
isFeatureEnabledForUser in interface DarkFeatureManager
Parameters:
userKey - the key of the user being queried; null represents the anonymous user
featureKey - key of the feature to be checked
Returns:
true if the feature key is valid and enabled, either for all users or the current user only; false otherwise.
See Also:
ValidFeatureKeyPredicate

canManageFeaturesForAllUsers

public boolean canManageFeaturesForAllUsers()
Description copied from interface: DarkFeatureManager
Returns true if the current acting user has permission to change dark features for all users. This is a nothrow method and should return a value instead of throw an exception.

Specified by:
canManageFeaturesForAllUsers in interface DarkFeatureManager
Returns:
true iff the current acting user has permission to change dark features for all users, false otherwise

enableFeatureForAllUsers

public void enableFeatureForAllUsers(String featureKey)
Description copied from interface: DarkFeatureManager
Enable the given dark feature all users. The acting user must have permission to change dark features for all users.

Specified by:
enableFeatureForAllUsers in interface DarkFeatureManager
Parameters:
featureKey - key of the feature to be enabled
See Also:
ValidFeatureKeyPredicate, DarkFeatureManager.canManageFeaturesForAllUsers()

disableFeatureForAllUsers

public void disableFeatureForAllUsers(String featureKey)
Description copied from interface: DarkFeatureManager
Disable the given dark feature for all users. The acting user must have permission to change dark features for all users.

Specified by:
disableFeatureForAllUsers in interface DarkFeatureManager
Parameters:
featureKey - key of the feature to be disabled
See Also:
ValidFeatureKeyPredicate, DarkFeatureManager.canManageFeaturesForAllUsers()

enableFeatureForCurrentUser

public void enableFeatureForCurrentUser(String featureKey)
Description copied from interface: DarkFeatureManager
Enable a dark feature for the current user only. Anonymous users are not supported. If the feature is already enabled for all users, the user will still be able to use it.

Specified by:
enableFeatureForCurrentUser in interface DarkFeatureManager
Parameters:
featureKey - key of the feature to enable
See Also:
ValidFeatureKeyPredicate

enableFeatureForUser

public void enableFeatureForUser(UserKey userKey,
                                 String featureKey)
Description copied from interface: DarkFeatureManager
Enable a dark feature for the given user only. Anonymous users are not supported. If the feature is already enabled for all users, the user will still be able to use it.

Specified by:
enableFeatureForUser in interface DarkFeatureManager
Parameters:
userKey - key of the user to enable the feature for; not null
featureKey - key of the feature to be enabled
See Also:
ValidFeatureKeyPredicate

disableFeatureForCurrentUser

public void disableFeatureForCurrentUser(String featureKey)
Description copied from interface: DarkFeatureManager
Disable a dark feature for the current user only. Anonymous users are not supported. If the feature is enabled for all users, the current user will still be able to use it.

Specified by:
disableFeatureForCurrentUser in interface DarkFeatureManager
Parameters:
featureKey - key of the feature to be disabled
See Also:
ValidFeatureKeyPredicate

disableFeatureForUser

public void disableFeatureForUser(UserKey userKey,
                                  String featureKey)
Description copied from interface: DarkFeatureManager
Disable a dark feature for the given user only. Anonymous users are not supported. If the feature is enabled for all users, the user will still be able to use it.

Specified by:
disableFeatureForUser in interface DarkFeatureManager
Parameters:
userKey - key of the user to disable the feature for; not null
featureKey - key of the feature to be disabled
See Also:
ValidFeatureKeyPredicate

getFeaturesEnabledForAllUsers

public EnabledDarkFeatures getFeaturesEnabledForAllUsers()
Specified by:
getFeaturesEnabledForAllUsers in interface DarkFeatureManager
Returns:
all dark features enabled for all users.

getFeaturesEnabledForCurrentUser

public EnabledDarkFeatures getFeaturesEnabledForCurrentUser()
Description copied from interface: DarkFeatureManager
Return features enabled for the current user (must be called within the context of a request). In case the current user could not be resolved or is anonymous, all dark features enabled for all users are returned instead.

Specified by:
getFeaturesEnabledForCurrentUser in interface DarkFeatureManager
Returns:
all dark features applicable for the current user.

getFeaturesEnabledForUser

public EnabledDarkFeatures getFeaturesEnabledForUser(@Nullable
                                                     UserKey userKey)
Description copied from interface: DarkFeatureManager
Return enabled features for a given user. In case the current user is anonymous, all global enabled features are returned.

Specified by:
getFeaturesEnabledForUser in interface DarkFeatureManager
Parameters:
userKey - key of the user being queried; null represents the anonymous user
Returns:
all dark features applicable for the given user


Copyright © 2015 Atlassian. All rights reserved.