Search in sources :

Example 11 with CouchDbFeature

use of org.ff4j.couchdb.document.CouchDbFeature in project ff4j by ff4j.

the class FeatureStoreCouchDb method delete.

/**
 * {@inheritDoc}
 */
@Override
public void delete(String uid) {
    if (uid == null || uid.isEmpty()) {
        throw new IllegalArgumentException(FEATURE_IDENTIFIER_CANNOT_BE_NULL_NOR_EMPTY);
    }
    if (!exist(uid)) {
        throw new FeatureNotFoundException(uid);
    }
    CouchDbFeature couchDbFeature = getFeature(uid);
    removeFeature(couchDbFeature);
}
Also used : CouchDbFeature(org.ff4j.couchdb.document.CouchDbFeature) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

Example 12 with CouchDbFeature

use of org.ff4j.couchdb.document.CouchDbFeature in project ff4j by ff4j.

the class FeatureStoreCouchDb 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);
    }
    List<CouchDbFeature> features = getFeatures(groupName);
    if (null != features) {
        features.forEach(f -> {
            Feature feat = fromJson(f.getFeature());
            if (null != feat) {
                feat.setEnable(true);
                f.setFeature(feat.toJson());
                updateFeature(f);
            }
        });
    }
}
Also used : CouchDbFeature(org.ff4j.couchdb.document.CouchDbFeature) GroupNotFoundException(org.ff4j.exception.GroupNotFoundException) CouchDbFeature(org.ff4j.couchdb.document.CouchDbFeature) Feature(org.ff4j.core.Feature)

Aggregations

CouchDbFeature (org.ff4j.couchdb.document.CouchDbFeature)12 Feature (org.ff4j.core.Feature)9 FeatureNotFoundException (org.ff4j.exception.FeatureNotFoundException)6 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)4 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 FeatureAlreadyExistException (org.ff4j.exception.FeatureAlreadyExistException)1