use of org.wso2.carbon.identity.configuration.mgt.core.dao.impl.CachedBackedConfigurationDAO in project carbon-identity-framework by wso2.
the class ConfigurationManagerComponent method activate.
/**
* Register ConfigurationManager as an OSGI service.
*
* @param componentContext OSGI service component context.
*/
@Activate
protected void activate(ComponentContext componentContext) {
try {
BundleContext bundleContext = componentContext.getBundleContext();
ConfigurationDAO configurationDAO = new ConfigurationDAOImpl();
bundleContext.registerService(ConfigurationDAO.class.getName(), configurationDAO, null);
bundleContext.registerService(ConfigurationDAO.class.getName(), new CachedBackedConfigurationDAO(configurationDAO), null);
ConfigurationManagerConfigurationHolder configurationManagerConfigurationHolder = new ConfigurationManagerConfigurationHolder();
configurationManagerConfigurationHolder.setConfigurationDAOS(configurationDAOs);
bundleContext.registerService(ConfigurationManager.class.getName(), new ConfigurationManagerImpl(configurationManagerConfigurationHolder), null);
ConfigurationManagerComponentDataHolder.getInstance().setConfigurationManagementEnabled(isConfigurationManagementEnabled());
setUseCreatedTime();
} catch (Throwable e) {
log.error("Error while activating ConfigurationManagerComponent.", e);
}
}
use of org.wso2.carbon.identity.configuration.mgt.core.dao.impl.CachedBackedConfigurationDAO 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);
}
}
Aggregations