Search in sources :

Example 16 with PropertyAccessException

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

the class PropertyStoreHttp method existProperty.

/**
 * {@inheritDoc}
 */
public boolean existProperty(String name) {
    Util.assertHasLength(name);
    Response cRes = ClientHttpUtils.invokeGetMethod(getStore().path(name), authorization);
    if (Status.OK.getStatusCode() == cRes.getStatus()) {
        return true;
    }
    if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
        return false;
    }
    throw new PropertyAccessException("Cannot check existence of property, an HTTP error " + cRes.getStatus() + " occured : " + cRes.getEntity());
}
Also used : Response(javax.ws.rs.core.Response) PropertyAccessException(org.ff4j.exception.PropertyAccessException)

Example 17 with PropertyAccessException

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

the class PropertyStoreHttp method readAllProperties.

/**
 * {@inheritDoc}
 */
public Map<String, Property<?>> readAllProperties() {
    Response cRes = ClientHttpUtils.invokeGetMethod(getStore(), authorization);
    if (Status.OK.getStatusCode() != cRes.getStatus()) {
        throw new PropertyAccessException("Cannot read properties, an HTTP error " + cRes.getStatus() + OCCURED);
    }
    String resEntity = cRes.readEntity(String.class);
    Property<?>[] pArray = PropertyJsonParser.parsePropertyArray(resEntity);
    Map<String, Property<?>> properties = new HashMap<String, Property<?>>();
    for (Property<?> pName : pArray) {
        properties.put(pName.getName(), pName);
    }
    return properties;
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) PropertyAccessException(org.ff4j.exception.PropertyAccessException) Property(org.ff4j.property.Property)

Example 18 with PropertyAccessException

use of org.ff4j.exception.PropertyAccessException 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

PropertyAccessException (org.ff4j.exception.PropertyAccessException)18 Connection (java.sql.Connection)8 PreparedStatement (java.sql.PreparedStatement)8 SQLException (java.sql.SQLException)8 JdbcUtils.closeConnection (org.ff4j.utils.JdbcUtils.closeConnection)8 Response (javax.ws.rs.core.Response)5 ResultSet (java.sql.ResultSet)4 PropertyNotFoundException (org.ff4j.exception.PropertyNotFoundException)4 Property (org.ff4j.property.Property)4 JdbcUtils.closeResultSet (org.ff4j.utils.JdbcUtils.closeResultSet)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 HashMap (java.util.HashMap)3 IOException (java.io.IOException)2 WebTarget (javax.ws.rs.client.WebTarget)2 Connection (org.apache.hadoop.hbase.client.Connection)2 Table (org.apache.hadoop.hbase.client.Table)2 HBaseConnection (org.ff4j.hbase.HBaseConnection)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1