use of com.epam.ta.reportportal.ws.model.ErrorType.INTEGRATION_NOT_FOUND in project service-api by reportportal.
the class ExecuteIntegrationHandlerImpl method executeCommand.
@Override
public Object executeCommand(ReportPortalUser.ProjectDetails projectDetails, Long integrationId, String command, Map<String, Object> executionParams) {
Integration integration = integrationRepository.findByIdAndProjectId(integrationId, projectDetails.getProjectId()).orElseGet(() -> integrationRepository.findGlobalById(integrationId).orElseThrow(() -> new ReportPortalException(INTEGRATION_NOT_FOUND, integrationId)));
ReportPortalExtensionPoint pluginInstance = pluginBox.getInstance(integration.getType().getName(), ReportPortalExtensionPoint.class).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, formattedSupplier("Plugin for '{}' isn't installed", integration.getType().getName()).get()));
Boolean asyncMode = ofNullable((Boolean) executionParams.get(ASYNC_MODE)).orElse(false);
executionParams.put(PROJECT_ID, projectDetails.getProjectId());
return ofNullable(pluginInstance.getCommandToExecute(command)).map(it -> {
if (asyncMode) {
supplyAsync(() -> it.executeCommand(integration, executionParams));
return new OperationCompletionRS(formattedSupplier("Command '{}' accepted for processing in plugin", command, integration.getType().getName()).get());
}
return it.executeCommand(integration, executionParams);
}).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, formattedSupplier("Command '{}' is not found in plugin {}.", command, integration.getType().getName()).get()));
}
Aggregations