use of org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_H2 in project carbon-identity-framework by wso2.
the class ConfigurationDAOImpl method replaceAttribute.
/**
* {@inheritDoc}
*/
@Override
public void replaceAttribute(String attributeId, String resourceId, Attribute attribute) throws ConfigurationManagementException {
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
try {
jdbcTemplate.withTransaction(template -> {
String query = INSERT_OR_UPDATE_ATTRIBUTE_MYSQL;
if (isH2DB()) {
query = INSERT_OR_UPDATE_ATTRIBUTE_H2;
} else if (isPostgreSQLDB()) {
query = INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL;
} else if (isMSSqlDB() || isDB2DB()) {
query = INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2;
} else if (isOracleDB()) {
query = INSERT_OR_UPDATE_ATTRIBUTE_ORACLE;
}
template.executeUpdate(query, 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_REPLACE_ATTRIBUTE, attribute.getKey(), e);
}
}
Aggregations