use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class JiraIssueCommenter method addComment.
@Override
protected final void addComment(String comment, ExistingIssueDetails<String> existingIssueDetails, @Nullable ProjectIssueModel source) throws AlertException {
try {
IssueCommentRequestModel issueCommentRequestModel = new IssueCommentRequestModel(existingIssueDetails.getIssueKey(), comment);
addComment(issueCommentRequestModel);
} catch (IntegrationException e) {
throw new AlertException(String.format("Failed to add a comment in Jira. Issue Key: %s", existingIssueDetails.getIssueKey()), e);
}
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class RestChannelUtility method createPostMessageRequest.
public Request createPostMessageRequest(String url, Map<String, String> headers, @Nullable Map<String, Set<String>> queryParameters, String jsonString) {
HttpUrl httpUrl;
try {
httpUrl = new HttpUrl(url);
} catch (IntegrationException e) {
throw new AlertRuntimeException(e);
}
Request.Builder requestBuilder = new Request.Builder().method(HttpMethod.POST).url(httpUrl);
requestBuilder.getHeaders().putAll(headers);
requestBuilder.bodyContent(new StringBodyContent(jsonString, BodyContentConverter.DEFAULT));
if (queryParameters != null && !queryParameters.isEmpty()) {
requestBuilder.queryParameters(queryParameters);
}
return requestBuilder.build();
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class JiraGlobalFieldModelTestActionTest method testConfigExceptionTest.
@Test
public void testConfigExceptionTest() throws IntegrationException {
String exceptionMessage = "fake exception message";
Mockito.doThrow(new IntegrationException(exceptionMessage)).when(testAction).canUserGetIssues(Mockito.any());
try {
testAction.testConfig("0", null, null);
fail(EXPECTED_EXCEPTION);
} catch (IntegrationException e) {
assertTrue(e.getMessage().contains(exceptionMessage));
}
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method createProviderProject.
private ProviderProject createProviderProject(ProjectView projectView, BlackDuckApiClient blackDuckService) {
String projectOwnerEmail = null;
if (StringUtils.isNotBlank(projectView.getProjectOwner())) {
try {
HttpUrl projectOwnerHttpUrl = new HttpUrl(projectView.getProjectOwner());
UserView projectOwner = blackDuckService.getResponse(projectOwnerHttpUrl, UserView.class);
projectOwnerEmail = projectOwner.getEmail();
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectOwnerNotFoundString(projectView.getName(), e.getMessage()), e);
}
}
String truncatedDescription = truncateDescription(projectView.getDescription());
return new ProviderProject(projectView.getName(), truncatedDescription, projectView.getMeta().getHref().toString(), projectOwnerEmail);
}
use of com.synopsys.integration.exception.IntegrationException in project hub-alert by blackducksoftware.
the class BlackDuckProviderDataAccessor method findFirstUserByEmailAddress.
@Override
public Optional<ProviderUserModel> findFirstUserByEmailAddress(Long providerConfigId, String emailAddress) {
Optional<ConfigurationModel> providerConfigOptional = configurationModelConfigurationAccessor.getConfigurationById(providerConfigId);
if (providerConfigOptional.isPresent()) {
try {
BlackDuckServicesFactory blackDuckServicesFactory = createBlackDuckServicesFactory(providerConfigOptional.get());
UserService userService = blackDuckServicesFactory.createUserService();
return userService.findUsersByEmail(emailAddress, new BlackDuckPageDefinition(1, 0)).getItems().stream().map(userView -> new ProviderUserModel(userView.getEmail(), false)).findFirst();
} catch (IntegrationException e) {
logger.errorAndDebug(createProjectNotFoundString(providerConfigId, e.getMessage()), e);
}
}
return Optional.empty();
}
Aggregations