use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyStoreHttp method readAllProperties.
/**
* {@inheritDoc}
*/
public Map<String, Property<?>> readAllProperties() {
ClientResponse cRes = getStore().get(ClientResponse.class);
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new PropertyAccessException("Cannot read properties, an HTTP error " + cRes.getStatus() + OCCURED);
}
String resEntity = cRes.getEntity(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.property.Property in project ff4j by ff4j.
the class XmlParserTest method testNullValues.
@Test
public void testNullValues() throws IOException {
new XmlParser().escapeXML(null);
new XmlParser().exportProperties(new HashMap<String, Property<?>>());
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyStoreMongoDB method readAllProperties.
/**
* {@inheritDoc}
*/
public Map<String, Property<?>> readAllProperties() {
LinkedHashMap<String, Property<?>> mapP = new LinkedHashMap<String, Property<?>>();
for (DBObject dbObject : getPropertiesCollection().find()) {
Property<?> prop = MAPPER.mapProperty(dbObject);
mapP.put(prop.getName(), prop);
}
return mapP;
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyStoreRedis method readAllProperties.
/**
* {@inheritDoc}
*/
public Map<String, Property<?>> readAllProperties() {
LinkedHashMap<String, Property<?>> mapP = new LinkedHashMap<String, Property<?>>();
Jedis jedis = null;
try {
jedis = getJedis();
Set<String> properties = jedis.smembers(keyBuilder.getKeyPropertyMap());
if (properties != null) {
for (String key : properties) {
mapP.put(key, readProperty(key));
}
}
return mapP;
} finally {
if (jedis != null) {
jedis.close();
}
}
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class PropertyCouchbaseMapper method toStore.
/**
* {@inheritDoc}
*/
@Override
public JsonDocument toStore(Property<?> prop) {
if (prop == null)
return null;
JsonObject jsonObject;
try {
jsonObject = TRANSCODER.stringToJsonObject(prop.toJson());
jsonObject.put("_class", Property.class.getCanonicalName());
} catch (Exception e) {
throw new FeatureAccessException("Cannot parse the feature", e);
}
return JsonDocument.create(prop.getName(), jsonObject);
}
Aggregations