Search in sources :

Example 1 with ERROR_CODE_GET_ATTRIBUTE

use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_ATTRIBUTE in project carbon-identity-framework by wso2.

the class ConfigurationDAOImpl method getAttributeByKey.

/**
 * {@inheritDoc}
 */
@Override
public Attribute getAttributeByKey(String resourceId, String attributeKey) throws ConfigurationManagementException {
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    try {
        return jdbcTemplate.fetchSingleRecord(SQLConstants.GET_ATTRIBUTE_SQL, (resultSet, rowNumber) -> new Attribute(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY), resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE), resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID)), preparedStatement -> {
            int initialParameterIndex = 1;
            preparedStatement.setString(initialParameterIndex, attributeKey);
            preparedStatement.setString(++initialParameterIndex, resourceId);
        });
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_GET_ATTRIBUTE, attributeKey, e);
    }
}
Also used : Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Aggregations

JdbcTemplate (org.wso2.carbon.database.utils.jdbc.JdbcTemplate)1 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)1 Attribute (org.wso2.carbon.identity.configuration.mgt.core.model.Attribute)1