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));
}
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;
}
Aggregations