use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_ATTRIBUTE in project carbon-identity-framework by wso2.
the class ConfigurationDAOImpl method addAttribute.
/**
* {@inheritDoc}
*/
@Override
public void addAttribute(String attributeId, String resourceId, Attribute attribute) throws ConfigurationManagementException {
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
try {
jdbcTemplate.withTransaction(template -> {
template.executeUpdate(SQLConstants.INSERT_ATTRIBUTE_MYSQL, preparedStatement -> {
int initialParameterIndex = 1;
preparedStatement.setString(initialParameterIndex, attributeId);
preparedStatement.setString(++initialParameterIndex, resourceId);
preparedStatement.setString(++initialParameterIndex, attribute.getKey());
preparedStatement.setString(++initialParameterIndex, attribute.getValue());
});
template.executeUpdate(SQLConstants.UPDATE_LAST_MODIFIED_SQL, preparedStatement -> {
int initialParameterIndex = 1;
preparedStatement.setTimestamp(initialParameterIndex, new java.sql.Timestamp(new Date().getTime()), calendar);
preparedStatement.setString(++initialParameterIndex, resourceId);
});
return null;
});
} catch (TransactionException e) {
throw handleServerException(ERROR_CODE_INSERT_ATTRIBUTE, attribute.getKey(), e);
}
}
Aggregations