use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME in project carbon-identity-framework by wso2.
the class SecretDAOImpl method getSecretTypeByName.
@Override
public SecretType getSecretTypeByName(String secretTypeName) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
SecretType secretTypeResponse;
try {
secretTypeResponse = jdbcTemplate.fetchSingleRecord(GET_SECRET_TYPE_BY_NAME, (resultSet, rowNumber) -> {
SecretType secretType = new SecretType();
secretType.setId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID));
secretType.setName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME));
secretType.setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION));
return secretType;
}, preparedStatement -> preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_NAME, secretTypeName));
return secretTypeResponse;
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_RETRIEVE_SECRET_TYPE, secretTypeName, e);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME in project carbon-identity-framework by wso2.
the class SecretDAOImpl method addSecretType.
@Override
public void addSecretType(SecretType secretType) throws SecretManagementException {
NamedJdbcTemplate jdbcTemplate = getNewTemplate();
try {
jdbcTemplate.executeInsert(SQLConstants.INSERT_SECRET_TYPE, preparedStatement -> {
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secretType.getId());
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_NAME, secretType.getName());
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION, secretType.getDescription());
}, secretType, false);
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_ADD_SECRET_TYPE, secretType.getName(), e);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME 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);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME 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);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.constant.ConfigurationConstants.DB_SCHEMA_COLUMN_NAME_NAME in project carbon-identity-framework by wso2.
the class ConfigurationDAOImpl method getResourceTypeByIdentifier.
private ResourceType getResourceTypeByIdentifier(String name, String id) throws ConfigurationManagementException {
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
ResourceType resourceTypeResponse;
try {
resourceTypeResponse = jdbcTemplate.fetchSingleRecord(selectGetResourceTypeQuery(id), (resultSet, rowNumber) -> {
ResourceType resourceType = new ResourceType();
resourceType.setId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID));
resourceType.setName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME));
resourceType.setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTTION));
return resourceType;
}, preparedStatement -> preparedStatement.setString(1, StringUtils.isEmpty(name) ? id : name));
return resourceTypeResponse;
} catch (DataAccessException e) {
throw handleServerException(ERROR_CODE_RETRIEVE_RESOURCE_TYPE, name, e);
}
}
Aggregations