Search in sources :

Example 1 with JiraPreconditionNotMetException

use of com.synopsys.integration.jira.common.exception.JiraPreconditionNotMetException in project hub-alert by blackducksoftware.

the class JiraIssueCreator method createIssueAndExtractDetails.

@Override
protected final ExistingIssueDetails<String> createIssueAndExtractDetails(IssueCreationModel alertIssueCreationModel) throws AlertException {
    MessageReplacementValues replacementValues = alertIssueCreationModel.getSource().map(this::createCustomFieldReplacementValues).orElse(new MessageReplacementValues.Builder(alertIssueCreationModel.getProvider().getLabel(), MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE).build());
    T creationRequest = createIssueCreationRequest(alertIssueCreationModel, replacementValues);
    try {
        IssueCreationResponseModel issueCreationResponseModel = createIssue(creationRequest);
        IssueResponseModel createdIssue = fetchIssue(issueCreationResponseModel.getKey());
        IssueFieldsComponent createdIssueFields = createdIssue.getFields();
        String issueUILink = JiraCallbackUtils.createUILink(createdIssue);
        IssueCategory issueCategory = alertIssueCreationModel.getSource().map(issueCategoryRetriever::retrieveIssueCategoryFromProjectIssueModel).orElse(IssueCategory.BOM);
        return new ExistingIssueDetails<>(createdIssue.getId(), createdIssue.getKey(), createdIssueFields.getSummary(), issueUILink, IssueStatus.RESOLVABLE, issueCategory);
    } catch (IntegrationRestException restException) {
        throw jiraErrorMessageUtility.improveRestException(restException, issueCreatorDescriptorKey, extractReporter(creationRequest));
    } catch (JiraPreconditionNotMetException jiraException) {
        String message = StringUtils.join(FAILED_TO_CREATE_ISSUE_MESSAGE, jiraException.getMessage(), " ");
        throw new AlertException(message, jiraException);
    } catch (IntegrationException intException) {
        throw new AlertException(FAILED_TO_CREATE_ISSUE_MESSAGE, intException);
    }
}
Also used : IntegrationRestException(com.synopsys.integration.rest.exception.IntegrationRestException) IssueCreationResponseModel(com.synopsys.integration.jira.common.model.response.IssueCreationResponseModel) IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) IntegrationException(com.synopsys.integration.exception.IntegrationException) IssueResponseModel(com.synopsys.integration.jira.common.model.response.IssueResponseModel) MessageReplacementValues(com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues) JiraPreconditionNotMetException(com.synopsys.integration.jira.common.exception.JiraPreconditionNotMetException) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) IssueFieldsComponent(com.synopsys.integration.jira.common.model.components.IssueFieldsComponent) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Aggregations

ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)1 IssueCategory (com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory)1 MessageReplacementValues (com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues)1 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 JiraPreconditionNotMetException (com.synopsys.integration.jira.common.exception.JiraPreconditionNotMetException)1 IssueFieldsComponent (com.synopsys.integration.jira.common.model.components.IssueFieldsComponent)1 IssueCreationResponseModel (com.synopsys.integration.jira.common.model.response.IssueCreationResponseModel)1 IssueResponseModel (com.synopsys.integration.jira.common.model.response.IssueResponseModel)1 IntegrationRestException (com.synopsys.integration.rest.exception.IntegrationRestException)1