Search in sources :

Example 6 with PropertyNotFoundException

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

the class PropertyStoreHttp method deleteProperty.

/**
 * {@inheritDoc}
 */
public void deleteProperty(String name) {
    Util.assertHasLength(name);
    ClientResponse cRes = getStore().path(name).delete(ClientResponse.class);
    if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
        throw new PropertyNotFoundException(name);
    }
    if (Status.NO_CONTENT.getStatusCode() != cRes.getStatus()) {
        throw new PropertyAccessException("Cannot delete property, an HTTP error " + cRes.getStatus() + OCCURED);
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PropertyNotFoundException(org.ff4j.exception.PropertyNotFoundException) PropertyAccessException(org.ff4j.exception.PropertyAccessException)

Example 7 with PropertyNotFoundException

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

the class PropertyStoreCassandra method readProperty.

/**
 * {@inheritDoc}
 */
@Override
public Property<?> readProperty(String name) {
    assertPropertyExist(name);
    ResultSet rs = cqlSession.execute(psReadProperty.bind(name));
    Row row = rs.one();
    if (null == row) {
        throw new PropertyNotFoundException(name);
    }
    return mapPropertyRow(row);
}
Also used : PropertyNotFoundException(org.ff4j.exception.PropertyNotFoundException) ResultSet(com.datastax.oss.driver.api.core.cql.ResultSet) Row(com.datastax.oss.driver.api.core.cql.Row)

Example 8 with PropertyNotFoundException

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

the class PropertyStoreHttp method deleteProperty.

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

Aggregations

PropertyNotFoundException (org.ff4j.exception.PropertyNotFoundException)8 PropertyAccessException (org.ff4j.exception.PropertyAccessException)4 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 SQLException (java.sql.SQLException)2 Response (javax.ws.rs.core.Response)2 JdbcUtils.closeConnection (org.ff4j.utils.JdbcUtils.closeConnection)2 ResultSet (com.datastax.oss.driver.api.core.cql.ResultSet)1 Row (com.datastax.oss.driver.api.core.cql.Row)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 ResultSet (java.sql.ResultSet)1 PropertyAlreadyExistException (org.ff4j.exception.PropertyAlreadyExistException)1 PropertyString (org.ff4j.property.PropertyString)1 JdbcUtils.closeResultSet (org.ff4j.utils.JdbcUtils.closeResultSet)1