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