Search in sources :

Example 1 with DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE

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

the class ConfigurationDAOImpl method getResourcesByType.

@Override
public List<Resource> getResourcesByType(int tenantId, String resourceTypeId) throws ConfigurationManagementServerException {
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    try {
        String resourceTypeName = jdbcTemplate.fetchSingleRecord(SQLConstants.GET_RESOURCE_TYPE_BY_ID_SQL, (resultSet, rowNumber) -> resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME), preparedStatement -> preparedStatement.setString(1, resourceTypeId));
        return jdbcTemplate.executeQuery(GET_RESOURCES_BY_RESOURCE_TYPE_ID_SQL, (LambdaExceptionUtils.rethrowRowMapper((resultSet, rowNumber) -> {
            String resourceId = resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID);
            String resourceName = resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME);
            String resourceLastModified = resultSet.getString(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED);
            String resourceCreatedTime = resultSet.getString(DB_SCHEMA_COLUMN_NAME_CREATED_TIME);
            String resourceHasFile = resultSet.getString(DB_SCHEMA_COLUMN_NAME_HAS_FILE);
            if (StringUtils.equals(resourceHasFile, "1") && (isOracleDB() || isMSSqlDB() || isDB2DB())) {
                resourceHasFile = "true";
            }
            String resourceHasAttribute = resultSet.getString(DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE);
            Resource resource = new Resource();
            resource.setCreatedTime(resourceCreatedTime);
            resource.setHasAttribute(Boolean.valueOf(resourceHasAttribute));
            resource.setResourceId(resourceId);
            resource.setResourceName(resourceName);
            resource.setLastModified(resourceLastModified);
            resource.setHasFile(Boolean.valueOf(resourceHasFile));
            resource.setTenantDomain(IdentityTenantUtil.getTenantDomain(tenantId));
            resource.setFiles(getFiles(resourceId, resourceTypeName, resourceName));
            resource.setAttributes(getAttributesByResourceId(resourceId));
            return resource;
        })), preparedStatement -> {
            preparedStatement.setString(1, resourceTypeId);
            preparedStatement.setInt(2, tenantId);
        });
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_RESOURCES_DOES_NOT_EXISTS, e);
    }
}
Also used : Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 2 with DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE

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

the class ConfigurationDAOImpl method getTenantResourceById.

/**
 * {@inheritDoc}
 */
@Override
public Resource getTenantResourceById(int tenantId, String resourceId) throws ConfigurationManagementException {
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    List<ConfigurationRawDataCollector> configurationRawDataCollectors;
    try {
        String queryWithCreatedTime = GET_RESOURCE_BY_ID_MYSQL;
        String queryWithOutCreatedTime = GET_RESOURCE_BY_ID_MYSQL_WITHOUT_CREATED_TIME;
        if (isOracleDB() || isMSSqlDB()) {
            queryWithCreatedTime = GET_RESOURCE_BY_ID_MSSQL_OR_ORACLE;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(useCreatedTimeField() ? queryWithCreatedTime : queryWithOutCreatedTime);
        sb.append(" AND R.TENANT_ID = ?");
        configurationRawDataCollectors = jdbcTemplate.executeQuery(sb.toString(), (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);
            preparedStatement.setInt(2, tenantId);
        });
        /*
            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)

Example 3 with DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE

use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE 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)

Example 4 with DB_SCHEMA_COLUMN_NAME_HAS_ATTRIBUTE

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

the class ConfigurationDAOImpl method getResourceByName.

/**
 * {@inheritDoc}
 */
@Override
public Resource getResourceByName(int tenantId, String resourceTypeId, String resourceName) throws ConfigurationManagementException {
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    List<ConfigurationRawDataCollector> configurationRawDataCollectors;
    try {
        String queryWithCreatedTime = GET_RESOURCE_BY_NAME_MYSQL;
        String queryWithOutCreatedTime = GET_RESOURCE_BY_NAME_MYSQL_WITHOUT_CREATED_TIME;
        if (isOracleDB() || isMSSqlDB()) {
            queryWithCreatedTime = GET_RESOURCE_BY_NAME_MSSQL_OR_ORACLE;
        }
        configurationRawDataCollectors = jdbcTemplate.executeQuery(useCreatedTimeField() ? queryWithCreatedTime : queryWithOutCreatedTime, (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)).setFileName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_FILE_NAME)).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 -> {
            int initialParameterIndex = 1;
            preparedStatement.setString(initialParameterIndex, resourceName);
            preparedStatement.setInt(++initialParameterIndex, tenantId);
            preparedStatement.setString(++initialParameterIndex, resourceTypeId);
        });
        /*
            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, resourceName, 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

JdbcTemplate (org.wso2.carbon.database.utils.jdbc.JdbcTemplate)4 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)4 InputStream (java.io.InputStream)3 Blob (java.sql.Blob)3 PreparedStatement (java.sql.PreparedStatement)3 SQLException (java.sql.SQLException)3 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)3 Timestamp (java.sql.Timestamp)3 UTC (java.time.ZoneOffset.UTC)3 ArrayList (java.util.ArrayList)3 Calendar (java.util.Calendar)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 TimeZone (java.util.TimeZone)3 StringUtils (org.apache.commons.lang.StringUtils)3 Log (org.apache.commons.logging.Log)3