use of org.ff4j.exception.PropertyNotFoundException in project ff4j by ff4j.
the class PropertyStoreAwsSSM method createOrUpdate.
private <T> void createOrUpdate(Property<T> property, boolean overwrite) {
Util.assertNotNull(property);
Util.assertHasLength(property.getName());
if (overwrite && !existProperty(property.getName())) {
throw new PropertyNotFoundException(property.getName());
}
try {
client.putParameter(builder -> builder.name(path + "/" + property.getName()).type(ParameterType.STRING).value(property.asString()).overwrite(overwrite).description(property.getDescription()));
} catch (ParameterAlreadyExistsException pae) {
throw new PropertyAlreadyExistException(property.getName());
}
}
use of org.ff4j.exception.PropertyNotFoundException in project ff4j by ff4j.
the class JdbcPropertyStore method readProperty.
/**
* {@inheritDoc}
*/
public Property<?> readProperty(String name) {
Util.assertHasLength(name);
Connection sqlConn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
sqlConn = getDataSource().getConnection();
if (!existProperty(name)) {
throw new PropertyNotFoundException(name);
}
// Returns features
ps = buildStatement(sqlConn, getQueryBuilder().getProperty(), name);
rs = ps.executeQuery();
rs.next();
return JDBC_MAPPER.map(rs);
} catch (SQLException sqlEX) {
throw new PropertyAccessException("Cannot check property existence, error related to database", sqlEX);
} finally {
closeResultSet(rs);
closeStatement(ps);
closeConnection(sqlConn);
}
}
use of org.ff4j.exception.PropertyNotFoundException in project ff4j by ff4j.
the class JdbcPropertyStore method deleteProperty.
/**
* {@inheritDoc}
*/
public void deleteProperty(String name) {
Util.assertHasLength(name);
Connection sqlConn = null;
PreparedStatement ps = null;
try {
sqlConn = getDataSource().getConnection();
if (!existProperty(name)) {
throw new PropertyNotFoundException(name);
}
ps = buildStatement(sqlConn, getQueryBuilder().deleteProperty(), name);
ps.executeUpdate();
} catch (SQLException sqlEX) {
throw new PropertyAccessException("Cannot delete property database, SQL ERROR", sqlEX);
} finally {
closeStatement(ps);
closeConnection(sqlConn);
}
}
use of org.ff4j.exception.PropertyNotFoundException in project ff4j by ff4j.
the class PropertyStoreHttp method readProperty.
/**
* {@inheritDoc}
*/
public Property<?> readProperty(String name) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Property name cannot be null nor empty");
}
Response cRes = ClientHttpUtils.invokeGetMethod(getStore().path(name), authorization);
if (Status.NOT_FOUND.getStatusCode() == cRes.getStatus()) {
throw new PropertyNotFoundException(name);
}
String resEntity = (String) cRes.readEntity(String.class);
return PropertyJsonParser.parseProperty(resEntity);
}
use of org.ff4j.exception.PropertyNotFoundException in project ff4j by ff4j.
the class PropertyStoreCommonsConfig method readProperty.
/**
* {@inheritDoc}
*/
@Override
public Property<?> readProperty(String name) {
Util.assertHasLength(name);
String value = conf().getString(name);
if (value == null) {
throw new PropertyNotFoundException(name);
}
return new PropertyString(name, value);
}
Aggregations