Search in sources :

Example 31 with Property

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;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) PropertyAccessException(org.ff4j.exception.PropertyAccessException) Property(org.ff4j.property.Property)

Example 32 with Property

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<?>>());
}
Also used : XmlParser(org.ff4j.conf.XmlParser) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 33 with 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;
}
Also used : Property(org.ff4j.property.Property) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) LinkedHashMap(java.util.LinkedHashMap)

Example 34 with Property

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();
        }
    }
}
Also used : Jedis(redis.clients.jedis.Jedis) Property(org.ff4j.property.Property) LinkedHashMap(java.util.LinkedHashMap)

Example 35 with Property

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);
}
Also used : FeatureAccessException(org.ff4j.exception.FeatureAccessException) JsonObject(com.couchbase.client.java.document.json.JsonObject) Property(org.ff4j.property.Property) FeatureAccessException(org.ff4j.exception.FeatureAccessException)

Aggregations

Property (org.ff4j.property.Property)56 HashMap (java.util.HashMap)20 PropertyString (org.ff4j.property.PropertyString)20 Test (org.junit.Test)20 Feature (org.ff4j.core.Feature)16 Map (java.util.Map)11 InputStream (java.io.InputStream)9 XmlParser (org.ff4j.conf.XmlParser)7 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)7 LinkedHashMap (java.util.LinkedHashMap)6 XmlConfig (org.ff4j.conf.XmlConfig)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 FeatureStore (org.ff4j.core.FeatureStore)4 PropertyAccessException (org.ff4j.exception.PropertyAccessException)4 PropertyStore (org.ff4j.property.store.PropertyStore)4 IOException (java.io.IOException)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)3