use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreHttp 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);
}
ClientResponse cRes = getGroups().path(groupName).get(ClientResponse.class);
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
throw new GroupNotFoundException(groupName);
}
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED);
}
String resEntity = cRes.getEntity(String.class);
Feature[] fArray = parseFeatureArray(resEntity);
Map<String, Feature> features = new HashMap<String, Feature>();
for (Feature feature : fArray) {
features.put(feature.getUid(), feature);
}
return features;
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongo method disableGroup.
/**
* {@inheritDoc}
*/
@Override
public void disableGroup(String groupName) {
if (groupName == null || groupName.isEmpty()) {
throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY);
}
if (!existGroup(groupName)) {
throw new GroupNotFoundException(groupName);
}
for (Document document : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) {
Object enabled = BUILDER.getEnable(false);
getFeaturesCollection().updateOne(document, new Document(MONGO_SET, enabled));
}
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongo 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);
}
Document target = BUILDER.getFeatUid(uid);
Document nGroupName = BUILDER.getGroupName("");
getFeaturesCollection().updateOne(target, new Document(MONGO_SET, nGroupName));
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreEhCache 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 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);
}
Aggregations