runtime.submitCallable(callable, new IRuntime.IFinishedExecution<Void>() { @Override
continue; runtime.submitScheduledCallable(() -> { try { if (!fbQuickReplies.isEmpty()) {
IConversation conversation) { return () -> { waitForExecutionFinishOrTimeout(conversationId, runtime.submitCallable(() -> { conversation.say(message, convertContext(inputDataContext)); return null;
}; SystemRuntime.getRuntime().submitCallable(processUserInput, null); return Response.accepted().build(); } catch (IllegalAccessException e) {
private void deploy(final Deployment.Environment environment, final String botId, final Integer version, final Boolean autoDeploy) { Callable<Void> deployBot = () -> { try { if (EnumSet.of(Status.NOT_FOUND, Status.ERROR).contains(checkDeploymentStatus(environment, botId, version))) { botFactory.deployBot(environment, botId, version, status -> { if (status == Status.READY && autoDeploy) { deploymentStore.setDeploymentInfo(environment.toString(), botId, version, DeploymentStatus.deployed); } }); } } catch (ServiceException e) { throwError(botId, version, e, "Error while deploying bot! (botId=%s , version=%s)"); } catch (IllegalAccessException e) { throwErrorForbidden(botId, version, e); } catch (Exception e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e.getLocalizedMessage(), e); } return null; }; SystemRuntime.getRuntime().submitCallable(deployBot, ThreadContext.getResources()); }
}; SystemRuntime.getRuntime().submitCallable(processUserInput, null);
@Override public void parse(String configId, Integer version, String sentence, AsyncResponse asyncResponse) { asyncResponse.setTimeout(30, TimeUnit.SECONDS); runtime.submitCallable((Callable<Void>) () -> { try { URI resourceUri = URI.create(IRestParserStore.resourceURI + configId + IRestParserStore.versionQueryParam + version); InputParserTask inputParserTask = getParser(resourceUri); IInputParser inputParser = (IInputParser) inputParserTask.getComponent(); List<RawSolution> rawSolutions = inputParser.parse(sentence); List<Solution> solutionExpressions = extractExpressions(rawSolutions, true, true); asyncResponse.resume(solutionExpressions); } catch (IllegalArgumentException e) { asyncResponse.resume(new BadRequestException(e.getLocalizedMessage())); } catch (Exception e) { log.error(e.getLocalizedMessage(), e); asyncResponse.resume(new InternalServerErrorException()); } return null; }, null); }
public void executeTestCase(final String id, final TestCase testCase) { SystemRuntime.getRuntime().submitCallable((Callable<Void>) () -> { try { testCaseStore.setTestCaseState(id, TestCaseState.IN_PROGRESS); if (!isBotDeployed(testCase.getBotId(), testCase.getBotVersion())) { deployBot(testCase.getBotId(), testCase.getBotVersion()); } ConversationMemorySnapshot actual = runTestCase(testCase.getBotId(), testCase); testCase.setActual(actual); testCase.setLastRun(new Date(System.currentTimeMillis())); testCase.setTestCaseState(testCase.getExpected().equals(testCase.getActual()) ? TestCaseState.SUCCESS : TestCaseState.FAILED); testCaseStore.storeTestCase(id, testCase); } catch (Exception e) { testCaseStore.setTestCaseState(id, TestCaseState.ERROR); throw e; } return null; }, ThreadContext.getResources()); }
private void undeploy(Deployment.Environment environment, String botId, Integer version) { Callable<Void> undeployBot = () -> { try { botFactory.undeployBot(environment, botId, version); deploymentStore.setDeploymentInfo(environment.toString(), botId, version, DeploymentStatus.undeployed); } catch (ServiceException e) { throwError(botId, version, e, "Error while undeploying bot! (botId=%s , version=%s)"); } catch (IllegalAccessException e) { return throwErrorForbidden(botId, version, e); } catch (Exception e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException(e.getLocalizedMessage(), e); } return null; }; SystemRuntime.getRuntime().submitCallable(undeployBot, ThreadContext.getResources()); }
@Override public Response webHook(final String botId, final Integer botVersion, final String callbackPayload, final String sha1PayloadSignature) { SystemRuntime.getRuntime().submitCallable((Callable<Void>) () -> { try { log.info("web hook called"); getMessageClient(botId, botVersion).getReceiveClient(). processCallbackPayload(callbackPayload, sha1PayloadSignature); } catch (MessengerVerificationException e) { log.error(e.getLocalizedMessage(), e); throw new InternalServerErrorException("Error when processing callback payload"); } return null; }, null); return Response.ok().build(); }
@Override public String viewHtml(String path) { try { path = preparePath(path); String htmlString = resourceFileManager.getResourceAsString("html", path); htmlString = htmlString.replace("<EDDI-VERSION/>", runtime.getVersion()); return htmlString; } catch (IResourceFileManager.NotFoundException e) { throw new NoLogWebApplicationException(Response.Status.NOT_FOUND); } }