use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongo 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 (Document document : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) {
Object enabled = BUILDER.getEnable(true);
getFeaturesCollection().updateOne(document, new Document(MONGO_SET, enabled));
}
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongo 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 (Document document : getFeaturesCollection().find(BUILDER.getGroupName(groupName))) {
Feature feature = FMAPPER.fromStore(document);
mapFP.put(feature.getUid(), feature);
}
return mapFP;
}
use of org.ff4j.exception.GroupNotFoundException in project ff4j by ff4j.
the class FeatureStoreHttp method enableGroup.
/**
* {@inheritDoc}
*/
@Override
public void enableGroup(String groupName) {
Util.assertHasLength(groupName);
Response cRes = ClientHttpUtils.invokePostMethod(getGroups().path(groupName).path(OPERATION_ENABLE), authorizationHeaderValue);
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
throw new GroupNotFoundException(groupName);
}
if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
throw new FeatureAccessException(CANNOT_GRANT_ROLE_ON_FEATURE_AN_HTTP_ERROR + cRes.getStatus() + OCCURED);
}
}
Aggregations