Search in sources :

Example 21 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class PhoneHomeTask method createPhoneHomeService.

private PhoneHomeService createPhoneHomeService(ExecutorService phoneHomeExecutor) {
    IntLogger intLogger = new Slf4jIntLogger(logger);
    ProxyInfo proxyInfo = proxyManager.createProxyInfoForHost(GoogleAnalyticsConstants.BASE_URL);
    IntHttpClient intHttpClient = new IntHttpClient(intLogger, gson, IntHttpClient.DEFAULT_TIMEOUT, true, proxyInfo);
    PhoneHomeClient phoneHomeClient = BlackDuckPhoneHomeHelper.createPhoneHomeClient(intLogger, intHttpClient.getClientBuilder(), gson);
    return PhoneHomeService.createAsynchronousPhoneHomeService(intLogger, phoneHomeClient, phoneHomeExecutor);
}
Also used : ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) PhoneHomeClient(com.synopsys.integration.phonehome.PhoneHomeClient) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger) IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) IntLogger(com.synopsys.integration.log.IntLogger) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger)

Example 22 with ProxyInfo

use of com.synopsys.integration.rest.proxy.ProxyInfo in project hub-alert by blackducksoftware.

the class ProxyTestService method pingHost.

public ConfigurationTestResult pingHost(String testUrl, SettingsProxyModel settingsProxyModel) {
    ProxyInfo proxyInfo = proxyManager.createProxyInfo(settingsProxyModel);
    IntHttpClient client = createIntHttpClient(proxyInfo);
    try {
        HttpUrl httpUrl = new HttpUrl(testUrl);
        Request testRequest = new Request.Builder(httpUrl).build();
        Response response = client.execute(testRequest);
        if (RestConstants.OK_200 >= response.getStatusCode() && response.getStatusCode() < RestConstants.MULT_CHOICE_300) {
            logger.info("Successfully pinged {}!", testUrl);
            return ConfigurationTestResult.success();
        } else {
            return ConfigurationTestResult.failure(String.format("Could not ping: %s. Status Message: %s. Status code: %s", testUrl, response.getStatusMessage(), response.getStatusCode()));
        }
    } catch (IntegrationException e) {
        logger.error(e.getMessage(), e);
        return ConfigurationTestResult.failure(e.getMessage());
    }
}
Also used : Response(com.synopsys.integration.rest.response.Response) ProxyInfo(com.synopsys.integration.rest.proxy.ProxyInfo) IntegrationException(com.synopsys.integration.exception.IntegrationException) IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) Request(com.synopsys.integration.rest.request.Request) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Aggregations

ProxyInfo (com.synopsys.integration.rest.proxy.ProxyInfo)22 Test (org.junit.jupiter.api.Test)9 IntHttpClient (com.synopsys.integration.rest.client.IntHttpClient)5 AzureBoardsProperties (com.synopsys.integration.alert.channel.azure.boards.AzureBoardsProperties)3 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)3 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)2 AzureApiVersionAppender (com.synopsys.integration.azure.boards.common.http.AzureApiVersionAppender)2 AzureHttpRequestCreator (com.synopsys.integration.azure.boards.common.http.AzureHttpRequestCreator)2 AzureHttpService (com.synopsys.integration.azure.boards.common.http.AzureHttpService)2 AzureWorkItemCommentService (com.synopsys.integration.azure.boards.common.service.comment.AzureWorkItemCommentService)2 AzureWorkItemTypeStateService (com.synopsys.integration.azure.boards.common.service.state.AzureWorkItemTypeStateService)2 AzureWorkItemService (com.synopsys.integration.azure.boards.common.service.workitem.AzureWorkItemService)2 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)2 IntLogger (com.synopsys.integration.log.IntLogger)2 Credentials (com.synopsys.integration.rest.credentials.Credentials)2 CredentialsBuilder (com.synopsys.integration.rest.credentials.CredentialsBuilder)2 ProxyInfoBuilder (com.synopsys.integration.rest.proxy.ProxyInfoBuilder)2 IssueTrackerModelExtractor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor)1 IssueTrackerProcessor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor)1 IssueTrackerSearcher (com.synopsys.integration.alert.api.channel.issue.search.IssueTrackerSearcher)1