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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations