Search in sources :

Example 6 with JiraServerServiceFactory

use of com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory in project hub-alert by blackducksoftware.

the class JiraServerPropertiesTest method testServerServiceFactory.

@Test
public void testServerServiceFactory() {
    try {
        JiraServerProperties properties = new JiraServerProperties("http://localhost:2990", "password", "user", false, ProxyInfo.NO_PROXY_INFO);
        JiraServerServiceFactory serviceFactory = properties.createJiraServicesServerFactory(LoggerFactory.getLogger(getClass()), new Gson());
        assertNotNull(serviceFactory);
    } catch (IssueTrackerException ex) {
        ex.printStackTrace();
        fail();
    }
}
Also used : JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) IssueTrackerException(com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueTrackerException) Gson(com.google.gson.Gson) Test(org.junit.jupiter.api.Test)

Example 7 with JiraServerServiceFactory

use of com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory 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 8 with JiraServerServiceFactory

use of com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory 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)

Example 9 with JiraServerServiceFactory

use of com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory in project hub-alert by blackducksoftware.

the class JiraServerProperties method createJiraServicesServerFactory.

public JiraServerServiceFactory createJiraServicesServerFactory(Logger logger, Gson gson) throws IssueTrackerException {
    JiraServerRestConfig jiraServerConfig = createJiraServerConfig();
    Slf4jIntLogger intLogger = new Slf4jIntLogger(logger);
    JiraHttpClient jiraHttpClient = jiraServerConfig.createJiraHttpClient(intLogger);
    return new JiraServerServiceFactory(intLogger, jiraHttpClient, gson);
}
Also used : JiraHttpClient(com.synopsys.integration.jira.common.rest.JiraHttpClient) JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) JiraServerRestConfig(com.synopsys.integration.jira.common.server.configuration.JiraServerRestConfig) Slf4jIntLogger(com.synopsys.integration.log.Slf4jIntLogger)

Aggregations

JiraServerServiceFactory (com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory)9 JiraServerProperties (com.synopsys.integration.alert.channel.jira.server.JiraServerProperties)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 Gson (com.google.gson.Gson)1 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