Search in sources :

Example 1 with ConfigurationManagementClientException

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);
}
Also used : Attribute(org.wso2.carbon.identity.configuration.mgt.core.model.Attribute)

Example 2 with ConfigurationManagementClientException

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);
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(org.wso2.carbon.identity.api.server.common.error.ErrorResponse) ConfigurationManagementServerException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementServerException) ConfigurationManagementClientException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException) APIError(org.wso2.carbon.identity.api.server.common.error.APIError) ErrorResponse(org.wso2.carbon.identity.api.server.common.error.ErrorResponse)

Example 3 with ConfigurationManagementClientException

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);
    }
}
Also used : ResourceFile(org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile) InputStream(java.io.InputStream) Resource(org.wso2.carbon.identity.configuration.mgt.core.model.Resource) EventPublisherConfiguration(org.wso2.carbon.event.publisher.core.config.EventPublisherConfiguration) TenantResourceManagementClientException(org.wso2.carbon.identity.tenant.resource.manager.exception.TenantResourceManagementClientException) EventPublisherService(org.wso2.carbon.event.publisher.core.EventPublisherService) ConfigurationManagementException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException) ConfigurationManagementClientException(org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException) EventPublisherConfigurationException(org.wso2.carbon.event.publisher.core.exception.EventPublisherConfigurationException)

Aggregations

ConfigurationManagementClientException (org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementClientException)2 InputStream (java.io.InputStream)1 Response (javax.ws.rs.core.Response)1 EventPublisherService (org.wso2.carbon.event.publisher.core.EventPublisherService)1 EventPublisherConfiguration (org.wso2.carbon.event.publisher.core.config.EventPublisherConfiguration)1 EventPublisherConfigurationException (org.wso2.carbon.event.publisher.core.exception.EventPublisherConfigurationException)1 APIError (org.wso2.carbon.identity.api.server.common.error.APIError)1 ErrorResponse (org.wso2.carbon.identity.api.server.common.error.ErrorResponse)1 ConfigurationManagementException (org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementException)1 ConfigurationManagementServerException (org.wso2.carbon.identity.configuration.mgt.core.exception.ConfigurationManagementServerException)1 Attribute (org.wso2.carbon.identity.configuration.mgt.core.model.Attribute)1 Resource (org.wso2.carbon.identity.configuration.mgt.core.model.Resource)1 ResourceFile (org.wso2.carbon.identity.configuration.mgt.core.model.ResourceFile)1 TenantResourceManagementClientException (org.wso2.carbon.identity.tenant.resource.manager.exception.TenantResourceManagementClientException)1