use of org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException in project carbon-identity-framework by wso2.
the class ConfigurationDAOImpl method insertResourceAttributes.
private void insertResourceAttributes(Template<?> template, Resource resource) throws DataAccessException, ConfigurationManagementClientException {
// Create sql query for attribute parameters.
String attributesQuery = buildQueryForAttributes(resource);
template.executeInsert(attributesQuery, preparedStatement -> {
int attributeUpdateParameterIndex = 0;
for (Attribute attribute : resource.getAttributes()) {
preparedStatement.setString(++attributeUpdateParameterIndex, generateUniqueID());
preparedStatement.setString(++attributeUpdateParameterIndex, resource.getResourceId());
preparedStatement.setString(++attributeUpdateParameterIndex, attribute.getKey());
preparedStatement.setString(++attributeUpdateParameterIndex, attribute.getValue());
}
}, resource, false);
}
use of org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException in project identity-api-server by wso2.
the class NotificationSenderManagementService method handleConfigurationMgtException.
private APIError handleConfigurationMgtException(ConfigurationManagementException e, NotificationSenderManagementConstants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse;
Response.Status status;
if (e instanceof ConfigurationManagementClientException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e.getMessage());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorCode = errorCode.contains(CONFIG_MGT_ERROR_CODE_DELIMITER) ? errorCode : NOTIFICATION_SENDER_ERROR_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.BAD_REQUEST;
} else if (e instanceof ConfigurationManagementServerException) {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
if (e.getErrorCode() != null) {
String errorCode = e.getErrorCode();
errorCode = errorCode.contains(CONFIG_MGT_ERROR_CODE_DELIMITER) ? errorCode : NOTIFICATION_SENDER_ERROR_PREFIX + errorCode;
errorResponse.setCode(errorCode);
}
errorResponse.setDescription(e.getMessage());
status = Response.Status.INTERNAL_SERVER_ERROR;
} else {
errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException in project identity-governance by wso2-extensions.
the class ResourceManagerImpl method removeEventPublisherConfiguration.
@Override
public void removeEventPublisherConfiguration(String resourceTypeName, String resourceName) throws TenantResourceManagementException {
try {
Resource resource = TenantResourceManagerDataHolder.getInstance().getConfigurationManager().getResource(resourceTypeName, resourceName);
ResourceFile resourceFile = resource.getFiles().get(0);
InputStream publisherConfig = TenantResourceManagerDataHolder.getInstance().getConfigurationManager().getFileById(PUBLISHER, resourceFile.getName(), resourceFile.getId());
EventPublisherService carbonEventPublisherService = TenantResourceManagerDataHolder.getInstance().getCarbonEventPublisherService();
EventPublisherConfiguration eventPublisherConfiguration = carbonEventPublisherService.getEventPublisherConfiguration(publisherConfig);
if (TenantResourceManagerDataHolder.getInstance().getCarbonEventPublisherService().getActiveEventPublisherConfiguration(eventPublisherConfiguration.getEventPublisherName()) != null) {
destroyEventPublisherConfiguration(eventPublisherConfiguration);
// Since the tenant event publisher was removed, we should load super tenant configs.
loadSuperTenantEventPublisherConfigs();
}
} catch (ConfigurationManagementException e) {
if (e instanceof ConfigurationManagementClientException && e.getErrorCode().equals(ConfigurationConstants.ErrorMessages.ERROR_CODE_RESOURCE_DOES_NOT_EXISTS.getCode())) {
throw new TenantResourceManagementClientException(e.getMessage(), e.getErrorCode());
}
throw handleServerException(ERROR_CODE_ERROR_WHEN_FETCHING_EVENT_PUBLISHER_RESOURCE, e, resourceName, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
} catch (EventPublisherConfigurationException e) {
throw handleServerException(ERROR_CODE_ERROR_WHEN_DEPLOYING_EVENT_PUBLISHER_CONFIGURATION, e, resourceName);
}
}
Aggregations