예제 #1
0
  public boolean isActive(Feature feature) {

    FeatureState state = featureStore.getFeatureState(feature);

    if (state == null) {
      FeatureMetaData metaData = new FeatureMetaData(feature);
      return metaData.isEnabledByDefault();
    }

    // disabled features are never active
    if (!state.isEnabled()) {
      return false;
    }

    // no user restriction? active!
    if (state.getUsers().isEmpty()) {
      return true;
    }

    // check if user is in user list
    FeatureUser user = featureUserProvider.getCurrentUser();
    if (user != null && user.getName() != null) {
      for (String username : state.getUsers()) {
        if (username.equals(user.getName())) {
          return true;
        }
      }
    }
    return false;
  }
예제 #2
0
 public FeatureState getFeatureState(Feature feature) {
   FeatureState state = featureStore.getFeatureState(feature);
   if (state == null) {
     FeatureMetaData metaData = new FeatureMetaData(feature);
     state = new FeatureState(feature, metaData.isEnabledByDefault());
   }
   return state;
 }
예제 #3
0
 public void setFeatureState(FeatureState state) {
   featureStore.setFeatureState(state);
 }