use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.
the class FeatureStoreSpringJdbc method delete.
/**
* {@inheritDoc}
*/
@Override
@Transactional
public void delete(String uid) {
if (!exist(uid))
throw new FeatureNotFoundException(uid);
deletePermissions(uid);
deleteProperties(uid);
deleteCoreFeature(uid);
}
use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.
the class FeatureStoreHttp method update.
/**
* {@inheritDoc}
*/
@Override
public void update(Feature fp) {
Util.assertNotNull(fp);
if (!exist(fp.getUid())) {
throw new FeatureNotFoundException(fp.getUid());
}
ClientResponse cRes = //
getStore().path(fp.getUid()).type(MediaType.APPLICATION_JSON).put(ClientResponse.class, new FeatureApiBean(fp));
if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
throw new FeatureAccessException("Cannot update feature, an HTTP error " + cRes.getStatus() + OCCURED);
}
}
use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.
the class FeatureStoreRedis method delete.
/**
* {@inheritDoc}
*/
public void delete(String fpId) {
if (!exist(fpId)) {
throw new FeatureNotFoundException(fpId);
}
Jedis jedis = null;
try {
jedis = getJedis();
// Store the feature in the mapping bucket.
jedis.srem(KEY_FEATURE_MAP, fpId);
jedis.del(KEY_FEATURE + fpId);
} finally {
if (jedis != null) {
jedis.close();
}
}
}
use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.
the class FeatureStoreRedis method update.
/**
* {@inheritDoc}
*/
@Override
public void update(Feature fp) {
Util.assertNotNull("Feature", fp);
if (!exist(fp.getUid())) {
throw new FeatureNotFoundException(fp.getUid());
}
Jedis jedis = null;
try {
jedis = getJedis();
jedis.set(KEY_FEATURE + fp.getUid(), fp.toJson());
jedis.persist(KEY_FEATURE + fp.getUid());
} finally {
if (jedis != null) {
jedis.close();
}
}
}
use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.
the class FeatureStoreMongoDB method removeFromGroup.
/**
* {@inheritDoc}
*/
@Override
public void removeFromGroup(String uid, String groupName) {
if (uid == null || uid.isEmpty()) {
throw new IllegalArgumentException(FEATURE_IDENTIFIER_CANNOT_BE_NULL_NOR_EMPTY);
}
if (groupName == null || groupName.isEmpty()) {
throw new IllegalArgumentException(GROUPNAME_CANNOT_BE_NULL_NOR_EMPTY);
}
if (!exist(uid)) {
throw new FeatureNotFoundException(uid);
}
if (!existGroup(groupName)) {
throw new GroupNotFoundException(groupName);
}
DBObject target = BUILDER.getFeatUid(uid);
DBObject nGroupName = BUILDER.getGroupName("");
getFeaturesCollection().update(target, BasicDBObjectBuilder.start(MONGO_SET, nGroupName).get());
}
Aggregations