Search in sources :

Example 1 with JiraCloudProperties

use of com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties in project hub-alert by blackducksoftware.

the class JiraCloudGlobalFieldModelTestAction method isUserAdmin.

@Override
protected boolean isUserAdmin(FieldUtility fieldUtility) throws IntegrationException {
    JiraCloudProperties jiraProperties = jiraCloudPropertiesFactory.createJiraProperties(fieldUtility);
    JiraCloudServiceFactory jiraCloudServiceFactory = jiraProperties.createJiraServicesCloudFactory(logger, gson);
    MyPermissionsService myPermissionsService = jiraCloudServiceFactory.createMyPermissionsService();
    MultiPermissionResponseModel myPermissions = myPermissionsService.getMyPermissions(JiraGlobalFieldModelTestAction.JIRA_ADMIN_PERMISSION_NAME);
    PermissionModel adminPermission = myPermissions.extractPermission(JiraGlobalFieldModelTestAction.JIRA_ADMIN_PERMISSION_NAME);
    return null != adminPermission && adminPermission.getHavePermission();
}
Also used : JiraCloudServiceFactory(com.synopsys.integration.jira.common.cloud.service.JiraCloudServiceFactory) PermissionModel(com.synopsys.integration.jira.common.model.response.PermissionModel) MultiPermissionResponseModel(com.synopsys.integration.jira.common.model.response.MultiPermissionResponseModel) JiraCloudProperties(com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties) MyPermissionsService(com.synopsys.integration.jira.common.cloud.service.MyPermissionsService)

Example 2 with JiraCloudProperties

use of com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties in project hub-alert by blackducksoftware.

the class JiraCloudGlobalFieldModelTestAction method isAppMissing.

@Override
protected boolean isAppMissing(FieldUtility fieldUtility) throws IntegrationException {
    JiraCloudProperties jiraProperties = jiraCloudPropertiesFactory.createJiraProperties(fieldUtility);
    JiraCloudServiceFactory jiraCloudServiceFactory = jiraProperties.createJiraServicesCloudFactory(logger, gson);
    PluginManagerService jiraAppService = jiraCloudServiceFactory.createPluginManagerService();
    return !jiraAppService.isAppInstalled(JiraConstants.JIRA_APP_KEY);
}
Also used : PluginManagerService(com.synopsys.integration.jira.common.rest.service.PluginManagerService) JiraCloudServiceFactory(com.synopsys.integration.jira.common.cloud.service.JiraCloudServiceFactory) JiraCloudProperties(com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties)

Example 3 with JiraCloudProperties

use of com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties in project hub-alert by blackducksoftware.

the class JiraCloudGlobalFieldModelTestAction method canUserGetIssues.

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

Example 4 with JiraCloudProperties

use of com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties in project hub-alert by blackducksoftware.

the class JiraCloudProcessorFactory method createProcessor.

@Override
public IssueTrackerProcessor<String> createProcessor(JiraCloudJobDetailsModel distributionDetails) throws AlertException {
    JiraCloudProperties jiraProperties = createJiraCloudProperties();
    JiraCloudServiceFactory jiraCloudServiceFactory = jiraProperties.createJiraServicesCloudFactory(logger, gson);
    if (!jiraProperties.isPluginCheckDisabled()) {
        checkIfAlertPluginIsInstalled(jiraCloudServiceFactory.createPluginManagerService());
    }
    // Jira Cloud Services
    IssueService issueService = jiraCloudServiceFactory.createIssueService();
    IssueSearchService issueSearchService = jiraCloudServiceFactory.createIssueSearchService();
    IssuePropertyService issuePropertyService = jiraCloudServiceFactory.createIssuePropertyService();
    // Common Helpers
    JiraIssueAlertPropertiesManager issuePropertiesManager = new JiraIssueAlertPropertiesManager(gson, issuePropertyService);
    // Extractor Requirement
    JiraIssueStatusCreator jiraIssueStatusCreator = new JiraIssueStatusCreator(distributionDetails.getResolveTransition(), distributionDetails.getReopenTransition());
    JiraSearcherFactory jiraSearcherFactory = new JiraSearcherFactory(issuePropertiesManager, jiraIssueStatusCreator, issueService::getTransitions, issueCategoryRetriever, modelTransformer);
    JiraCloudQueryExecutor jiraCloudQueryExecutor = new JiraCloudQueryExecutor(issueSearchService);
    IssueTrackerSearcher<String> jiraSearcher = jiraSearcherFactory.createJiraSearcher(distributionDetails.getProjectNameOrKey(), jiraCloudQueryExecutor);
    IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(jiraMessageFormatter, jiraSearcher);
    ProjectService projectService = jiraCloudServiceFactory.createProjectService();
    FieldService fieldService = jiraCloudServiceFactory.createFieldService();
    JiraCustomFieldResolver customFieldResolver = new JiraCustomFieldResolver(fieldService::getUserVisibleFields);
    JiraIssueCreationRequestCreator issueCreationRequestCreator = new JiraIssueCreationRequestCreator(customFieldResolver);
    JiraErrorMessageUtility jiraErrorMessageUtility = new JiraErrorMessageUtility(gson, customFieldResolver);
    IssueTrackerMessageSender<String> messageSender = messageSenderFactory.createMessageSender(issueService, distributionDetails, projectService, issueCreationRequestCreator, issuePropertiesManager, jiraErrorMessageUtility);
    return new IssueTrackerProcessor<>(extractor, messageSender);
}
Also used : IssueService(com.synopsys.integration.jira.common.cloud.service.IssueService) IssueTrackerProcessor(com.synopsys.integration.alert.api.channel.issue.IssueTrackerProcessor) JiraCustomFieldResolver(com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver) JiraErrorMessageUtility(com.synopsys.integration.alert.api.channel.jira.distribution.JiraErrorMessageUtility) IssueSearchService(com.synopsys.integration.jira.common.cloud.service.IssueSearchService) JiraIssueCreationRequestCreator(com.synopsys.integration.alert.api.channel.jira.distribution.JiraIssueCreationRequestCreator) JiraCloudServiceFactory(com.synopsys.integration.jira.common.cloud.service.JiraCloudServiceFactory) IssuePropertyService(com.synopsys.integration.jira.common.rest.service.IssuePropertyService) JiraCloudProperties(com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties) ProjectService(com.synopsys.integration.jira.common.cloud.service.ProjectService) FieldService(com.synopsys.integration.jira.common.cloud.service.FieldService) JiraSearcherFactory(com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraSearcherFactory) IssueTrackerModelExtractor(com.synopsys.integration.alert.api.channel.issue.IssueTrackerModelExtractor) JiraIssueStatusCreator(com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueStatusCreator) JiraIssueAlertPropertiesManager(com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueAlertPropertiesManager)

Example 5 with JiraCloudProperties

use of com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties in project hub-alert by blackducksoftware.

the class JiraCloudCustomFunctionAction method createActionResponse.

@Override
public ActionResponse<String> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper ignoredServletContent) {
    JiraCloudProperties jiraProperties = jiraCloudPropertiesFactory.createJiraProperties(fieldModel);
    try {
        JiraCloudServiceFactory jiraServicesCloudFactory = jiraProperties.createJiraServicesCloudFactory(logger, gson);
        PluginManagerService jiraAppService = jiraServicesCloudFactory.createPluginManagerService();
        int statusCode = jiraAppService.installMarketplaceCloudApp(JiraConstants.JIRA_APP_KEY);
        if (!HttpStatusCodes.isSuccess(statusCode)) {
            return new ActionResponse<>(HttpStatus.BAD_REQUEST, "The Jira Cloud server responded with error code: " + statusCode);
        }
        boolean jiraPluginInstalled = JiraPluginCheckUtils.checkIsAppInstalledAndRetryIfNecessary(jiraAppService);
        if (!jiraPluginInstalled) {
            return new ActionResponse<>(HttpStatus.NOT_FOUND, String.format("Unable to confirm successful installation of the Jira Cloud '%s' plugin. Please verify the installation on your Jira Cloud server.", JiraConstants.JIRA_ALERT_APP_NAME));
        }
        return new ActionResponse<>(HttpStatus.OK, String.format("Successfully installed the '%s' plugin on Jira Cloud", JiraConstants.JIRA_ALERT_APP_NAME));
    } catch (IntegrationException e) {
        logger.error("There was an issue connecting to Jira Cloud", e);
        return new ActionResponse<>(HttpStatus.BAD_REQUEST, "The following error occurred when connecting to Jira Cloud: " + e.getMessage());
    } catch (InterruptedException e) {
        logger.error("Thread was interrupted while validating jira install.", 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) IntegrationException(com.synopsys.integration.exception.IntegrationException) JiraCloudServiceFactory(com.synopsys.integration.jira.common.cloud.service.JiraCloudServiceFactory) JiraCloudProperties(com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Aggregations

JiraCloudProperties (com.synopsys.integration.alert.channel.jira.cloud.JiraCloudProperties)6 JiraCloudServiceFactory (com.synopsys.integration.jira.common.cloud.service.JiraCloudServiceFactory)6 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 FieldService (com.synopsys.integration.jira.common.cloud.service.FieldService)2 IssueSearchService (com.synopsys.integration.jira.common.cloud.service.IssueSearchService)2 IssueService (com.synopsys.integration.jira.common.cloud.service.IssueService)2 ProjectService (com.synopsys.integration.jira.common.cloud.service.ProjectService)2 IssuePropertyService (com.synopsys.integration.jira.common.rest.service.IssuePropertyService)2 PluginManagerService (com.synopsys.integration.jira.common.rest.service.PluginManagerService)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 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 IssueSearchResponseModel (com.synopsys.integration.jira.common.cloud.model.IssueSearchResponseModel)1 MyPermissionsService (com.synopsys.integration.jira.common.cloud.service.MyPermissionsService)1