Search in sources :

Example 1 with JiraServerProperties

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

the class JiraServerProcessorFactory method createProcessor.

@Override
public IssueTrackerProcessor<String> createProcessor(JiraServerJobDetailsModel distributionDetails) throws AlertException {
    JiraServerProperties jiraProperties = jiraServerPropertiesFactory.createJiraPropertiesWithJobId(distributionDetails.getJobId());
    JiraServerServiceFactory jiraServerServiceFactory = jiraProperties.createJiraServicesServerFactory(logger, gson);
    if (!jiraProperties.isPluginCheckDisabled()) {
        checkIfAlertPluginIsInstalled(jiraServerServiceFactory.createPluginManagerService());
    }
    // Jira Services
    IssueService issueService = jiraServerServiceFactory.createIssueService();
    IssueSearchService issueSearchService = jiraServerServiceFactory.createIssueSearchService();
    IssuePropertyService issuePropertyService = jiraServerServiceFactory.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);
    JiraServerQueryExecutor jiraCloudQueryExecutor = new JiraServerQueryExecutor(issueSearchService);
    IssueTrackerSearcher<String> jiraSearcher = jiraSearcherFactory.createJiraSearcher(distributionDetails.getProjectNameOrKey(), jiraCloudQueryExecutor);
    IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(jiraMessageFormatter, jiraSearcher);
    ProjectService projectService = jiraServerServiceFactory.createProjectService();
    FieldService fieldService = jiraServerServiceFactory.createFieldService();
    JiraCustomFieldResolver customFieldResolver = new JiraCustomFieldResolver(fieldService::getUserVisibleFields);
    JiraIssueCreationRequestCreator issueCreationRequestCreator = new JiraIssueCreationRequestCreator(customFieldResolver);
    JiraErrorMessageUtility jiraErrorMessageUtility = new JiraErrorMessageUtility(gson, customFieldResolver);
    IssueTrackerMessageSender<String> messageSender = jiraServerMessageSenderFactory.createMessageSender(issueService, distributionDetails, projectService, issueCreationRequestCreator, issuePropertiesManager, jiraErrorMessageUtility);
    return new IssueTrackerProcessor<>(extractor, messageSender);
}
Also used : IssueService(com.synopsys.integration.jira.common.server.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.server.service.IssueSearchService) JiraIssueCreationRequestCreator(com.synopsys.integration.alert.api.channel.jira.distribution.JiraIssueCreationRequestCreator) IssuePropertyService(com.synopsys.integration.jira.common.rest.service.IssuePropertyService) ProjectService(com.synopsys.integration.jira.common.server.service.ProjectService) JiraServerProperties(com.synopsys.integration.alert.channel.jira.server.JiraServerProperties) FieldService(com.synopsys.integration.jira.common.server.service.FieldService) JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) 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 2 with JiraServerProperties

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

the class JiraServerGlobalFieldModelTestAction method isUserAdmin.

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

Example 3 with JiraServerProperties

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

the class JiraServerGlobalFieldModelTestAction method isAppMissing.

@Override
protected boolean isAppMissing(FieldUtility fieldUtility) throws IntegrationException {
    JiraServerProperties jiraProperties = createJiraProperties(fieldUtility);
    JiraServerServiceFactory jiraServerServiceFactory = jiraProperties.createJiraServicesServerFactory(logger, gson);
    PluginManagerService jiraAppService = jiraServerServiceFactory.createPluginManagerService();
    return !jiraAppService.isAppInstalled(JiraConstants.JIRA_APP_KEY);
}
Also used : PluginManagerService(com.synopsys.integration.jira.common.rest.service.PluginManagerService) JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) JiraServerProperties(com.synopsys.integration.alert.channel.jira.server.JiraServerProperties)

Example 4 with JiraServerProperties

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

the class JiraServerMessageSenderFactory method createMessageSender.

@Override
public IssueTrackerMessageSender<String> createMessageSender(JiraServerJobDetailsModel distributionDetails) throws AlertException {
    JiraServerProperties jiraServerProperties = jiraServerPropertiesFactory.createJiraPropertiesWithJobId(distributionDetails.getJobId());
    JiraServerServiceFactory jiraServerServiceFactory = jiraServerProperties.createJiraServicesServerFactory(logger, gson);
    // Jira Services
    IssueService issueService = jiraServerServiceFactory.createIssueService();
    IssuePropertyService issuePropertyService = jiraServerServiceFactory.createIssuePropertyService();
    // Common Helpers
    JiraIssueAlertPropertiesManager issuePropertiesManager = new JiraIssueAlertPropertiesManager(gson, issuePropertyService);
    ProjectService projectService = jiraServerServiceFactory.createProjectService();
    FieldService fieldService = jiraServerServiceFactory.createFieldService();
    JiraCustomFieldResolver customFieldResolver = new JiraCustomFieldResolver(fieldService::getUserVisibleFields);
    JiraIssueCreationRequestCreator issueCreationRequestCreator = new JiraIssueCreationRequestCreator(customFieldResolver);
    JiraErrorMessageUtility jiraErrorMessageUtility = new JiraErrorMessageUtility(gson, customFieldResolver);
    return createMessageSender(issueService, distributionDetails, projectService, issueCreationRequestCreator, issuePropertiesManager, jiraErrorMessageUtility);
}
Also used : IssueService(com.synopsys.integration.jira.common.server.service.IssueService) FieldService(com.synopsys.integration.jira.common.server.service.FieldService) JiraCustomFieldResolver(com.synopsys.integration.alert.api.channel.jira.distribution.custom.JiraCustomFieldResolver) JiraErrorMessageUtility(com.synopsys.integration.alert.api.channel.jira.distribution.JiraErrorMessageUtility) JiraServerServiceFactory(com.synopsys.integration.jira.common.server.service.JiraServerServiceFactory) JiraIssueCreationRequestCreator(com.synopsys.integration.alert.api.channel.jira.distribution.JiraIssueCreationRequestCreator) IssuePropertyService(com.synopsys.integration.jira.common.rest.service.IssuePropertyService) ProjectService(com.synopsys.integration.jira.common.server.service.ProjectService) JiraServerProperties(com.synopsys.integration.alert.channel.jira.server.JiraServerProperties) JiraIssueAlertPropertiesManager(com.synopsys.integration.alert.api.channel.jira.distribution.search.JiraIssueAlertPropertiesManager)

Example 5 with JiraServerProperties

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

the class JiraServerInstallPluginAction method installPlugin.

public ActionResponse<ValidationResponseModel> installPlugin(JiraServerGlobalConfigModel jiraServerGlobalConfigModel) {
    if (!authorizationManager.hasExecutePermission(ConfigContextEnum.GLOBAL, ChannelKeys.JIRA_SERVER)) {
        return new ActionResponse<>(HttpStatus.FORBIDDEN, ResponseFactory.UNAUTHORIZED_REQUEST_MESSAGE);
    }
    ActionResponse<ValidationResponseModel> validate = jiraServerGlobalValidationAction.validate(jiraServerGlobalConfigModel);
    Boolean validationHasErrors = validate.getContent().map(ValidationResponseModel::hasErrors).orElse(false);
    if (validationHasErrors) {
        return validate;
    }
    JiraServerProperties jiraProperties = jiraServerPropertiesFactory.createJiraProperties(jiraServerGlobalConfigModel);
    try {
        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 : ValidationResponseModel(com.synopsys.integration.alert.common.rest.model.ValidationResponseModel) 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)

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