Search in sources :

Example 56 with DataAccessException

use of org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException in project carbon-identity-framework by wso2.

the class ConfigurationDAOImpl method getTenantResources.

/**
 * {@inheritDoc}
 */
@Override
public Resources getTenantResources(Condition condition) throws ConfigurationManagementException {
    PlaceholderSQL placeholderSQL = buildPlaceholderSQL(condition, useCreatedTimeField());
    if (placeholderSQL.getQuery().getBytes().length > getMaximumQueryLengthInBytes()) {
        if (log.isDebugEnabled()) {
            log.debug("Error building SQL query for the search. Search expression " + "query length: " + placeholderSQL.getQuery().length() + " exceeds the maximum limit: " + MAX_QUERY_LENGTH_IN_BYTES_SQL);
        }
        throw handleClientException(ERROR_CODE_QUERY_LENGTH_EXCEEDED, null);
    }
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    List<ConfigurationRawDataCollector> configurationRawDataCollectors;
    try {
        configurationRawDataCollectors = jdbcTemplate.executeQuery(placeholderSQL.getQuery(), (resultSet, rowNumber) -> {
            ConfigurationRawDataCollector.ConfigurationRawDataCollectorBuilder configurationRawDataCollectorBuilder = new ConfigurationRawDataCollector.ConfigurationRawDataCollectorBuilder().setResourceId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID)).setTenantId(resultSet.getInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID)).setResourceName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME)).setLastModified(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, calendar)).setResourceTypeName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE)).setResourceTypeDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTTION)).setAttributeKey(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY)).setAttributeValue(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE)).setAttributeId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID)).setFileId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_FILE_ID));
            if (useCreatedTimeField()) {
                configurationRawDataCollectorBuilder.setCreatedTime(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_CREATED_TIME, calendar));
            }
            return configurationRawDataCollectorBuilder.build();
        }, preparedStatement -> {
            for (int count = 0; count < placeholderSQL.getData().size(); count++) {
                if (placeholderSQL.getData().get(count).getClass().equals(Integer.class)) {
                    preparedStatement.setInt(count + 1, (Integer) placeholderSQL.getData().get(count));
                } else {
                    preparedStatement.setString(count + 1, (String) placeholderSQL.getData().get(count));
                }
            }
        });
        /*
            Database call can contain duplicate data for some columns. Need to filter them in order to build the
            resource.
            */
        return configurationRawDataCollectors == null || configurationRawDataCollectors.size() == 0 ? null : buildResourcesFromRawData(configurationRawDataCollectors);
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_SEARCH_TENANT_RESOURCES, null, e);
    }
}
Also used : INSERT_OR_UPDATE_RESOURCE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_POSTGRESQL) MAX_QUERY_LENGTH_IN_BYTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.MAX_QUERY_LENGTH_IN_BYTES_SQL) DELETE_FILES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILES_SQL) StringUtils(org.apache.commons.lang.StringUtils) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) INSERT_OR_UPDATE_ATTRIBUTE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MYSQL) DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) ConfigurationManagementException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException) INSERT_RESOURCE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL) ERROR_CODE_INSERT_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_FILE) ERROR_CODE_GET_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILE) Map(java.util.Map) Condition(org.wso2.carbon.identity.configuration.mgt.core.search.Condition) ERROR_CODE_REPLACE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_ATTRIBUTE) ERROR_CODE_RESOURCE_ALREADY_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCE_ALREADY_EXISTS) INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2) INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE) INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) ConfigurationUtils.getMaximumQueryLengthInBytes(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getMaximumQueryLengthInBytes) Set(java.util.Set) GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME) PreparedStatement(java.sql.PreparedStatement) SQLConstants(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants) JdbcUtils.isOracleDB(org.wso2.carbon.identity.core.util.JdbcUtils.isOracleDB) ERROR_CODE_UPDATE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_ATTRIBUTE) ConfigurationManagementClientException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException) INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2) GET_RESOURCE_TYPE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_TYPE_ID_BY_NAME_SQL) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_INSERT_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_ATTRIBUTE) ERROR_CODE_DELETE_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILE) ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR) GET_FILES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_TYPE_ID_SQL) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) ERROR_CODE_ADD_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE_TYPE) ERROR_CODE_ADD_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE) ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) INSERT_OR_UPDATE_RESOURCE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_ORACLE) INSERT_OR_UPDATE_RESOURCE_TYPE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_H2) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) Calendar(java.util.Calendar) INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_QUERY_LENGTH_EXCEEDED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_QUERY_LENGTH_EXCEEDED) DB_SCHEMA_COLUMN_NAME_DESCRIPTTION(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTTION) INSERT_OR_UPDATE_ATTRIBUTE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_H2) GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE) UPDATE_HAS_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_HAS_FILE_SQL) JdbcUtils.isMSSqlDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMSSqlDB) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID) ERROR_CODE_DELETE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE) ERROR_CODE_REPLACE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_RESOURCE) GET_RESOURCE_CREATED_TIME_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_CREATED_TIME_BY_NAME_SQL) GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE) DB_SCHEMA_COLUMN_NAME_HAS_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_FILE) GET_FILES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_ID_SQL) ERROR_CODE_DELETE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_ATTRIBUTE) ERROR_CODE_CHECK_DB_METADATA(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_CHECK_DB_METADATA) GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE) ERROR_CODE_UPDATE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_RESOURCE_TYPE) Resources(org.wso2.carbon.identity.configuration.mgt.core.model.Resources) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ID) UPDATE_RESOURCE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE_H2) INSERT_OR_UPDATE_ATTRIBUTES_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MYSQL) ConfigurationUtils.handleClientException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME) Date(java.util.Date) Template(org.wso2.carbon.database.utils.jdbc.Template) DB_SCHEMA_COLUMN_NAME_FILE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_NAME) ERROR_CODE_GET_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME) GET_RESOURCE_NAME_BY_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_NAME_BY_ID) DB_SCHEMA_COLUMN_NAME_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_VALUE) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ERROR_CODE_RESOURCES_DOES_NOT_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCES_DOES_NOT_EXISTS) GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL) DB_SCHEMA_COLUMN_NAME_FILE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_ID) INSERT_OR_UPDATE_ATTRIBUTE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_ORACLE) ERROR_CODE_GET_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) PrimitiveConditionValidator(org.wso2.carbon.identity.configuration.mgt.core.search.PrimitiveConditionValidator) DELETE_ATTRIBUTE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_ATTRIBUTE_SQL) ERROR_CODE_RETRIEVE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RETRIEVE_RESOURCE_TYPE) JdbcUtils.isMariaDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMariaDB) ERROR_CODE_DELETE_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILES) INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL) ConfigurationManagementServerException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementServerException) List(java.util.List) DELETE_RESOURCE_ATTRIBUTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_RESOURCE_ATTRIBUTES_SQL) JdbcUtils.isH2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isH2DB) ConfigurationUtils.handleServerException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleServerException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL) GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL) ERROR_CODE_GET_FILES_BY_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES_BY_TYPE) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) HashMap(java.util.HashMap) ConfigurationDAO(org.wso2.carbon.identity.configuration.mgt.core.dao.ConfigurationDAO) HashSet(java.util.HashSet) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY) PrimitiveConditionValidationException(org.wso2.carbon.identity.configuration.mgt.core.search.exception.PrimitiveConditionValidationException) GET_RESOURCE_BY_ID_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL) INSERT_OR_UPDATE_ATTRIBUTES_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_ORACLE) INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME) INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL) INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME) GET_RESOURCE_BY_NAME_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL) UPDATE_LAST_MODIFIED_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_LAST_MODIFIED_SQL) ERROR_CODE_SEARCH_TENANT_RESOURCES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_TENANT_RESOURCES) PlaceholderSQL(org.wso2.carbon.identity.configuration.mgt.core.search.PlaceholderSQL) JdbcUtils(org.wso2.carbon.identity.core.util.JdbcUtils) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME) ConfigurationUtils.generateUniqueID(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.generateUniqueID) GET_RESOURCE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_BY_NAME_SQL) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME) GET_ATTRIBUTES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_ATTRIBUTES_BY_RESOURCE_ID_SQL) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) DB_SCHEMA_COLUMN_NAME_RESOURCE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_ID) JdbcUtils.isMySQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMySQLDB) Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) ConfigurationUtils.useCreatedTimeField(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.useCreatedTimeField) INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE) UPDATE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE) ResourceSearchBean(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean) ERROR_CODE_DELETE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE_TYPE) DELETE_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILE_SQL) JdbcUtils.isPostgreSQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isPostgreSQLDB) INSERT_OR_UPDATE_RESOURCE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL) Log(org.apache.commons.logging.Log) Blob(java.sql.Blob) ConfigurationUtils.getFilePath(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getFilePath) ERROR_CODE_GET_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_RESOURCE) JdbcUtils.isDB2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isDB2DB) InputStream(java.io.InputStream) PlaceholderSQL(org.wso2.carbon.identity.configuration.mgt.core.search.PlaceholderSQL) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 57 with DataAccessException

use of org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException in project carbon-identity-framework by wso2.

the class ConfigurationDAOImpl method addResource.

/**
 * {@inheritDoc}
 */
@Override
public void addResource(Resource resource) throws ConfigurationManagementException {
    String resourceTypeId = getResourceTypeByName(resource.getResourceType()).getId();
    Timestamp currentTime = new java.sql.Timestamp(new Date().getTime());
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    try {
        boolean isOracleOrMssql = isOracleDB() || isMSSqlDB();
        jdbcTemplate.withTransaction(template -> {
            boolean isAttributeExists = resource.getAttributes() != null;
            boolean isFileExists = resource.getFiles() != null && !resource.getFiles().isEmpty();
            // Insert resource metadata.
            template.executeInsert(useCreatedTimeField() ? INSERT_RESOURCE_SQL : INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME, preparedStatement -> {
                int initialParameterIndex = 1;
                preparedStatement.setString(initialParameterIndex, resource.getResourceId());
                preparedStatement.setInt(++initialParameterIndex, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
                preparedStatement.setString(++initialParameterIndex, resource.getResourceName());
                if (useCreatedTimeField()) {
                    preparedStatement.setTimestamp(++initialParameterIndex, currentTime, calendar);
                }
                preparedStatement.setTimestamp(++initialParameterIndex, currentTime, calendar);
                if (isOracleOrMssql) {
                    preparedStatement.setInt(++initialParameterIndex, isFileExists ? 1 : 0);
                    preparedStatement.setInt(++initialParameterIndex, isAttributeExists ? 1 : 0);
                } else {
                    preparedStatement.setBoolean(++initialParameterIndex, isFileExists);
                    preparedStatement.setBoolean(++initialParameterIndex, isAttributeExists);
                }
                preparedStatement.setString(++initialParameterIndex, resourceTypeId);
            }, resource, false);
            // Insert attributes.
            if (isAttributeExists) {
                insertResourceAttributes(template, resource);
            }
            // Insert files.
            if (isFileExists) {
                for (ResourceFile file : resource.getFiles()) {
                    insertResourceFile(template, resource, file.getId(), file.getName(), file.getInputStream());
                }
            }
            return null;
        });
        resource.setLastModified(currentTime.toInstant().toString());
        if (useCreatedTimeField()) {
            resource.setCreatedTime(currentTime.toInstant().toString());
        }
    } catch (TransactionException e) {
        throw handleServerException(ERROR_CODE_ADD_RESOURCE, resource.getResourceName(), e);
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_CHECK_DB_METADATA, e.getMessage(), e);
    }
}
Also used : ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) Timestamp(java.sql.Timestamp) Date(java.util.Date) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 58 with DataAccessException

use of org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException in project carbon-identity-framework by wso2.

the class ConfigurationDAOImpl method updateMetadataForMYSQL.

private void updateMetadataForMYSQL(Resource resource, String resourceTypeId, boolean isAttributeExists, Timestamp currentTime, boolean useCreatedTime) throws TransactionException, ConfigurationManagementServerException {
    String query = INSERT_OR_UPDATE_RESOURCE_MYSQL;
    try {
        if (isPostgreSQLDB()) {
            query = INSERT_OR_UPDATE_RESOURCE_POSTGRESQL;
        } else if (isMSSqlDB() || isDB2DB()) {
            query = INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2;
        } else if (isOracleDB()) {
            query = INSERT_OR_UPDATE_RESOURCE_ORACLE;
        }
        boolean isOracleOrMssql = isOracleDB() || isMSSqlDB();
        JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
        final String finalQuery = query;
        jdbcTemplate.withTransaction(template -> template.executeInsert(useCreatedTime ? finalQuery : INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME, preparedStatement -> {
            int initialParameterIndex = 1;
            preparedStatement.setString(initialParameterIndex, resource.getResourceId());
            preparedStatement.setInt(++initialParameterIndex, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
            preparedStatement.setString(++initialParameterIndex, resource.getResourceName());
            if (useCreatedTime) {
                preparedStatement.setTimestamp(++initialParameterIndex, currentTime, calendar);
            }
            preparedStatement.setTimestamp(++initialParameterIndex, currentTime, calendar);
            if (isOracleOrMssql) {
                preparedStatement.setInt(++initialParameterIndex, 0);
                preparedStatement.setInt(++initialParameterIndex, isAttributeExists ? 1 : 0);
            } else {
                preparedStatement.setBoolean(++initialParameterIndex, false);
                preparedStatement.setBoolean(++initialParameterIndex, isAttributeExists);
            }
            preparedStatement.setString(++initialParameterIndex, resourceTypeId);
        }, resource, false));
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_CHECK_DB_METADATA, e.getMessage(), e);
    }
}
Also used : INSERT_OR_UPDATE_RESOURCE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_POSTGRESQL) MAX_QUERY_LENGTH_IN_BYTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.MAX_QUERY_LENGTH_IN_BYTES_SQL) DELETE_FILES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILES_SQL) StringUtils(org.apache.commons.lang.StringUtils) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) INSERT_OR_UPDATE_ATTRIBUTE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MYSQL) DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) ConfigurationManagementException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException) INSERT_RESOURCE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL) ERROR_CODE_INSERT_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_FILE) ERROR_CODE_GET_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILE) Map(java.util.Map) Condition(org.wso2.carbon.identity.configuration.mgt.core.search.Condition) ERROR_CODE_REPLACE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_ATTRIBUTE) ERROR_CODE_RESOURCE_ALREADY_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCE_ALREADY_EXISTS) INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2) INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE) INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) ConfigurationUtils.getMaximumQueryLengthInBytes(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getMaximumQueryLengthInBytes) Set(java.util.Set) GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME) PreparedStatement(java.sql.PreparedStatement) SQLConstants(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants) JdbcUtils.isOracleDB(org.wso2.carbon.identity.core.util.JdbcUtils.isOracleDB) ERROR_CODE_UPDATE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_ATTRIBUTE) ConfigurationManagementClientException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException) INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2) GET_RESOURCE_TYPE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_TYPE_ID_BY_NAME_SQL) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_INSERT_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_ATTRIBUTE) ERROR_CODE_DELETE_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILE) ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR) GET_FILES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_TYPE_ID_SQL) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) ERROR_CODE_ADD_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE_TYPE) ERROR_CODE_ADD_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE) ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) INSERT_OR_UPDATE_RESOURCE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_ORACLE) INSERT_OR_UPDATE_RESOURCE_TYPE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_H2) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) Calendar(java.util.Calendar) INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_QUERY_LENGTH_EXCEEDED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_QUERY_LENGTH_EXCEEDED) DB_SCHEMA_COLUMN_NAME_DESCRIPTTION(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTTION) INSERT_OR_UPDATE_ATTRIBUTE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_H2) GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE) UPDATE_HAS_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_HAS_FILE_SQL) JdbcUtils.isMSSqlDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMSSqlDB) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID) ERROR_CODE_DELETE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE) ERROR_CODE_REPLACE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_RESOURCE) GET_RESOURCE_CREATED_TIME_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_CREATED_TIME_BY_NAME_SQL) GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE) DB_SCHEMA_COLUMN_NAME_HAS_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_FILE) GET_FILES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_ID_SQL) ERROR_CODE_DELETE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_ATTRIBUTE) ERROR_CODE_CHECK_DB_METADATA(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_CHECK_DB_METADATA) GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE) ERROR_CODE_UPDATE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_RESOURCE_TYPE) Resources(org.wso2.carbon.identity.configuration.mgt.core.model.Resources) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ID) UPDATE_RESOURCE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE_H2) INSERT_OR_UPDATE_ATTRIBUTES_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MYSQL) ConfigurationUtils.handleClientException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME) Date(java.util.Date) Template(org.wso2.carbon.database.utils.jdbc.Template) DB_SCHEMA_COLUMN_NAME_FILE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_NAME) ERROR_CODE_GET_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME) GET_RESOURCE_NAME_BY_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_NAME_BY_ID) DB_SCHEMA_COLUMN_NAME_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_VALUE) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ERROR_CODE_RESOURCES_DOES_NOT_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCES_DOES_NOT_EXISTS) GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL) DB_SCHEMA_COLUMN_NAME_FILE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_ID) INSERT_OR_UPDATE_ATTRIBUTE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_ORACLE) ERROR_CODE_GET_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) PrimitiveConditionValidator(org.wso2.carbon.identity.configuration.mgt.core.search.PrimitiveConditionValidator) DELETE_ATTRIBUTE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_ATTRIBUTE_SQL) ERROR_CODE_RETRIEVE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RETRIEVE_RESOURCE_TYPE) JdbcUtils.isMariaDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMariaDB) ERROR_CODE_DELETE_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILES) INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL) ConfigurationManagementServerException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementServerException) List(java.util.List) DELETE_RESOURCE_ATTRIBUTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_RESOURCE_ATTRIBUTES_SQL) JdbcUtils.isH2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isH2DB) ConfigurationUtils.handleServerException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleServerException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL) GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL) ERROR_CODE_GET_FILES_BY_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES_BY_TYPE) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) HashMap(java.util.HashMap) ConfigurationDAO(org.wso2.carbon.identity.configuration.mgt.core.dao.ConfigurationDAO) HashSet(java.util.HashSet) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY) PrimitiveConditionValidationException(org.wso2.carbon.identity.configuration.mgt.core.search.exception.PrimitiveConditionValidationException) GET_RESOURCE_BY_ID_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL) INSERT_OR_UPDATE_ATTRIBUTES_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_ORACLE) INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME) INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL) INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME) GET_RESOURCE_BY_NAME_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL) UPDATE_LAST_MODIFIED_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_LAST_MODIFIED_SQL) ERROR_CODE_SEARCH_TENANT_RESOURCES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_TENANT_RESOURCES) PlaceholderSQL(org.wso2.carbon.identity.configuration.mgt.core.search.PlaceholderSQL) JdbcUtils(org.wso2.carbon.identity.core.util.JdbcUtils) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME) ConfigurationUtils.generateUniqueID(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.generateUniqueID) GET_RESOURCE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_BY_NAME_SQL) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME) GET_ATTRIBUTES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_ATTRIBUTES_BY_RESOURCE_ID_SQL) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) DB_SCHEMA_COLUMN_NAME_RESOURCE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_ID) JdbcUtils.isMySQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMySQLDB) Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) ConfigurationUtils.useCreatedTimeField(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.useCreatedTimeField) INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE) UPDATE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE) ResourceSearchBean(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean) ERROR_CODE_DELETE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE_TYPE) DELETE_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILE_SQL) JdbcUtils.isPostgreSQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isPostgreSQLDB) INSERT_OR_UPDATE_RESOURCE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL) Log(org.apache.commons.logging.Log) Blob(java.sql.Blob) ConfigurationUtils.getFilePath(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getFilePath) ERROR_CODE_GET_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_RESOURCE) JdbcUtils.isDB2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isDB2DB) InputStream(java.io.InputStream) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 59 with DataAccessException

use of org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException in project carbon-identity-framework by wso2.

the class ConfigurationDAOImpl method deleteResourceTypeByName.

/**
 * {@inheritDoc}
 */
@Override
public void deleteResourceTypeByName(String resourceTypeName) throws ConfigurationManagementException {
    try {
        if (isMySQLDB()) {
            JdbcTemplate jdbcTemplateGetResourceTypeId = JdbcUtils.getNewTemplate();
            String resourceTypeId = jdbcTemplateGetResourceTypeId.withTransaction(template -> template.fetchSingleRecord(GET_RESOURCE_TYPE_ID_BY_NAME_SQL, (resultSet, rowNumber) -> resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID), preparedStatement -> {
                int initialParameterIndex = 1;
                preparedStatement.setString(initialParameterIndex, resourceTypeName);
            }));
            JdbcTemplate jdbcTemplateGetIds = JdbcUtils.getNewTemplate();
            jdbcTemplateGetIds.executeQuery(GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL, ((resultSet, rowNumber) -> {
                String ResourceId = resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID);
                int TenantId = resultSet.getInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID);
                try {
                    CachedBackedConfigurationDAO cachedBackedConfigurationDAO = new CachedBackedConfigurationDAO(this);
                    cachedBackedConfigurationDAO.deleteResourceById(TenantId, ResourceId);
                } catch (ConfigurationManagementException e) {
                    log.error(ERROR_CODE_DELETE_RESOURCE + ResourceId, e);
                }
                return null;
            }), preparedStatement -> preparedStatement.setString(1, resourceTypeId));
        }
    } catch (TransactionException | DataAccessException e) {
        throw handleServerException(ERROR_CODE_DELETE_RESOURCE_TYPE, resourceTypeName, e);
    }
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    try {
        jdbcTemplate.executeUpdate(selectDeleteResourceTypeQuery(null), (preparedStatement -> preparedStatement.setString(1, resourceTypeName)));
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_DELETE_RESOURCE_TYPE, resourceTypeName, e);
    }
}
Also used : INSERT_OR_UPDATE_RESOURCE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_POSTGRESQL) MAX_QUERY_LENGTH_IN_BYTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.MAX_QUERY_LENGTH_IN_BYTES_SQL) DELETE_FILES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILES_SQL) StringUtils(org.apache.commons.lang.StringUtils) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) INSERT_OR_UPDATE_ATTRIBUTE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MYSQL) DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) ConfigurationManagementException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException) INSERT_RESOURCE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL) ERROR_CODE_INSERT_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_FILE) ERROR_CODE_GET_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILE) Map(java.util.Map) Condition(org.wso2.carbon.identity.configuration.mgt.core.search.Condition) ERROR_CODE_REPLACE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_ATTRIBUTE) ERROR_CODE_RESOURCE_ALREADY_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCE_ALREADY_EXISTS) INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2) INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE) INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) ConfigurationUtils.getMaximumQueryLengthInBytes(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getMaximumQueryLengthInBytes) Set(java.util.Set) GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME) PreparedStatement(java.sql.PreparedStatement) SQLConstants(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants) JdbcUtils.isOracleDB(org.wso2.carbon.identity.core.util.JdbcUtils.isOracleDB) ERROR_CODE_UPDATE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_ATTRIBUTE) ConfigurationManagementClientException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException) INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2) GET_RESOURCE_TYPE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_TYPE_ID_BY_NAME_SQL) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_INSERT_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_ATTRIBUTE) ERROR_CODE_DELETE_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILE) ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR) GET_FILES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_TYPE_ID_SQL) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) ERROR_CODE_ADD_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE_TYPE) ERROR_CODE_ADD_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE) ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) INSERT_OR_UPDATE_RESOURCE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_ORACLE) INSERT_OR_UPDATE_RESOURCE_TYPE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_H2) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) Calendar(java.util.Calendar) INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_QUERY_LENGTH_EXCEEDED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_QUERY_LENGTH_EXCEEDED) DB_SCHEMA_COLUMN_NAME_DESCRIPTTION(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTTION) INSERT_OR_UPDATE_ATTRIBUTE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_H2) GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE) UPDATE_HAS_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_HAS_FILE_SQL) JdbcUtils.isMSSqlDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMSSqlDB) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID) ERROR_CODE_DELETE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE) ERROR_CODE_REPLACE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_RESOURCE) GET_RESOURCE_CREATED_TIME_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_CREATED_TIME_BY_NAME_SQL) GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE) DB_SCHEMA_COLUMN_NAME_HAS_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_FILE) GET_FILES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_ID_SQL) ERROR_CODE_DELETE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_ATTRIBUTE) ERROR_CODE_CHECK_DB_METADATA(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_CHECK_DB_METADATA) GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE) ERROR_CODE_UPDATE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_RESOURCE_TYPE) Resources(org.wso2.carbon.identity.configuration.mgt.core.model.Resources) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ID) UPDATE_RESOURCE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE_H2) INSERT_OR_UPDATE_ATTRIBUTES_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MYSQL) ConfigurationUtils.handleClientException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME) Date(java.util.Date) Template(org.wso2.carbon.database.utils.jdbc.Template) DB_SCHEMA_COLUMN_NAME_FILE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_NAME) ERROR_CODE_GET_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME) GET_RESOURCE_NAME_BY_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_NAME_BY_ID) DB_SCHEMA_COLUMN_NAME_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_VALUE) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ERROR_CODE_RESOURCES_DOES_NOT_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCES_DOES_NOT_EXISTS) GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL) DB_SCHEMA_COLUMN_NAME_FILE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_ID) INSERT_OR_UPDATE_ATTRIBUTE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_ORACLE) ERROR_CODE_GET_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) PrimitiveConditionValidator(org.wso2.carbon.identity.configuration.mgt.core.search.PrimitiveConditionValidator) DELETE_ATTRIBUTE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_ATTRIBUTE_SQL) ERROR_CODE_RETRIEVE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RETRIEVE_RESOURCE_TYPE) JdbcUtils.isMariaDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMariaDB) ERROR_CODE_DELETE_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILES) INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL) ConfigurationManagementServerException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementServerException) List(java.util.List) DELETE_RESOURCE_ATTRIBUTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_RESOURCE_ATTRIBUTES_SQL) JdbcUtils.isH2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isH2DB) ConfigurationUtils.handleServerException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleServerException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL) GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL) ERROR_CODE_GET_FILES_BY_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES_BY_TYPE) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) HashMap(java.util.HashMap) ConfigurationDAO(org.wso2.carbon.identity.configuration.mgt.core.dao.ConfigurationDAO) HashSet(java.util.HashSet) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY) PrimitiveConditionValidationException(org.wso2.carbon.identity.configuration.mgt.core.search.exception.PrimitiveConditionValidationException) GET_RESOURCE_BY_ID_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL) INSERT_OR_UPDATE_ATTRIBUTES_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_ORACLE) INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME) INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL) INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME) GET_RESOURCE_BY_NAME_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL) UPDATE_LAST_MODIFIED_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_LAST_MODIFIED_SQL) ERROR_CODE_SEARCH_TENANT_RESOURCES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_TENANT_RESOURCES) PlaceholderSQL(org.wso2.carbon.identity.configuration.mgt.core.search.PlaceholderSQL) JdbcUtils(org.wso2.carbon.identity.core.util.JdbcUtils) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME) ConfigurationUtils.generateUniqueID(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.generateUniqueID) GET_RESOURCE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_BY_NAME_SQL) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME) GET_ATTRIBUTES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_ATTRIBUTES_BY_RESOURCE_ID_SQL) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) DB_SCHEMA_COLUMN_NAME_RESOURCE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_ID) JdbcUtils.isMySQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMySQLDB) Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) ConfigurationUtils.useCreatedTimeField(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.useCreatedTimeField) INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE) UPDATE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE) ResourceSearchBean(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean) ERROR_CODE_DELETE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE_TYPE) DELETE_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILE_SQL) JdbcUtils.isPostgreSQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isPostgreSQLDB) INSERT_OR_UPDATE_RESOURCE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL) Log(org.apache.commons.logging.Log) Blob(java.sql.Blob) ConfigurationUtils.getFilePath(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getFilePath) ERROR_CODE_GET_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_RESOURCE) JdbcUtils.isDB2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isDB2DB) InputStream(java.io.InputStream) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) ConfigurationManagementException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 60 with DataAccessException

use of org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException in project carbon-identity-framework by wso2.

the class ConfigurationDAOImpl method getResourceById.

/**
 * {@inheritDoc}
 */
@Override
public Resource getResourceById(String resourceId) throws ConfigurationManagementException {
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    List<ConfigurationRawDataCollector> configurationRawDataCollectors;
    try {
        configurationRawDataCollectors = jdbcTemplate.executeQuery(useCreatedTimeField() ? GET_RESOURCE_BY_ID_MYSQL : GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME, (resultSet, rowNumber) -> {
            ConfigurationRawDataCollector.ConfigurationRawDataCollectorBuilder configurationRawDataCollectorBuilder = new ConfigurationRawDataCollector.ConfigurationRawDataCollectorBuilder().setResourceId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID)).setTenantId(resultSet.getInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID)).setResourceName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME)).setLastModified(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, calendar)).setResourceTypeName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE)).setResourceTypeDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTTION)).setAttributeKey(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY)).setAttributeValue(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE)).setAttributeId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID)).setFileId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_FILE_ID)).setHasFile(resultSet.getBoolean(DB_SCHEMA_COLUMN_NAME_HAS_FILE)).setHasAttribute(resultSet.getBoolean(DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE));
            if (useCreatedTimeField()) {
                configurationRawDataCollectorBuilder.setCreatedTime(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_CREATED_TIME, calendar));
            }
            return configurationRawDataCollectorBuilder.build();
        }, preparedStatement -> preparedStatement.setString(1, resourceId));
        /*
            Database call can contain duplicate data for some columns. Need to filter them in order to build the
            resource.
            */
        return configurationRawDataCollectors == null || configurationRawDataCollectors.size() == 0 ? null : buildResourceFromRawData(configurationRawDataCollectors);
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_GET_RESOURCE, "id = " + resourceId, e);
    }
}
Also used : INSERT_OR_UPDATE_RESOURCE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_POSTGRESQL) MAX_QUERY_LENGTH_IN_BYTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.MAX_QUERY_LENGTH_IN_BYTES_SQL) DELETE_FILES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILES_SQL) StringUtils(org.apache.commons.lang.StringUtils) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) ResourceType(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceType) INSERT_OR_UPDATE_ATTRIBUTE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MYSQL) DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) ConfigurationManagementException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException) INSERT_RESOURCE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL) ERROR_CODE_INSERT_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_FILE) ERROR_CODE_GET_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILE) Map(java.util.Map) Condition(org.wso2.carbon.identity.configuration.mgt.core.search.Condition) ERROR_CODE_REPLACE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_ATTRIBUTE) ERROR_CODE_RESOURCE_ALREADY_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCE_ALREADY_EXISTS) INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MSSQL_OR_DB2) INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_POSTGRESQL) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_VALUE) INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MSSQL_OR_DB2) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) ConfigurationUtils.getMaximumQueryLengthInBytes(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getMaximumQueryLengthInBytes) Set(java.util.Set) GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME) PreparedStatement(java.sql.PreparedStatement) SQLConstants(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants) JdbcUtils.isOracleDB(org.wso2.carbon.identity.core.util.JdbcUtils.isOracleDB) ERROR_CODE_UPDATE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_ATTRIBUTE) ConfigurationManagementClientException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException) INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_MSSQL_OR_DB2) GET_RESOURCE_TYPE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_TYPE_ID_BY_NAME_SQL) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_INSERT_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_INSERT_ATTRIBUTE) ERROR_CODE_DELETE_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILE) ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_QUERY_SQL_PROPERTY_PARSE_ERROR) GET_FILES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_TYPE_ID_SQL) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) ERROR_CODE_ADD_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE_TYPE) ERROR_CODE_ADD_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_ADD_RESOURCE) ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) INSERT_OR_UPDATE_RESOURCE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_ORACLE) INSERT_OR_UPDATE_RESOURCE_TYPE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_H2) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) Calendar(java.util.Calendar) INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_MSSQL_OR_DB2) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_QUERY_LENGTH_EXCEEDED(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_QUERY_LENGTH_EXCEEDED) DB_SCHEMA_COLUMN_NAME_DESCRIPTTION(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTTION) INSERT_OR_UPDATE_ATTRIBUTE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_H2) GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MSSQL_OR_ORACLE) UPDATE_HAS_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_HAS_FILE_SQL) JdbcUtils.isMSSqlDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMSSqlDB) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_ID) ERROR_CODE_DELETE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE) ERROR_CODE_REPLACE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_REPLACE_RESOURCE) GET_RESOURCE_CREATED_TIME_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_CREATED_TIME_BY_NAME_SQL) GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE) DB_SCHEMA_COLUMN_NAME_HAS_FILE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_FILE) GET_FILES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_FILES_BY_RESOURCE_ID_SQL) ERROR_CODE_DELETE_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_ATTRIBUTE) ERROR_CODE_CHECK_DB_METADATA(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_CHECK_DB_METADATA) GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE) ERROR_CODE_UPDATE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_UPDATE_RESOURCE_TYPE) Resources(org.wso2.carbon.identity.configuration.mgt.core.model.Resources) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ID) UPDATE_RESOURCE_H2(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE_H2) INSERT_OR_UPDATE_ATTRIBUTES_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_MYSQL) ConfigurationUtils.handleClientException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME) Date(java.util.Date) Template(org.wso2.carbon.database.utils.jdbc.Template) DB_SCHEMA_COLUMN_NAME_FILE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_NAME) ERROR_CODE_GET_ATTRIBUTE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_ATTRIBUTE) DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME) GET_RESOURCE_NAME_BY_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_NAME_BY_ID) DB_SCHEMA_COLUMN_NAME_VALUE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_VALUE) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) ERROR_CODE_RESOURCES_DOES_NOT_EXISTS(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCES_DOES_NOT_EXISTS) GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL) DB_SCHEMA_COLUMN_NAME_FILE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_ID) INSERT_OR_UPDATE_ATTRIBUTE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_ORACLE) ERROR_CODE_GET_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) PrimitiveConditionValidator(org.wso2.carbon.identity.configuration.mgt.core.search.PrimitiveConditionValidator) DELETE_ATTRIBUTE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_ATTRIBUTE_SQL) ERROR_CODE_RETRIEVE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_RETRIEVE_RESOURCE_TYPE) JdbcUtils.isMariaDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMariaDB) ERROR_CODE_DELETE_FILES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_FILES) INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTE_POSTGRESQL) ConfigurationManagementServerException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementServerException) List(java.util.List) DELETE_RESOURCE_ATTRIBUTES_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_RESOURCE_ATTRIBUTES_SQL) JdbcUtils.isH2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isH2DB) ConfigurationUtils.handleServerException(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.handleServerException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL) GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_TENANT_ID_BY_TYPE_ID_SQL) ERROR_CODE_GET_FILES_BY_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_FILES_BY_TYPE) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) HashMap(java.util.HashMap) ConfigurationDAO(org.wso2.carbon.identity.configuration.mgt.core.dao.ConfigurationDAO) HashSet(java.util.HashSet) DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_ATTRIBUTE_KEY) PrimitiveConditionValidationException(org.wso2.carbon.identity.configuration.mgt.core.search.exception.PrimitiveConditionValidationException) GET_RESOURCE_BY_ID_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_ID_MYSQL) INSERT_OR_UPDATE_ATTRIBUTES_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_ATTRIBUTES_ORACLE) INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_RESOURCE_SQL_WITHOUT_CREATED_TIME) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME) INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_POSTGRESQL) INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL_WITHOUT_CREATED_TIME) GET_RESOURCE_BY_NAME_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_BY_NAME_MYSQL) UPDATE_LAST_MODIFIED_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_LAST_MODIFIED_SQL) ERROR_CODE_SEARCH_TENANT_RESOURCES(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_SEARCH_TENANT_RESOURCES) PlaceholderSQL(org.wso2.carbon.identity.configuration.mgt.core.search.PlaceholderSQL) JdbcUtils(org.wso2.carbon.identity.core.util.JdbcUtils) GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_TENANT_RESOURCES_SELECT_COLUMNS_MYSQL_WITHOUT_CREATED_TIME) ConfigurationUtils.generateUniqueID(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.generateUniqueID) GET_RESOURCE_ID_BY_NAME_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_RESOURCE_ID_BY_NAME_SQL) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME) GET_ATTRIBUTES_BY_RESOURCE_ID_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.GET_ATTRIBUTES_BY_RESOURCE_ID_SQL) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) DB_SCHEMA_COLUMN_NAME_RESOURCE_ID(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_RESOURCE_ID) JdbcUtils.isMySQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isMySQLDB) Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute) ConfigurationUtils.useCreatedTimeField(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.useCreatedTimeField) INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_TYPE_ORACLE) UPDATE_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.UPDATE_RESOURCE) ResourceSearchBean(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceSearchBean) ERROR_CODE_DELETE_RESOURCE_TYPE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_DELETE_RESOURCE_TYPE) DELETE_FILE_SQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.DELETE_FILE_SQL) JdbcUtils.isPostgreSQLDB(org.wso2.carbon.identity.core.util.JdbcUtils.isPostgreSQLDB) INSERT_OR_UPDATE_RESOURCE_MYSQL(org.wso2.carbon.identity.configuration.mgt.core.constant.SQLConstants.INSERT_OR_UPDATE_RESOURCE_MYSQL) Log(org.apache.commons.logging.Log) Blob(java.sql.Blob) ConfigurationUtils.getFilePath(org.wso2.carbon.identity.configuration.mgt.core.util.ConfigurationUtils.getFilePath) ERROR_CODE_GET_RESOURCE(org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.ErrorMessages.ERROR_CODE_GET_RESOURCE) JdbcUtils.isDB2DB(org.wso2.carbon.identity.core.util.JdbcUtils.isDB2DB) InputStream(java.io.InputStream) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Aggregations

DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)79 JdbcTemplate (org.wso2.carbon.database.utils.jdbc.JdbcTemplate)58 PreparedStatement (java.sql.PreparedStatement)33 SQLException (java.sql.SQLException)33 List (java.util.List)31 Log (org.apache.commons.logging.Log)29 LogFactory (org.apache.commons.logging.LogFactory)29 TransactionException (org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException)28 ArrayList (java.util.ArrayList)26 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)25 Map (java.util.Map)25 HashMap (java.util.HashMap)24 HashSet (java.util.HashSet)22 Set (java.util.Set)22 StringUtils (org.apache.commons.lang.StringUtils)22 Timestamp (java.sql.Timestamp)21 IdentityTenantUtil (org.wso2.carbon.identity.core.util.IdentityTenantUtil)21 Date (java.util.Date)19 Calendar (java.util.Calendar)18 JdbcUtils.isH2DB (org.wso2.carbon.identity.core.util.JdbcUtils.isH2DB)18