use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class JdbcPropertyStore method listPropertyNames.
/**
* {@inheritDoc}
*/
public Set<String> listPropertyNames() {
Set<String> propertyNames = new HashSet<String>();
PreparedStatement ps = null;
Connection sqlConn = null;
ResultSet rs = null;
try {
sqlConn = getDataSource().getConnection();
ps = buildStatement(sqlConn, getQueryBuilder().getAllPropertiesNames());
rs = ps.executeQuery();
while (rs.next()) {
propertyNames.add(rs.getString(COL_PROPERTY_ID));
}
} catch (SQLException sqlEX) {
throw new PropertyAccessException("Cannot read properties within database, SQL ERROR", sqlEX);
} finally {
closeResultSet(rs);
closeStatement(ps);
closeConnection(sqlConn);
}
return propertyNames;
}
use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class PropertyStoreHttp method clear.
/**
* {@inheritDoc}
*/
public void clear() {
Util.assertHasLength(url);
WebTarget wr = getJerseyClient().target(url).path(RESOURCE_PROPERTYSTORE).path(STORE_CLEAR);
Response cRes = post(wr);
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new PropertyAccessException("Cannot clear property store - " + cRes.getStatus());
}
}
use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class PropertyStoreHttp method createSchema.
/**
* {@inheritDoc}
*/
@Override
public void createSchema() {
Util.assertHasLength(url);
WebTarget wr = getJerseyClient().target(url).path(RESOURCE_PROPERTYSTORE).path(STORE_CREATESCHEMA);
Response cRes = post(wr);
if (Status.OK.getStatusCode() != cRes.getStatus()) {
throw new PropertyAccessException("Cannot clear property store - " + cRes.getStatus());
}
}
use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class JdbcPropertyStore method existProperty.
/**
* {@inheritDoc}
*/
public boolean existProperty(String name) {
Util.assertHasLength(name);
PreparedStatement ps = null;
ResultSet rs = null;
Connection sqlConn = null;
try {
sqlConn = getDataSource().getConnection();
ps = buildStatement(sqlConn, getQueryBuilder().existProperty(), name);
rs = ps.executeQuery();
rs.next();
return 1 == rs.getInt(1);
} catch (SQLException sqlEX) {
throw new PropertyAccessException("Cannot check feature existence, error related to database", sqlEX);
} finally {
closeResultSet(rs);
closeStatement(ps);
closeConnection(sqlConn);
}
}
use of org.ff4j.exception.PropertyAccessException in project ff4j by ff4j.
the class JdbcPropertyStore method updateProperty.
/**
* {@inheritDoc}
*/
public void updateProperty(String name, String newValue) {
Util.assertHasLength(name);
Connection sqlConn = null;
PreparedStatement ps = null;
try {
sqlConn = getDataSource().getConnection();
// Check existence
Property<?> ab = readProperty(name);
// Check new value validity
ab.fromString(newValue);
ps = buildStatement(sqlConn, getQueryBuilder().updateProperty(), newValue, name);
ps.executeUpdate();
} catch (SQLException sqlEX) {
throw new PropertyAccessException("Cannot update property database, SQL ERROR", sqlEX);
} finally {
closeStatement(ps);
closeConnection(sqlConn);
}
}
Aggregations