use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_NAME in project carbon-identity-framework by wso2.
the class ConfigurationDAOImpl method getFilesByResourceType.
@Override
public List<ResourceFile> getFilesByResourceType(String resourceTypeId, int tenantId) throws ConfigurationManagementServerException {
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
try {
return jdbcTemplate.executeQuery(GET_FILES_BY_RESOURCE_TYPE_ID_SQL, ((resultSet, rowNumber) -> {
String resourceFileId = resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID);
String resourceFileName = resultSet.getString(DB_SCHEMA_COLUMN_NAME_FILE_NAME);
String resourceName = resultSet.getString(DB_SCHEMA_COLUMN_NAME_RESOURCE_NAME);
String resourceTypeName = resultSet.getString(DB_SCHEMA_COLUMN_NAME_RESOURCE_TYPE_NAME);
return new ResourceFile(resourceFileId, getFilePath(resourceFileId, resourceTypeName, resourceName), resourceFileName);
}), preparedStatement -> {
preparedStatement.setString(1, resourceTypeId);
preparedStatement.setInt(2, tenantId);
});
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_GET_FILES_BY_TYPE, resourceTypeId, e);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_FILE_NAME 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);
}
}
Aggregations