本文整理汇总了Java中com.blackducksoftware.integration.hub.global.HubServerConfig类的典型用法代码示例。如果您正苦于以下问题:Java HubServerConfig类的具体用法?Java HubServerConfig怎么用?Java HubServerConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HubServerConfig类属于com.blackducksoftware.integration.hub.global包,在下文中一共展示了HubServerConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getHubServerConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
/**
* Build the Hub Server information for connection
*
* @return
*/
private static HubServerConfig getHubServerConfig(PropertyConstants propertyConstants) {
HubServerConfigBuilder builder = new HubServerConfigBuilder();
builder.setHubUrl(propertyConstants.getHubServerUrl());
builder.setUsername(propertyConstants.getHubUserName());
builder.setPassword(propertyConstants.getHubPassword());
builder.setTimeout(propertyConstants.getHubTimeout());
if (propertyConstants.getHubProxyHost() != null && !"".equalsIgnoreCase(propertyConstants.getHubProxyHost())) {
logger.info("Inside Proxy settings::" + propertyConstants.getHubProxyHost() + "::");
builder.setProxyHost(propertyConstants.getHubProxyHost());
builder.setProxyPort(propertyConstants.getHubProxyPort());
builder.setProxyUsername(propertyConstants.getHubProxyUser());
builder.setProxyPassword(propertyConstants.getHubPassword());
builder.setIgnoredProxyHosts(propertyConstants.getHubProxyNoHost());
}
return builder.build();
}
开发者ID:blackducksoftware,项目名称:hub-fortify-ssc-integration-service,代码行数:24,代码来源:RestConnectionHelper.java
示例2: persist
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public void persist() throws IOException {
if (!configFile.getParentFile().exists() && configFile.getParentFile().mkdirs()) {
Loggers.SERVER.info("Directory created for the Hub configuration file at : " + configFile.getParentFile().getCanonicalPath());
} else if (configFile.exists() && configFile.delete()) {
Loggers.SERVER.info("Old Hub configuration file removed, to be replaced by a new configuration.");
}
configFile.createNewFile();
final JsonObject globalConfigJson = new JsonObject();
final JsonElement hubServerConfigJson = gson.toJsonTree(getHubServerConfig(), HubServerConfig.class);
globalConfigJson.add("hubServerConfig", hubServerConfigJson);
globalConfigJson.addProperty("hubWorkspaceCheck", hubWorkspaceCheck);
try (BufferedWriter writer = new BufferedWriter(new FileWriter(configFile))) {
writer.write(gson.toJson(globalConfigJson));
} catch (final IOException e) {
Loggers.SERVER.error("Failed to save Hub config file: " + configFile, e);
}
}
开发者ID:blackducksoftware,项目名称:hub-teamcity,代码行数:20,代码来源:ServerHubConfigPersistenceManager.java
示例3: checkInput
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public void checkInput(final HttpServletRequest request, final ActionErrors errors) throws IllegalArgumentException, EncryptionException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final HubServerConfigBuilder builder = getHubServerConfigBuilderFromRequest(request);
final AbstractValidator validator = builder.createValidator();
final ValidationResults results = validator.assertValid();
if (results.isSuccess()) {
final HubServerConfig config = builder.buildObject();
configPersistenceManager.setHubServerConfig(config);
configPersistenceManager.setHubWorkspaceCheck(Boolean.valueOf(request.getParameter("hubWorkspaceCheck")));
} else {
checkForErrors(HubServerConfigFieldEnum.HUBURL, "errorUrl", results, errors);
checkForErrors(HubServerConfigFieldEnum.HUBTIMEOUT, "errorTimeout", results, errors);
checkForErrors(HubCredentialsFieldEnum.USERNAME, "errorUserName", results, errors);
checkForErrors(HubCredentialsFieldEnum.PASSWORD, "errorPassword", results, errors);
checkForErrors(HubProxyInfoFieldEnum.PROXYHOST, "errorHubProxyServer", results, errors);
checkForErrors(HubProxyInfoFieldEnum.PROXYPORT, "errorHubProxyPort", results, errors);
checkForErrors(HubProxyInfoFieldEnum.NOPROXYHOSTS, "errorHubNoProxyHost", results, errors);
checkForErrors(HubProxyInfoFieldEnum.PROXYUSERNAME, "errorHubProxyUser", results, errors);
checkForErrors(HubProxyInfoFieldEnum.PROXYPASSWORD, "errorHubProxyPass", results, errors);
}
}
开发者ID:blackducksoftware,项目名称:hub-teamcity,代码行数:25,代码来源:HubGlobalServerConfigController.java
示例4: getHubServerConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
private HubServerConfig getHubServerConfig(final IntLogger logger) {
try {
final String hubUrl = getPersistedValue(HubConfigKeys.CONFIG_HUB_URL);
final String hubUser = getPersistedValue(HubConfigKeys.CONFIG_HUB_USER);
final String hubPass = getPersistedValue(HubConfigKeys.CONFIG_HUB_PASS);
final String hubPassLength = getPersistedValue(HubConfigKeys.CONFIG_HUB_PASS_LENGTH);
final String hubImportSSLCerts = getPersistedValue(HubConfigKeys.CONFIG_HUB_IMPORT_SSL_CERTIFICATES);
final String hubProxyUrl = getPersistedValue(HubConfigKeys.CONFIG_PROXY_HOST);
final String hubProxyPort = getPersistedValue(HubConfigKeys.CONFIG_PROXY_PORT);
final String hubProxyNoHost = getPersistedValue(HubConfigKeys.CONFIG_PROXY_NO_HOST);
final String hubProxyUser = getPersistedValue(HubConfigKeys.CONFIG_PROXY_USER);
final String hubProxyPass = getPersistedValue(HubConfigKeys.CONFIG_PROXY_PASS);
final String hubProxyPassLength = getPersistedValue(HubConfigKeys.CONFIG_PROXY_PASS_LENGTH);
final HubServerConfig result = HubBambooUtils.getInstance().buildConfigFromStrings(hubUrl, hubUser, hubPass, hubPassLength, hubImportSSLCerts, hubProxyUrl, hubProxyPort, hubProxyNoHost, hubProxyUser, hubProxyPass,
hubProxyPassLength);
return result;
} catch (final IllegalStateException e) {
logger.error(e.getMessage());
logger.debug("", e);
}
return null;
}
开发者ID:blackducksoftware,项目名称:hub-bamboo,代码行数:24,代码来源:HubScanTask.java
示例5: createHubConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public HubServerConfig createHubConfig(final String hubUri) {
try {
final HubServerConfigBuilder configBuilder = new HubServerConfigBuilder();
configBuilder.setHubUrl(hubUri);
// using oauth the username and password aren't used but need to be set
// for the builder
configBuilder.setUsername("auser");
configBuilder.setPassword("apassword");
configBuilder.setTimeout(extensionProperties.getHubServerTimeout());
configBuilder.setProxyHost(extensionProperties.getHubProxyHost());
configBuilder.setProxyPort(extensionProperties.getHubProxyPort());
configBuilder.setIgnoredProxyHosts(extensionProperties.getHubProxyNoHost());
configBuilder.setProxyUsername(extensionProperties.getHubProxyUser());
configBuilder.setProxyPassword(extensionProperties.getHubProxyPassword());
configBuilder.setAlwaysTrustServerCertificate(alwaysTrustServerCertificate);
final HubServerConfig config = configBuilder.build();
// output the configuration details
logger.info("Hub Server URL = " + config.getHubUrl());
logger.info("Hub Timeout = " + config.getTimeout());
return config;
} catch (final IllegalStateException ex) {
logger.error("Error with the hub configuration", ex);
}
return null;
}
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:29,代码来源:EmailEngine.java
示例6: buildConfigFromStrings
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public HubServerConfig buildConfigFromStrings(final String hubUrl,
final String hubUser, final String hubPass, final String hubPassLength,
final String hubImportSSLCerts, final String hubProxyUrl,
final String hubProxyPort, final String hubProxyNoHost, final String hubProxyUser,
final String hubProxyPass, final String hubProxyPassLength) {
final HubServerConfigBuilder configBuilder = new HubServerConfigBuilder();
configBuilder.setHubUrl(hubUrl);
configBuilder.setUsername(hubUser);
configBuilder.setPassword(hubPass);
configBuilder.setProxyHost(hubProxyUrl);
configBuilder.setProxyPort(hubProxyPort);
configBuilder.setProxyUsername(hubProxyUser);
configBuilder.setIgnoredProxyHosts(hubProxyNoHost);
int length = 0;
if (StringUtils.isNotBlank(hubPassLength)) {
length = Integer.valueOf(hubPassLength);
configBuilder.setPasswordLength(length);
}
if (StringUtils.isNotBlank(hubProxyUser)) {
configBuilder.setProxyPassword(hubProxyPass);
if (StringUtils.isNotBlank(hubProxyPassLength)) {
length = Integer.valueOf(hubProxyPassLength);
configBuilder.setProxyPasswordLength(length);
}
}
if (StringUtils.isNotBlank(hubImportSSLCerts)) {
configBuilder.setAutoImportHttpsCertificates(Boolean.valueOf(hubImportSSLCerts));
}
return configBuilder.build();
}
开发者ID:blackducksoftware,项目名称:hub-bamboo,代码行数:35,代码来源:HubBambooUtils.java
示例7: call
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
@Override
public Boolean call() throws Exception {
try {
logger.debug(String.format("ISSUE TRACKER TASK STARTED: Event Type ID: %s, Issue: %s", eventTypeID, jiraIssue));
final PluginConfigurationDetails configDetails = new PluginConfigurationDetails(settings);
final JiraSettingsService jiraSettingsService = new JiraSettingsService(settings);
// only execute if hub 3.7 or higher with the issue tracker
// capability
final HubServerConfig hubServerConfig = createHubServerConfig(configDetails);
if (hubServerConfig == null) {
logger.error("Hub Server Configuration is invalid. Cannot update Hub issue tracking data.");
} else {
final HubServicesFactory servicesFactory = createHubServicesFactory(hubServerConfig);
final HubSupportHelper hubSupportHelper = new HubSupportHelper();
final HubVersionRequestService hubVersionRequestService = servicesFactory.createHubVersionRequestService();
hubSupportHelper.checkHubSupport(hubVersionRequestService, null);
if (hubSupportHelper.hasCapability(HubCapabilitiesEnum.ISSUE_TRACKER)) {
final JiraContext jiraContext = initJiraContext(configDetails.getJiraAdminUserName(), configDetails.getJiraIssueCreatorUserName());
final HubJiraConfigSerializable config = createJiraConfig(configDetails);
if (config == null) {
logger.debug("No Hub Jira configuration set");
return Boolean.FALSE;
}
final HubIssueTrackerHandler hubIssueHandler = new HubIssueTrackerHandler(jiraServices, jiraSettingsService, servicesFactory.createBomComponentIssueRequestService());
handleIssue(jiraContext, eventTypeID, jiraIssue, hubIssueHandler, property, propertyKey);
}
}
} catch (final Throwable throwable) {
logger.error(String.format("Error occurred processing issue %s, caused by %s", jiraIssue, throwable));
return Boolean.FALSE;
} finally {
logger.debug(String.format("ISSUE TRACKER TASK FINISHED: Event Type ID: %s, Issue: %s", eventTypeID, jiraIssue));
}
return Boolean.TRUE;
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:41,代码来源:IssueTrackerTask.java
示例8: createHubServerConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public HubServerConfig createHubServerConfig(final PluginConfigurationDetails configDetails) {
final HubServerConfigBuilder hubConfigBuilder = configDetails.createHubServerConfigBuilder();
HubServerConfig hubServerConfig = null;
if (configDetails.getProjectMappingJson() == null) {
logger.debug("HubNotificationCheckTask: Project Mappings not configured, therefore there is nothing to do.");
return null;
}
if (configDetails.getPolicyRulesJson() == null) {
logger.debug("HubNotificationCheckTask: Policy Rules not configured, therefore there is nothing to do.");
return null;
}
try {
logger.debug("Building Hub configuration");
hubServerConfig = hubConfigBuilder.build();
logger.debug("Finished building Hub configuration");
} catch (final IllegalStateException e) {
logger.error(
"Unable to connect to the Hub. This could mean the Hub is currently unreachable, or that at least one of the Black Duck plugins (either the Hub Admin plugin or the Hub JIRA plugin) is not (yet) configured correctly: "
+ e.getMessage());
return null;
}
logger.debug("Last run date: " + configDetails.getLastRunDateString());
logger.debug("Hub url / username: " + hubServerConfig.getHubUrl().toString() + " / " + hubServerConfig.getGlobalCredentials().getUsername());
logger.debug("Interval: " + configDetails.getIntervalString());
return hubServerConfig;
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:31,代码来源:IssueTrackerTask.java
示例9: createHubServicesFactory
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
private HubServicesFactory createHubServicesFactory(final HubServerConfig hubServerConfig) throws EncryptionException {
final RestConnection restConnection = new CredentialsRestConnection(logger, hubServerConfig.getHubUrl(),
hubServerConfig.getGlobalCredentials().getUsername(), hubServerConfig.getGlobalCredentials().getDecryptedPassword(),
hubServerConfig.getTimeout());
final HubServicesFactory hubServicesFactory = new HubServicesFactory(restConnection);
return hubServicesFactory;
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:8,代码来源:HubJiraTask.java
示例10: deSerializeConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
private HubJiraConfigSerializable deSerializeConfig(final HubServerConfig hubServerConfig) {
if (pluginConfigDetails.getProjectMappingJson() == null) {
logger.debug(
"HubNotificationCheckTask: Project Mappings not configured, therefore there is nothing to do.");
return null;
}
if (pluginConfigDetails.getPolicyRulesJson() == null) {
logger.debug("HubNotificationCheckTask: Policy Rules not configured, therefore there is nothing to do.");
return null;
}
logger.debug("Last run date: " + pluginConfigDetails.getLastRunDateString());
logger.debug("Hub url / username: " + hubServerConfig.getHubUrl().toString() + " / "
+ hubServerConfig.getGlobalCredentials().getUsername());
logger.debug("Interval: " + pluginConfigDetails.getIntervalString());
final HubJiraConfigSerializable config = new HubJiraConfigSerializable();
config.setHubProjectMappingsJson(pluginConfigDetails.getProjectMappingJson());
config.setPolicyRulesJson(pluginConfigDetails.getPolicyRulesJson());
logger.debug("Mappings:");
for (final HubProjectMapping mapping : config.getHubProjectMappings()) {
logger.debug(mapping.toString());
}
logger.debug("Policy Rules:");
for (final PolicyRuleSerializable rule : config.getPolicyRules()) {
logger.debug(rule.toString());
}
return config;
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:31,代码来源:HubJiraTask.java
示例11: getHubServerConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public HubServerConfig getHubServerConfig() {
return hubServerConfig;
}
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:4,代码来源:EmailEngine.java
示例12: getRestConnection
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public RestConnection getRestConnection(final IntLogger logger, final HubServerConfig hubServerConfig) throws EncryptionException {
return hubServerConfig.createCredentialsRestConnection(logger);
}
开发者ID:blackducksoftware,项目名称:hub-teamcity,代码行数:4,代码来源:HubBuildProcess.java
示例13: getHubServerConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
private HubServerConfig getHubServerConfig(final IntLogger logger, final CIEnvironmentVariables commonVariables) {
final HubServerConfigBuilder configBuilder = new HubServerConfigBuilder();
// read the credentials and proxy info using the existing objects.
final String serverUrl = commonVariables.getValue(HubConstantValues.HUB_URL);
final String timeout = commonVariables.getValue(HubConstantValues.HUB_CONNECTION_TIMEOUT);
final String username = commonVariables.getValue(HubConstantValues.HUB_USERNAME);
final String password = commonVariables.getValue(HubConstantValues.HUB_PASSWORD);
final String passwordLength = commonVariables.getValue(HubConstantValues.HUB_PASSWORD_LENGTH);
final String autoImportHttpsCertificates = commonVariables.getValue(HubConstantValues.HUB_IMPORT_SSL_CERT);
final String proxyHost = commonVariables.getValue(HubConstantValues.HUB_PROXY_HOST);
final String proxyPort = commonVariables.getValue(HubConstantValues.HUB_PROXY_PORT);
final String ignoredProxyHosts = commonVariables.getValue(HubConstantValues.HUB_NO_PROXY_HOSTS);
final String proxyUsername = commonVariables.getValue(HubConstantValues.HUB_PROXY_USER);
final String proxyPassword = commonVariables.getValue(HubConstantValues.HUB_PROXY_PASS);
final String proxyPasswordLength = commonVariables.getValue(HubConstantValues.HUB_PROXY_PASS_LENGTH);
configBuilder.setHubUrl(serverUrl);
configBuilder.setUsername(username);
configBuilder.setPassword(password);
configBuilder.setPasswordLength(NumberUtils.toInt(passwordLength));
configBuilder.setTimeout(timeout);
configBuilder.setAutoImportHttpsCertificates(Boolean.valueOf(autoImportHttpsCertificates));
configBuilder.setProxyHost(proxyHost);
configBuilder.setProxyPort(proxyPort);
configBuilder.setIgnoredProxyHosts(ignoredProxyHosts);
configBuilder.setProxyUsername(proxyUsername);
configBuilder.setProxyPassword(proxyPassword);
configBuilder.setProxyPasswordLength(NumberUtils.toInt(proxyPasswordLength));
try {
return configBuilder.build();
} catch (final IllegalStateException e) {
logger.error(e.getMessage(), e);
}
return null;
}
开发者ID:blackducksoftware,项目名称:hub-teamcity,代码行数:42,代码来源:HubBuildProcess.java
示例14: setHubServerConfig
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public void setHubServerConfig(final HubServerConfig hubServerConfig) {
this.hubServerConfig = hubServerConfig;
}
开发者ID:blackducksoftware,项目名称:hub-teamcity,代码行数:4,代码来源:ServerHubConfigPersistenceManager.java
示例15: addGlobalParameterMap
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
private void addGlobalParameterMap(final Map<String, String> runParameters) {
final HubServerConfig hubServerConfig = serverPeristanceManager.getHubServerConfig();
if (!runParameters.containsKey(HubConstantValues.HUB_URL)) {
runParameters.put(HubConstantValues.HUB_URL, StringUtils.trimToEmpty(hubServerConfig.getHubUrl().toString()));
}
if (!runParameters.containsKey(HubConstantValues.HUB_USERNAME)) {
runParameters.put(HubConstantValues.HUB_USERNAME, StringUtils.trimToEmpty(hubServerConfig.getGlobalCredentials().getUsername()));
}
if (!runParameters.containsKey(HubConstantValues.HUB_PASSWORD)) {
runParameters.put(HubConstantValues.HUB_PASSWORD, StringUtils.trimToEmpty(hubServerConfig.getGlobalCredentials().getEncryptedPassword()));
}
if (!runParameters.containsKey(HubConstantValues.HUB_PASSWORD_LENGTH)) {
runParameters.put(HubConstantValues.HUB_PASSWORD_LENGTH, Integer.toString(hubServerConfig.getGlobalCredentials().getActualPasswordLength()));
}
if (!runParameters.containsKey(HubConstantValues.HUB_CONNECTION_TIMEOUT)) {
runParameters.put(HubConstantValues.HUB_CONNECTION_TIMEOUT, String.valueOf(hubServerConfig.getTimeout()));
}
if (!runParameters.containsKey(HubConstantValues.HUB_IMPORT_SSL_CERT)) {
runParameters.put(HubConstantValues.HUB_IMPORT_SSL_CERT, String.valueOf(hubServerConfig.isAutoImportHttpsCertificates()));
}
if (!runParameters.containsKey(HubConstantValues.HUB_WORKSPACE_CHECK)) {
runParameters.put(HubConstantValues.HUB_WORKSPACE_CHECK, String.valueOf(serverPeristanceManager.isHubWorkspaceCheck()));
}
final String ignoredProxyHosts = hubServerConfig.getProxyInfo().getIgnoredProxyHosts();
if (!runParameters.containsKey(HubConstantValues.HUB_NO_PROXY_HOSTS) && StringUtils.isNotBlank(ignoredProxyHosts)) {
runParameters.put(HubConstantValues.HUB_NO_PROXY_HOSTS, StringUtils.trimToEmpty(ignoredProxyHosts));
}
final String proxyHost = hubServerConfig.getProxyInfo().getHost();
final int proxyPort = hubServerConfig.getProxyInfo().getPort();
final String proxyUsername = hubServerConfig.getProxyInfo().getUsername();
final String proxyPassword = hubServerConfig.getProxyInfo().getEncryptedPassword();
final String proxyPasswordLength = Integer.toString(hubServerConfig.getProxyInfo().getActualPasswordLength());
if (StringUtils.isNotBlank(proxyHost) && proxyPort > 0) {
if (!runParameters.containsKey(HubConstantValues.HUB_PROXY_HOST)) {
runParameters.put(HubConstantValues.HUB_PROXY_HOST, StringUtils.trimToEmpty(proxyHost));
}
if (!runParameters.containsKey(HubConstantValues.HUB_PROXY_PORT)) {
runParameters.put(HubConstantValues.HUB_PROXY_PORT, String.valueOf(proxyPort));
}
if (StringUtils.isNotBlank(proxyUsername) && StringUtils.isNotBlank(proxyPassword)) {
if (!runParameters.containsKey(HubConstantValues.HUB_PROXY_USER)) {
runParameters.put(HubConstantValues.HUB_PROXY_USER, StringUtils.trimToEmpty(proxyUsername));
}
if (!runParameters.containsKey(HubConstantValues.HUB_PROXY_PASS)) {
runParameters.put(HubConstantValues.HUB_PROXY_PASS, StringUtils.trimToEmpty(proxyPassword));
}
if (!runParameters.containsKey(HubConstantValues.HUB_PROXY_PASS_LENGTH)) {
runParameters.put(HubConstantValues.HUB_PROXY_PASS_LENGTH, proxyPasswordLength);
}
}
}
}
开发者ID:blackducksoftware,项目名称:hub-teamcity,代码行数:57,代码来源:HubParametersPreprocessor.java
示例16: getRestConnection
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
private RestConnection getRestConnection(final HubServerConfig hubServerConfig) throws EncryptionException {
final Slf4jIntLogger intLogger = new Slf4jIntLogger(logger);
return hubServerConfig.createCredentialsRestConnection(intLogger);
}
开发者ID:blackducksoftware,项目名称:hub-maven-plugin,代码行数:5,代码来源:BuildBOMGoal.java
示例17: testConnection
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
@Path("/testConnection")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public Response testConnection(final HubServerConfigSerializable config,
@Context final HttpServletRequest request) {
try {
final PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
final Response response = checkUserPermissions(request, settings);
if (response != null) {
return response;
}
transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction() {
final HubServerConfigBuilder serverConfigBuilder = setConfigBuilderFromSerializableConfig(config,
settings);
setConfigFromResult(config, serverConfigBuilder.createValidator());
if (config.hasErrors()) {
return config;
} else {
final HubServerConfig serverConfig = serverConfigBuilder.build();
try {
final CredentialsRestConnection restConnection = new CredentialsRestConnection(logger, serverConfig.getHubUrl(),
serverConfig.getGlobalCredentials().getUsername(),
serverConfig.getGlobalCredentials().getDecryptedPassword(),
serverConfig.getTimeout());
restConnection.connect();
} catch (final IntegrationException e) {
if (e.getMessage().toLowerCase().contains("unauthorized")) {
config.setUsernameError(
"Username and Password are invalid for : " + serverConfig.getHubUrl());
} else {
config.setTestConnectionError(e.toString());
}
}
return config;
}
}
});
if (config.hasErrors()) {
return Response.ok(config).status(Status.BAD_REQUEST).build();
}
return Response.noContent().build();
} catch (final Throwable t) {
final StringBuilder sb = new StringBuilder();
sb.append("Unexpected exception caught in testConnection(): ");
sb.append(t.getMessage());
if (t.getCause() != null) {
sb.append("; Caused by: ");
sb.append(t.getCause().getMessage());
}
config.setHubUrlError(sb.toString());
return Response.ok(config).status(Status.BAD_REQUEST).build();
}
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:62,代码来源:HubConfigController.java
示例18: createHubServicesFactory
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
public HubServicesFactory createHubServicesFactory(final HubServerConfig config) throws EncryptionException {
final RestConnection restConnection = new CredentialsRestConnection(logger, config.getHubUrl(), config.getGlobalCredentials().getUsername(), config.getGlobalCredentials().getDecryptedPassword(), config.getTimeout());
return new HubServicesFactory(restConnection);
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:5,代码来源:IssueTrackerTask.java
示例19: build
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
@Override
public HubServerConfig build() throws IllegalStateException {
return super.buildObject();
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:5,代码来源:HubServerConfigBuilderMock.java
示例20: createHubServicesFactory
import com.blackducksoftware.integration.hub.global.HubServerConfig; //导入依赖的package包/类
@Override
public HubServicesFactory createHubServicesFactory(final HubServerConfig config) throws EncryptionException {
return hubServicesFactory;
}
开发者ID:blackducksoftware,项目名称:hub-jira,代码行数:5,代码来源:IssueTrackerTaskWithMocks.java
注:本文中的com.blackducksoftware.integration.hub.global.HubServerConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论