use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class PropertyStoreHttp method existProperty.
/**
* {@inheritDoc}
*/
public boolean existProperty(String name) {
Util.assertHasLength(name);
Response cRes = ClientHttpUtils.invokeGetMethod(getStore().path(name), authorization);
if (Status.OK.getStatusCode() == cRes.getStatus()) {
return true;
}
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
return false;
}
throw new PropertyAccessException("Cannot check existence of property, an HTTP error " + cRes.getStatus() + " occured : " + cRes.getEntity());
}
use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class PropertyStoreHttp method readAllProperties.
/**
* {@inheritDoc}
*/
public Map<String, Property<?>> readAllProperties() {
Response cRes = ClientHttpUtils.invokeGetMethod(getStore(), authorization);
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new PropertyAccessException("Cannot read properties, an HTTP error " + cRes.getStatus() + OCCURED);
}
String resEntity = cRes.readEntity(String.class);
Property<?>[] pArray = PropertyJsonParser.parsePropertyArray(resEntity);
Map<String, Property<?>> properties = new HashMap<String, Property<?>>();
for (Property<?> pName : pArray) {
properties.put(pName.getName(), pName);
}
return properties;
}
use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class PropertyStoreHttp method deleteProperty.
/**
* {@inheritDoc}
*/
public void deleteProperty(String name) {
Util.assertHasLength(name);
Response cRes = ClientHttpUtils.invokeDeleteMethod(getStore().path(name), authorization);
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
throw new PropertyNotFoundException(name);
}
if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
throw new PropertyAccessException("Cannot delete property, an HTTP error " + cRes.getStatus() + OCCURED);
}
}
Aggregations