Search in sources :

Example 11 with FeatureNotFoundException

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);
}
Also used : FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with FeatureNotFoundException

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);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FeatureAccessException(org.ff4j.exception.FeatureAccessException) FeatureApiBean(org.ff4j.web.api.resources.domain.FeatureApiBean) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

Example 13 with FeatureNotFoundException

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();
        }
    }
}
Also used : Jedis(redis.clients.jedis.Jedis) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

Example 14 with FeatureNotFoundException

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();
        }
    }
}
Also used : Jedis(redis.clients.jedis.Jedis) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

Example 15 with FeatureNotFoundException

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());
}
Also used : GroupNotFoundException(org.ff4j.exception.GroupNotFoundException) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject)

Aggregations

FeatureNotFoundException (org.ff4j.exception.FeatureNotFoundException)23 Response (javax.ws.rs.core.Response)8 FeatureAccessException (org.ff4j.exception.FeatureAccessException)7 BasicDBObject (com.mongodb.BasicDBObject)3 DBObject (com.mongodb.DBObject)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 Path (javax.ws.rs.Path)3 Document (org.bson.Document)3 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)3 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 Jedis (redis.clients.jedis.Jedis)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 RolesAllowed (javax.annotation.security.RolesAllowed)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1