Search in sources :

Example 6 with JiraServerProperties

use of com.synopsys.integration.alert.channel.jira.server.JiraServerProperties in project hub-alert by blackducksoftware.

the class JiraServerCustomFunctionAction method createActionResponse.

@Override
public ActionResponse<String> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper ignoredServletContent) {
    try {
        JiraServerProperties jiraProperties = jiraServerPropertiesFactory.createJiraPropertiesWithJobId(UUID.fromString(fieldModel.getId()));
        JiraServerServiceFactory jiraServicesFactory = jiraProperties.createJiraServicesServerFactory(logger, gson);
        PluginManagerService jiraAppService = jiraServicesFactory.createPluginManagerService();
        try {
            jiraAppService.installMarketplaceServerApp(JiraConstants.JIRA_APP_KEY);
        } catch (IntegrationRestException e) {
            if (RestConstants.NOT_FOUND_404 == e.getHttpStatusCode()) {
                return new ActionResponse<>(HttpStatus.NOT_FOUND, String.format("The marketplace listing of the '%s' app may not support your version of Jira. Please install the app manually or request a compatibility update. Error: %s", JiraConstants.JIRA_ALERT_APP_NAME, e.getMessage()));
            }
            return createBadRequestIntegrationException(e);
        }
        boolean jiraPluginInstalled = JiraPluginCheckUtils.checkIsAppInstalledAndRetryIfNecessary(jiraAppService);
        if (!jiraPluginInstalled) {
            return new ActionResponse<>(HttpStatus.NOT_FOUND, String.format("Unable to confirm Jira server successfully installed the '%s' plugin. Please verify the installation on you Jira server.", JiraConstants.JIRA_ALERT_APP_NAME));
        }
        return new ActionResponse<>(HttpStatus.OK, String.format("Successfully installed the '%s' plugin on Jira server.", JiraConstants.JIRA_ALERT_APP_NAME));
    } catch (IntegrationException e) {
        return createBadRequestIntegrationException(e);
    } catch (InterruptedException e) {
        logger.error("Thread was interrupted while validating Jira plugin installation.", e);
        Thread.currentThread().interrupt();
        return new ActionResponse<>(HttpStatus.INTERNAL_SERVER_ERROR, String.format("Thread was interrupted while validating Jira '%s' plugin installation: %s", JiraConstants.JIRA_ALERT_APP_NAME, e.getMessage()));
    }
}
Also used : PluginManagerService(com.synopsys.integration.jira.common.rest.service.PluginManagerService) IntegrationRestException(com.synopsys.integration.rest.exception.IntegrationRestException) JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) IntegrationException(com.synopsys.integration.exception.IntegrationException) JiraServerProperties(com.synopsys.integration.alert.channel.jira.server.JiraServerProperties) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 7 with JiraServerProperties

use of com.synopsys.integration.alert.channel.jira.server.JiraServerProperties in project hub-alert by blackducksoftware.

the class JiraServerGlobalFieldModelTestAction method canUserGetIssues.

@Override
protected boolean canUserGetIssues(FieldUtility fieldUtility) throws IntegrationException {
    JiraServerProperties jiraProperties = createJiraProperties(fieldUtility);
    JiraServerServiceFactory jiraServerServiceFactory = jiraProperties.createJiraServicesServerFactory(logger, gson);
    IssueSearchService issueSearchService = jiraServerServiceFactory.createIssueSearchService();
    IssueSearchResponseModel issueSearchResponseModel = issueSearchService.queryForIssuePage("", 0, 1);
    return issueSearchResponseModel.getIssues().size() > 0;
}
Also used : JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) IssueSearchService(com.synopsys.integration.jira.common.server.service.IssueSearchService) IssueSearchResponseModel(com.synopsys.integration.jira.common.server.model.IssueSearchResponseModel) JiraServerProperties(com.synopsys.integration.alert.channel.jira.server.JiraServerProperties)

Aggregations

JiraServerProperties (com.synopsys.integration.alert.channel.jira.server.JiraServerProperties)7 JiraServerServiceFactory (com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory)7 PluginManagerService (com.synopsys.integration.jira.common.rest.service.PluginManagerService)3 JiraErrorMessageUtility (com.synopsys.integration.alert.api.channel.jira.distribution.JiraErrorMessageUtility)2 JiraIssueCreationRequestCreator (com.synopsys.integration.alert.api.channel.jira.distribution.JiraIssueCreationRequestCreator)2 JiraCustomFieldResolver (com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver)2 JiraIssueAlertPropertiesManager (com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueAlertPropertiesManager)2 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)2 IntegrationException (com.synopsys.integration.exception.IntegrationException)2 IssuePropertyService (com.synopsys.integration.jira.common.rest.service.IssuePropertyService)2 FieldService (com.synopsys.integration.jira.common.server.service.FieldService)2 IssueSearchService (com.synopsys.integration.jira.common.server.service.IssueSearchService)2 IssueService (com.synopsys.integration.jira.common.server.service.IssueService)2 ProjectService (com.synopsys.integration.jira.common.server.service.ProjectService)2 IntegrationRestException (com.synopsys.integration.rest.exception.IntegrationRestException)2 IssueTrackerModelExtractor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor)1 IssueTrackerProcessor (com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor)1 JiraIssueStatusCreator (com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueStatusCreator)1 JiraSearcherFactory (com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraSearcherFactory)1 ValidationResponseModel (com.synopsys.integration.alert.common.rest.model.ValidationResponseModel)1