Search in sources :

Example 21 with RestConnection

use of com.blackducksoftware.integration.hub.rest.RestConnection in project hub-docker-inspector by blackducksoftware.

the class HubClient method phoneHomeHubConnection.

private void phoneHomeHubConnection(final String dockerEngineVersion) throws IOException, EncryptionException {
    final RestConnection restConnection = createRestConnection();
    final HubServicesFactory hubServicesFactory = new HubServicesFactory(restConnection);
    final PhoneHomeService phoner = hubServicesFactory.createPhoneHomeService();
    final PhoneHomeRequestBodyBuilder phoneHomeRequestBodyBuilder = phoner.createInitialPhoneHomeRequestBodyBuilder(THIRD_PARTY_NAME_DOCKER, dockerEngineVersion, programVersion.getProgramVersion());
    phoneHomeRequestBodyBuilder.setBlackDuckName(BlackDuckName.HUB);
    if (!StringUtils.isBlank(config.getCallerName())) {
        phoneHomeRequestBodyBuilder.addToMetaDataMap(PHONE_HOME_METADATA_NAME_CALLER_NAME, config.getCallerName());
    }
    if (!StringUtils.isBlank(config.getCallerVersion())) {
        phoneHomeRequestBodyBuilder.addToMetaDataMap(PHONE_HOME_METADATA_NAME_CALLER_VERSION, config.getCallerVersion());
    }
    final PhoneHomeRequestBody phoneHomeRequestBody = phoneHomeRequestBodyBuilder.buildObject();
    phoner.phoneHome(phoneHomeRequestBody);
    logger.trace("Attempt to phone home completed");
}
Also used : PhoneHomeRequestBody(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBody) PhoneHomeRequestBodyBuilder(com.blackducksoftware.integration.phonehome.PhoneHomeRequestBodyBuilder) RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory) PhoneHomeService(com.blackducksoftware.integration.hub.service.PhoneHomeService)

Example 22 with RestConnection

use of com.blackducksoftware.integration.hub.rest.RestConnection in project hub-docker-inspector by blackducksoftware.

the class HubClient method testHubConnection.

public void testHubConnection() throws HubIntegrationException {
    // ArgsWithSpacesTest tests this in output
    logger.trace(String.format("Hub username: %s", getHubUsername()));
    if (!config.isUploadBdio()) {
        logger.debug("Upload of BDIO not enabled; skipping verification of Hub connection");
        return;
    }
    RestConnection restConnection;
    try {
        restConnection = createRestConnection();
        restConnection.connect();
    } catch (final IntegrationException e) {
        final String msg = String.format("Error connecting to Hub: %s", e.getMessage());
        throw new HubIntegrationException(msg);
    }
    logger.info("Successful connection to the Hub.");
}
Also used : RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) HubIntegrationException(com.blackducksoftware.integration.hub.exception.HubIntegrationException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) HubIntegrationException(com.blackducksoftware.integration.hub.exception.HubIntegrationException)

Example 23 with RestConnection

use of com.blackducksoftware.integration.hub.rest.RestConnection in project hub-docker-inspector by blackducksoftware.

the class ImageInspectorClient method createConnection.

private RestConnection createConnection(final String baseUrl, final int timeoutSeconds) throws MalformedURLException {
    final UnauthenticatedRestConnectionBuilder connectionBuilder = new UnauthenticatedRestConnectionBuilder();
    connectionBuilder.setBaseUrl(baseUrl);
    connectionBuilder.setTimeout(timeoutSeconds);
    final IntLogger intLogger = new Slf4jIntLogger(logger);
    connectionBuilder.setLogger(intLogger);
    connectionBuilder.setAlwaysTrustServerCertificate(false);
    final RestConnection connection = connectionBuilder.build();
    return connection;
}
Also used : RestConnection(com.blackducksoftware.integration.hub.rest.RestConnection) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger) UnauthenticatedRestConnectionBuilder(com.blackducksoftware.integration.hub.rest.UnauthenticatedRestConnectionBuilder) IntLogger(com.blackducksoftware.integration.log.IntLogger) Slf4jIntLogger(com.blackducksoftware.integration.log.Slf4jIntLogger)

Aggregations

RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)23 Test (org.junit.Test)10 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)9 HubServerConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubServerConfigBuilder)6 Request (com.blackducksoftware.integration.hub.request.Request)6 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)5 HubServerConfig (com.blackducksoftware.integration.hub.configuration.HubServerConfig)4 UnauthenticatedRestConnectionBuilder (com.blackducksoftware.integration.hub.rest.UnauthenticatedRestConnectionBuilder)4 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)4 ChannelRestConnectionFactory (com.blackducksoftware.integration.hub.alert.channel.rest.ChannelRestConnectionFactory)3 GlobalHubConfigActions (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigActions)3 GlobalActionsTest (com.blackducksoftware.integration.hub.alert.web.actions.global.GlobalActionsTest)3 Slf4jIntLogger (com.blackducksoftware.integration.log.Slf4jIntLogger)3 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)2 GlobalHubConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalHubConfigEntity)2 GlobalHubRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.global.GlobalHubRepositoryWrapper)2 GlobalHubConfigRestModel (com.blackducksoftware.integration.hub.alert.hub.controller.global.GlobalHubConfigRestModel)2 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)2 LoginRestModel (com.blackducksoftware.integration.hub.alert.web.model.LoginRestModel)2 ProxyInfo (com.blackducksoftware.integration.hub.proxy.ProxyInfo)2