use of com.synopsys.integration.log.Slf4jIntLogger in project hub-alert by blackducksoftware.
the class NotificationExtractorBlackDuckServicesFactoryCache method createBlackDuckServicesFactory.
private BlackDuckServicesFactory createBlackDuckServicesFactory(Long blackDuckConfigId) throws AlertConfigurationException {
Optional<BlackDuckProperties> optionalProperties = blackDuckPropertiesFactory.createProperties(blackDuckConfigId);
if (optionalProperties.isPresent()) {
BlackDuckProperties blackDuckProperties = optionalProperties.get();
Slf4jIntLogger intLogger = new Slf4jIntLogger(logger);
try {
BlackDuckHttpClient blackDuckHttpClient = blackDuckProperties.createBlackDuckCacheClient(intLogger);
return blackDuckProperties.createBlackDuckServicesFactory(blackDuckHttpClient, intLogger);
} catch (AlertException e) {
throw new AlertConfigurationException("The BlackDuck configuration is invalid", e);
}
}
throw new AlertConfigurationException(String.format("No BlackDuck configuration with id '%s' existed", blackDuckConfigId));
}
use of com.synopsys.integration.log.Slf4jIntLogger in project hub-alert by blackducksoftware.
the class BlackDuckSystemValidator method validate.
public boolean validate(BlackDuckProperties blackDuckProperties) {
boolean valid = true;
String configName = blackDuckProperties.getConfigName();
logger.info("Validating Black Duck configuration '{}'...", configName);
try {
Optional<String> blackDuckUrlOptional = blackDuckProperties.getBlackDuckUrl();
removeOldConfigMessages(blackDuckProperties, SystemMessageType.BLACKDUCK_PROVIDER_CONNECTIVITY, SystemMessageType.BLACKDUCK_PROVIDER_LOCALHOST, SystemMessageType.BLACKDUCK_PROVIDER_URL_MISSING);
String errorMessage = String.format(MISSING_BLACKDUCK_URL_ERROR_W_CONFIG_FORMAT, configName);
String urlMissingType = createProviderSystemMessageType(blackDuckProperties, SystemMessageType.BLACKDUCK_PROVIDER_URL_MISSING);
boolean missingUrl = addSystemMessageForError(errorMessage, SystemMessageSeverity.WARNING, urlMissingType, blackDuckUrlOptional.isEmpty());
if (missingUrl) {
logger.error(" -> {}", String.format(MISSING_BLACKDUCK_CONFIG_ERROR_FORMAT, configName));
valid = false;
}
if (blackDuckUrlOptional.isPresent()) {
String blackDuckUrlString = blackDuckUrlOptional.get();
Integer timeout = blackDuckProperties.getBlackDuckTimeout();
logger.debug(" -> Black Duck configuration '{}' URL found validating: {}", configName, blackDuckUrlString);
logger.debug(" -> Black Duck configuration '{}' Timeout: {}", configName, timeout);
URL blackDuckUrl = new URL(blackDuckUrlString);
String localhostMissingType = createProviderSystemMessageType(blackDuckProperties, SystemMessageType.BLACKDUCK_PROVIDER_LOCALHOST);
boolean localHostError = addSystemMessageForError(String.format(BLACKDUCK_LOCALHOST_ERROR_FORMAT, configName), SystemMessageSeverity.WARNING, localhostMissingType, "localhost".equals(blackDuckUrl.getHost()));
if (localHostError) {
logger.warn(" -> {}", String.format(BLACKDUCK_LOCALHOST_ERROR_FORMAT, configName));
}
IntLogger intLogger = new Slf4jIntLogger(logger);
BlackDuckServerConfig blackDuckServerConfig = blackDuckProperties.createBlackDuckServerConfig(intLogger);
boolean canConnect = blackDuckServerConfig.canConnect(intLogger);
if (canConnect) {
logger.info(" -> Black Duck configuration '{}' is Valid!", configName);
} else {
String message = String.format("Can not connect to the Black Duck server with the configuration '%s'.", configName);
connectivityWarning(blackDuckProperties, message);
valid = false;
}
} else {
String message = String.format("The Black Duck configuration '%s' is not valid.", configName);
connectivityWarning(blackDuckProperties, message);
valid = false;
}
BlackDuckApiTokenValidator blackDuckAPITokenValidator = new BlackDuckApiTokenValidator(blackDuckProperties);
if (!blackDuckAPITokenValidator.isApiTokenValid()) {
connectivityWarning(blackDuckProperties, BLACKDUCK_API_PERMISSION_FORMAT);
valid = false;
}
} catch (MalformedURLException | IntegrationException | AlertRuntimeException ex) {
logger.error(" -> Black Duck configuration '{}' is invalid; cause: {}", configName, ex.getMessage());
logger.debug(String.format(" -> Black Duck configuration '%s' Stack Trace: ", configName), ex);
valid = false;
}
return valid;
}
use of com.synopsys.integration.log.Slf4jIntLogger in project hub-alert by blackducksoftware.
the class BlackDuckSSOConfigRetriever method fromProperties.
public static BlackDuckSSOConfigRetriever fromProperties(BlackDuckProperties blackDuckProperties) throws AlertException {
Logger logger = LoggerFactory.getLogger(BlackDuckSSOConfigRetriever.class);
Slf4jIntLogger intLogger = new Slf4jIntLogger(logger);
BlackDuckHttpClient blackDuckHttpClient = blackDuckProperties.createBlackDuckHttpClient(intLogger);
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckProperties.createBlackDuckServicesFactory(blackDuckHttpClient, intLogger);
return new BlackDuckSSOConfigRetriever(blackDuckServicesFactory.getApiDiscovery(), blackDuckServicesFactory.getBlackDuckApiClient());
}
use of com.synopsys.integration.log.Slf4jIntLogger in project hub-alert by blackducksoftware.
the class BlackDuckProjectExistencePopulator method createBlackDuckApiClient.
private BlackDuckApiClient createBlackDuckApiClient(ConfigurationModel providerGlobalConfig) throws AlertException {
StatefulProvider statefulProvider = blackDuckProvider.createStatefulProvider(providerGlobalConfig);
BlackDuckProperties blackDuckProperties = (BlackDuckProperties) statefulProvider.getProperties();
IntLogger intLogger = new Slf4jIntLogger(logger);
BlackDuckHttpClient blackDuckHttpClient = blackDuckProperties.createBlackDuckHttpClient(intLogger);
BlackDuckServicesFactory blackDuckServicesFactory = blackDuckProperties.createBlackDuckServicesFactory(blackDuckHttpClient, intLogger);
return blackDuckServicesFactory.getBlackDuckApiClient();
}
use of com.synopsys.integration.log.Slf4jIntLogger in project hub-alert by blackducksoftware.
the class JiraServerProperties method createJiraServicesServerFactory.
public JiraServerServiceFactory createJiraServicesServerFactory(Logger logger, Gson gson) throws IssueTrackerException {
JiraServerRestConfig jiraServerConfig = createJiraServerConfig();
Slf4jIntLogger intLogger = new Slf4jIntLogger(logger);
JiraHttpClient jiraHttpClient = jiraServerConfig.createJiraHttpClient(intLogger);
return new JiraServerServiceFactory(intLogger, jiraHttpClient, gson);
}
Aggregations