Search in sources :

Example 81 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class HBaseFeatureMapper method fromStore.

/**
 * {@inheritDoc}
 */
public Feature fromStore(Result result) {
    // uid
    String uid = Bytes.toString(result.getValue(B_FEATURES_CF_CORE, B_FEAT_UID));
    Feature fout = new Feature(uid);
    // description
    fout.setDescription(Bytes.toString(result.getValue(B_FEATURES_CF_CORE, B_FEAT_DESCRIPTION)));
    // enable
    fout.setEnable(Bytes.toBoolean(result.getValue(B_FEATURES_CF_CORE, B_FEAT_ENABLE)));
    // group
    fout.setGroup(Bytes.toString(result.getValue(B_FEATURES_CF_CORE, B_FEAT_GROUPNAME)));
    if ("null".equals(fout.getGroup())) {
        fout.setGroup(null);
    }
    // permissions
    fout.setPermissions(FeatureJsonParser.parsePermissions(Bytes.toString(result.getValue(B_FEATURES_CF_CORE, B_FEAT_ROLES))));
    // Flipping Strategy
    fout.setFlippingStrategy(FeatureJsonParser.parseFlipStrategyAsJson(uid, Bytes.toString(result.getValue(B_FEATURES_CF_CORE, B_FEAT_STRATEGY))));
    // Custom Properties
    NavigableMap<byte[], byte[]> map = result.getFamilyMap(B_FEATURES_CF_PROPERTIES);
    for (Map.Entry<byte[], byte[]> property : map.entrySet()) {
        fout.getCustomProperties().put(Bytes.toString(property.getKey()), PropertyJsonParser.parseProperty(Bytes.toString(property.getValue())));
    }
    return fout;
}
Also used : Feature(org.ff4j.core.Feature) NavigableMap(java.util.NavigableMap) Map(java.util.Map)

Example 82 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class FeatureStoreJCache method removeRoleFromFeature.

/**
 * {@inheritDoc}
 */
@Override
public void removeRoleFromFeature(String flipId, String roleName) {
    Util.assertParamHasLength(roleName, "roleName (#2)");
    // retrieve
    Feature f = read(flipId);
    f.getPermissions().remove(roleName);
    // persist modification
    update(f);
}
Also used : Feature(org.ff4j.core.Feature)

Example 83 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class FeatureStoreJCache method addToGroup.

/**
 * {@inheritDoc}
 */
@Override
public void addToGroup(String featureId, String groupName) {
    Util.assertParamHasLength(groupName, "groupName (#2)");
    // retrieve
    Feature f = read(featureId);
    f.setGroup(groupName);
    // persist modification
    update(f);
}
Also used : Feature(org.ff4j.core.Feature)

Example 84 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class FeatureStoreJCache method removeFromGroup.

/**
 * {@inheritDoc}
 */
@Override
public void removeFromGroup(String featureId, String groupName) {
    Util.assertParamHasLength(groupName, "groupName (#2)");
    if (!existGroup(groupName)) {
        throw new GroupNotFoundException(groupName);
    }
    // retrieve
    Feature f = read(featureId);
    f.setGroup(null);
    // persist modification
    update(f);
}
Also used : GroupNotFoundException(org.ff4j.exception.GroupNotFoundException) Feature(org.ff4j.core.Feature)

Example 85 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class FeatureStoreJCache method grantRoleOnFeature.

/**
 * {@inheritDoc}
 */
@Override
public void grantRoleOnFeature(String flipId, String roleName) {
    Util.assertParamHasLength(roleName, "roleName (#2)");
    // retrieve
    Feature f = read(flipId);
    // modify
    f.getPermissions().add(roleName);
    // persist modification
    update(f);
}
Also used : Feature(org.ff4j.core.Feature)

Aggregations

Feature (org.ff4j.core.Feature)295 Test (org.junit.Test)144 PropertyString (org.ff4j.property.PropertyString)53 HashMap (java.util.HashMap)38 HashSet (java.util.HashSet)27 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)19 Property (org.ff4j.property.Property)16 LinkedHashMap (java.util.LinkedHashMap)15 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)15 Map (java.util.Map)14 XmlParser (org.ff4j.conf.XmlParser)14 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)14 FeatureAccessException (org.ff4j.exception.FeatureAccessException)13 InputStream (java.io.InputStream)11 FeatureApiBean (org.ff4j.web.api.resources.domain.FeatureApiBean)11 Set (java.util.Set)10 Response (javax.ws.rs.core.Response)10 FlippingStrategy (org.ff4j.core.FlippingStrategy)10 CouchDbFeature (org.ff4j.couchdb.document.CouchDbFeature)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9