use of com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method createBlackDuckServicesFactory.
private BlackDuckServicesFactory createBlackDuckServicesFactory(ConfigurationModel blackDuckConfiguration) throws AlertException {
BlackDuckProperties properties = blackDuckPropertiesFactory.createProperties(blackDuckConfiguration);
BlackDuckHttpClient blackDuckHttpClient = properties.createBlackDuckHttpClient(logger);
return properties.createBlackDuckServicesFactory(blackDuckHttpClient, logger);
}
use of com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient in project hub-alert by blackducksoftware.
the class BlackDuckPhoneHomeHandler method populatePhoneHomeData.
@Override
public PhoneHomeRequestBodyBuilder populatePhoneHomeData(ConfigurationModel configurationModel, NameVersion alertArtifactInfo) {
String registrationId = null;
String blackDuckUrl = PhoneHomeRequestBody.UNKNOWN_FIELD_VALUE;
String blackDuckVersion = PhoneHomeRequestBody.UNKNOWN_FIELD_VALUE;
try {
descriptorAccessor.getRegisteredDescriptorById(configurationModel.getDescriptorId());
StatefulProvider statefulProvider = provider.createStatefulProvider(configurationModel);
BlackDuckProperties blackDuckProperties = (BlackDuckProperties) statefulProvider.getProperties();
BlackDuckHttpClient blackDuckHttpClient = blackDuckProperties.createBlackDuckHttpClient(logger);
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckProperties.createBlackDuckServicesFactory(blackDuckHttpClient, new Slf4jIntLogger(logger));
BlackDuckRegistrationService blackDuckRegistrationService = blackDuckServicesFactory.createBlackDuckRegistrationService();
BlackDuckServerData blackDuckServerData = blackDuckRegistrationService.getBlackDuckServerData();
blackDuckVersion = blackDuckServerData.getVersion();
registrationId = blackDuckServerData.getRegistrationKey().orElse(null);
blackDuckUrl = blackDuckProperties.getBlackDuckUrl().orElse(PhoneHomeRequestBody.UNKNOWN_FIELD_VALUE);
} catch (IntegrationException ignored) {
// ignoring this exception
}
// We must check if the reg id is blank because of an edge case in which Black Duck can authenticate (while the webserver is coming up) without registration
if (StringUtils.isBlank(registrationId)) {
registrationId = PhoneHomeRequestBody.UNKNOWN_FIELD_VALUE;
}
PhoneHomeRequestBodyBuilder phoneHomeBuilder = new PhoneHomeRequestBodyBuilder(registrationId, blackDuckUrl, alertArtifactInfo, UniquePhoneHomeProduct.BLACK_DUCK, blackDuckVersion);
return phoneHomeBuilder;
}
use of com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient in project hub-alert by blackducksoftware.
the class BlackDuckCacheHttpClientCache method retrieveOrCreateBlackDuckCacheHttpClient.
public BlackDuckHttpClient retrieveOrCreateBlackDuckCacheHttpClient(Long blackDuckConfigId) throws IntegrationException {
BlackDuckHttpClient cachedClient = httpClientCache.get(blackDuckConfigId);
if (null != cachedClient) {
return cachedClient;
}
BlackDuckProperties properties = blackDuckPropertiesFactory.createProperties(blackDuckConfigId).orElseThrow(() -> new AlertConfigurationException(String.format("No BlackDuck configuration with id %s", blackDuckConfigId)));
BlackDuckHttpClient blackDuckCacheClient = properties.createBlackDuckCacheClient(new Slf4jIntLogger(logger));
httpClientCache.put(blackDuckConfigId, blackDuckCacheClient);
return blackDuckCacheClient;
}
use of com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient in project hub-alert by blackducksoftware.
the class BlackDuckIssueTrackerCallbackEventHandler method createBlackDuckServicesFactory.
private Optional<BlackDuckServicesFactory> createBlackDuckServicesFactory(BlackDuckProperties blackDuckProperties) {
IntLogger intLogger = new Slf4jIntLogger(logger);
try {
BlackDuckHttpClient blackDuckHttpClient = blackDuckProperties.createBlackDuckHttpClient(intLogger);
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckProperties.createBlackDuckServicesFactory(blackDuckHttpClient, intLogger);
return Optional.of(blackDuckServicesFactory);
} catch (AlertException e) {
logger.error("Failed to create a BlackDuck http client", e);
return Optional.empty();
}
}
use of com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient in project hub-alert by blackducksoftware.
the class BlackDuckDataSyncTask method runProviderTask.
@Override
public void runProviderTask() {
try {
BlackDuckProperties providerProperties = getProviderProperties();
Optional<BlackDuckHttpClient> optionalBlackDuckHttpClient = providerProperties.createBlackDuckHttpClientAndLogErrors(logger);
if (optionalBlackDuckHttpClient.isPresent()) {
BlackDuckHttpClient blackDuckHttpClient = optionalBlackDuckHttpClient.get();
BlackDuckServicesFactory blackDuckServicesFactory = providerProperties.createBlackDuckServicesFactory(blackDuckHttpClient, new Slf4jIntLogger(logger));
ProjectUsersService projectUsersService = blackDuckServicesFactory.createProjectUsersService();
BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
ApiDiscovery apiDiscovery = blackDuckServicesFactory.getApiDiscovery();
List<ProjectView> projectViews = blackDuckApiClient.getAllResponses(apiDiscovery.metaProjectsLink());
Map<ProjectView, ProviderProject> blackDuckToAlertProjects = mapBlackDuckProjectsToAlertProjects(projectViews, blackDuckApiClient);
Map<ProviderProject, Set<String>> projectToEmailAddresses = getEmailsPerProject(blackDuckToAlertProjects, projectUsersService);
Set<String> allRelevantBlackDuckUsers = getAllActiveBlackDuckUserEmailAddresses(blackDuckApiClient, apiDiscovery);
blackDuckDataAccessor.updateProjectAndUserData(providerProperties.getConfigId(), projectToEmailAddresses, allRelevantBlackDuckUsers);
} else {
logger.error("Missing BlackDuck global configuration.");
}
} catch (IntegrationException | AlertRuntimeException e) {
logger.error(String.format("Could not retrieve the current data from the BlackDuck server: %s", e.getMessage()), e);
}
}
Aggregations