use of org.ff4j.exception.FeatureAccessException 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);
}
}
use of org.ff4j.exception.FeatureAccessException in project ff4j by ff4j.
the class FeatureStoreHttp method existGroup.
/**
* {@inheritDoc}
*/
@Override
public boolean existGroup(String groupName) {
Util.assertHasLength(groupName);
Response cRes = ClientHttpUtils.invokeGetMethod(getGroups().path(groupName), authorizationHeaderValue);
if (Status.OK.getStatusCode() == cRes.getStatus()) {
return true;
}
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
return false;
}
throw new FeatureAccessException("Cannot check existence of group , an HTTP error " + cRes.getStatus() + OCCURED);
}
use of org.ff4j.exception.FeatureAccessException in project ff4j by ff4j.
the class FeatureStoreHttp method readAll.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Feature> readAll() {
Response cRes = ClientHttpUtils.invokeGetMethod(getStore(), authorizationHeaderValue);
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new FeatureAccessException("Cannot read features, an HTTP error " + cRes.getStatus() + OCCURED);
}
String resEntity = (String) cRes.readEntity(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.FeatureAccessException in project ff4j by ff4j.
the class FeatureStoreHttp method createSchema.
/**
* {@inheritDoc}
*/
@Override
public void createSchema() {
Util.assertHasLength(url);
Response cRes = ClientHttpUtils.invokePostMethod(getJerseyClient().target(url).path(RESOURCE_STORE).path(STORE_CREATESCHEMA), authorizationHeaderValue);
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new FeatureAccessException("Cannot create feature store - " + cRes.getStatus());
}
}
use of org.ff4j.exception.FeatureAccessException in project ff4j by ff4j.
the class FeatureStoreHttp method delete.
/**
* {@inheritDoc}
*/
@Override
public void delete(String uid) {
Util.assertHasLength(uid);
Response cRes = ClientHttpUtils.invokeDeleteMethod(getStore().path(uid), authorizationHeaderValue);
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
throw new FeatureNotFoundException(uid);
}
if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
throw new FeatureAccessException("Cannot delete feature, an HTTP error " + cRes.getStatus() + OCCURED);
}
}
Aggregations