use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongoDB method readGroup.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Feature> readGroup(String groupName) {
if (groupName == null || groupName.isEmpty()) {
throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY);
}
if (!existGroup(groupName)) {
throw new GroupNotFoundException(groupName);
}
LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>();
for (DBObject dbObject : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) {
Feature feature = MAPPER.mapFeature(dbObject);
mapFP.put(feature.getUid(), feature);
}
return mapFP;
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreSpringJdbc method readGroup.
/**
* {@inheritDoc}
*/
public Map<String, Feature> readGroup(String groupName) {
if (groupName == null || groupName.isEmpty()) {
throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY);
}
if (!existGroup(groupName)) {
throw new GroupNotFoundException(groupName);
}
LinkedHashMap<String, Feature> mapFP = new LinkedHashMap<String, Feature>();
List<Feature> lFp = getJdbcTemplate().query(getQueryBuilder().getFeatureOfGroup(), FMAPPER, groupName);
for (Feature flipPoint : lFp) {
mapFP.put(flipPoint.getUid(), flipPoint);
}
return mapFP;
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreRedis 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.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongoDB method removeFromGroup.
/**
* {@inheritDoc}
*/
@Override
public void removeFromGroup(String uid, String groupName) {
if (uid == null || uid.isEmpty()) {
throw new IllegalArgumentException(FEATURE_IDENTIFIER_CANNOT_BE_NULL_NOR_EMPTY);
}
if (groupName == null || groupName.isEmpty()) {
throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY);
}
if (!exist(uid)) {
throw new FeatureNotFoundException(uid);
}
if (!existGroup(groupName)) {
throw new GroupNotFoundException(groupName);
}
DBObject target = BUILDER.getFeatUid(uid);
DBObject nGroupName = BUILDER.getGroupName("");
getFeaturesCollection().update(target, BasicDBObjectBuilder.start(MONGO_SET, nGroupName).get());
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongoDB method enableGroup.
/**
* {@inheritDoc}
*/
@Override
public void enableGroup(String groupName) {
if (groupName == null || groupName.isEmpty()) {
throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY);
}
if (!existGroup(groupName)) {
throw new GroupNotFoundException(groupName);
}
for (DBObject dbObject : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) {
Object enabledd = BUILDER.getEnable(true);
getFeaturesCollection().update(dbObject, BasicDBObjectBuilder.start(MONGO_SET, enabledd).get());
}
}
Aggregations