use of org.wso2.carbon.identity.tenant.resource.manager.exception.TenantResourceManagementClientException in project identity-api-server by wso2.
the class NotificationSenderManagementService method handleTenantResourceManagementException.
private APIError handleTenantResourceManagementException(TenantResourceManagementException e, NotificationSenderManagementConstants.ErrorMessage errorEnum, String data) {
ErrorResponse errorResponse = getErrorBuilder(errorEnum, data).build(log, e, errorEnum.getDescription());
Response.Status status;
if (e instanceof TenantResourceManagementClientException) {
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 TenantResourceManagementServerException) {
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 {
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.tenant.resource.manager.exception.TenantResourceManagementClientException 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