Search in sources :

Example 21 with FeatureNotFoundException

use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.

the class FeatureStoreHttp method disable.

/**
 * {@inheritDoc}
 */
@Override
public void disable(String uid) {
    Util.assertHasLength(uid);
    Response cRes = ClientHttpUtils.invokePostMethod(getStore().path(uid).path(OPERATION_DISABLE), authorizationHeaderValue);
    if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
        throw new FeatureNotFoundException(uid);
    }
}
Also used : Response(javax.ws.rs.core.Response) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

Example 22 with FeatureNotFoundException

use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.

the class FeatureStoreHttp method enable.

/**
 * {@inheritDoc}
 */
@Override
public void enable(String uid) {
    Util.assertHasLength(uid);
    Response cRes = ClientHttpUtils.invokePostMethod(getStore().path(uid).path(OPERATION_ENABLE), authorizationHeaderValue);
    if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
        throw new FeatureNotFoundException(uid);
    }
}
Also used : Response(javax.ws.rs.core.Response) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

Example 23 with FeatureNotFoundException

use of org.ff4j.exception.FeatureNotFoundException in project ff4j by ff4j.

the class FeatureStoreHttp method delete.

/**
 * {@inheritDoc}
 */
@Override
public void delete(String uid) {
    Util.assertHasLength(uid);
    Response cRes = ClientHttpUtils.invokeDeleteMethod(getStore().path(uid), authorizationHeaderValue);
    if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
        throw new FeatureNotFoundException(uid);
    }
    if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
        throw new FeatureAccessException("Cannot delete feature, an HTTP error " + cRes.getStatus() + OCCURED);
    }
}
Also used : Response(javax.ws.rs.core.Response) FeatureAccessException(org.ff4j.exception.FeatureAccessException) FeatureNotFoundException(org.ff4j.exception.FeatureNotFoundException)

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