Search in sources :

Example 1 with MultiFieldModel

use of com.synopsys.integration.alert.common.rest.model.MultiFieldModel in project hub-alert by blackducksoftware.

the class ConfigActions method readAllByContextAndDescriptorWithoutChecks.

@Override
protected ActionResponse<MultiFieldModel> readAllByContextAndDescriptorWithoutChecks(String context, String descriptorName) {
    ConfigContextEnum configContext = ConfigContextEnum.valueOf(context);
    Optional<DescriptorKey> descriptorKey = descriptorMap.getDescriptorKey(descriptorName);
    if (!descriptorKey.isPresent()) {
        return new ActionResponse<>(HttpStatus.BAD_REQUEST, String.format("Unknown descriptor: %s", descriptorName));
    }
    List<ConfigurationModel> configurationModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(descriptorKey.get(), configContext);
    List<FieldModel> fieldModels = convertConfigurationModelList(descriptorName, context, configurationModels);
    return new ActionResponse<>(HttpStatus.OK, new MultiFieldModel(fieldModels));
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) SettingsDescriptorKey(com.synopsys.integration.alert.component.settings.descriptor.SettingsDescriptorKey) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) MultiFieldModel(com.synopsys.integration.alert.common.rest.model.MultiFieldModel) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) MultiFieldModel(com.synopsys.integration.alert.common.rest.model.MultiFieldModel) ValidationActionResponse(com.synopsys.integration.alert.common.action.ValidationActionResponse) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 2 with MultiFieldModel

use of com.synopsys.integration.alert.common.rest.model.MultiFieldModel in project hub-alert by blackducksoftware.

the class BlackDuckProviderService method findBlackDuckProvider.

public String findBlackDuckProvider() throws IntegrationException {
    String blackDuckProviderSearch = String.format("/api/configuration?context=%s&descriptorName=%s", ConfigContextEnum.GLOBAL, blackDuckProviderKey);
    String response = alertRequestUtility.executeGetRequest(blackDuckProviderSearch, "Could not find the Black Duck provider.");
    MultiFieldModel blackDuckConfigurations = gson.fromJson(response, MultiFieldModel.class);
    FieldModel blackDuckProviderConfiguration = blackDuckConfigurations.getFieldModels().stream().filter(blackDuckConfiguration -> blackDuckConfiguration.getFieldValue("blackduck.url").filter(blackDuckProviderUrl::equals).isPresent()).findFirst().orElseThrow(() -> new IntegrationException("Could not find the BlackDuck provider configuration."));
    String blackDuckProviderID = blackDuckProviderConfiguration.getId();
    String blackDuckConfigBody = gson.toJson(blackDuckProviderConfiguration);
    alertRequestUtility.executePutRequest("/api/configuration/" + blackDuckProviderID, blackDuckConfigBody, "Could not save the Black Duck provider.");
    intLogger.info(String.format("Retrieved the Black Duck provider, ID %s.", blackDuckProviderID));
    return blackDuckProviderID;
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) MultiFieldModel(com.synopsys.integration.alert.common.rest.model.MultiFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) MultiFieldModel(com.synopsys.integration.alert.common.rest.model.MultiFieldModel)

Aggregations

FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)2 MultiFieldModel (com.synopsys.integration.alert.common.rest.model.MultiFieldModel)2 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)1 ValidationActionResponse (com.synopsys.integration.alert.common.action.ValidationActionResponse)1 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)1 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)1 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)1 SettingsDescriptorKey (com.synopsys.integration.alert.component.settings.descriptor.SettingsDescriptorKey)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1