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