protected Map<String, String> getPersistenceProperties(KieServerConfig config) { Map<String, String> persistenceProperties = new HashMap<String, String>(); persistenceProperties.put("hibernate.dialect", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DIALECT, "org.hibernate.dialect.H2Dialect")); persistenceProperties.put("hibernate.default_schema", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DEFAULT_SCHEMA)); persistenceProperties.put("hibernate.transaction.jta.platform", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_TM, "JBossAS")); persistenceProperties.put("javax.persistence.jtaDataSource", config.getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DS, "java:jboss/datasources/ExampleDS")); System.getProperties().stringPropertyNames() .stream() .filter(PersistenceUnitInfoLoader::isValidPersistenceKey) .forEach(name -> persistenceProperties.put(name, System.getProperty(name))); return persistenceProperties; }
public ImageServiceBase(RuntimeDataService dataService, Map<String, ImageReference> imageReferenceMap, KieServerRegistry registry) { this.dataService = dataService; this.imageReferenceMap = imageReferenceMap; this.registry = registry; this.kieServerLocation = this.registry.getConfig().getConfigItemValue(KieServerConstants.KIE_SERVER_LOCATION, System.getProperty(KieServerConstants.KIE_SERVER_LOCATION, "unknown")); if (!this.kieServerLocation.endsWith("/")) { this.kieServerLocation = kieServerLocation + "/"; } }
public static String loadControllerPassword(final KieServerConfig config) { return loadControllerPassword(config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, "kieserver1!")); }
public static String loadControllerPassword(final KieServerConfig config) { return loadControllerPassword(config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, "kieserver1!")); }
public CaseManagementRuntimeDataServiceBase(CaseRuntimeDataService caseRuntimeDataService, KieServerRegistry context) { this.caseRuntimeDataService = caseRuntimeDataService; this.identityProvider = context.getIdentityProvider(); this.context = context; this.bypassAuthUser = Boolean.parseBoolean(context.getConfig().getConfigItemValue(KieServerConstants.CFG_BYPASS_AUTH_USER, "false")); }
public RuntimeDataServiceBase(RuntimeDataService delegate, KieServerRegistry context) { this.runtimeDataService = delegate; this.identityProvider = context.getIdentityProvider(); this.context = context; this.bypassAuthUser = Boolean.parseBoolean(context.getConfig().getConfigItemValue(KieServerConstants.CFG_BYPASS_AUTH_USER, "false")); }
public boolean disconnectFromSingleController(KieServerInfo serverInfo, KieServerConfig config, String controllerUrl) { String connectAndSyncUrl = null; try { connectAndSyncUrl = controllerUrl + "/server/" + KieServerEnvironment.getServerId()+"/?location="+ URLEncoder.encode(serverInfo.getLocation(), "UTF-8"); String userName = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver"); String password = loadControllerPassword(config); String token = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN); makeHttpDeleteRequestAndCreateCustomResponse(connectAndSyncUrl, null, userName, password, token); return true; } catch (Exception e) { // let's check all other controllers in case of running in cluster of controllers logger.debug("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getMessage(), e); return false; } }
public KieServerSetup connectToSingleController(KieServerInfo serverInfo, KieServerConfig config, String controllerUrl) { String connectAndSyncUrl = controllerUrl + "/server/" + KieServerEnvironment.getServerId(); String userName = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver"); String password = loadControllerPassword(config); String token = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN); try { KieServerSetup kieServerSetup = makeHttpPutRequestAndCreateCustomResponse(connectAndSyncUrl, serialize(serverInfo), KieServerSetup.class, userName, password, token); if (kieServerSetup != null) { // once there is non null list let's return it return kieServerSetup; } } catch (Exception e) { // let's check all other controllers in case of running in cluster of controllers logger.warn("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getMessage(), e); } return null; }
public UserTaskServiceBase(UserTaskService userTaskService, KieServerRegistry context) { this.userTaskService = userTaskService; this.context = context; this.identityProvider = context.getIdentityProvider(); this.marshallerHelper = new MarshallerHelper(context); this.bypassAuthUser = Boolean.parseBoolean(context.getConfig().getConfigItemValue(KieServerConstants.CFG_BYPASS_AUTH_USER, "false")); }
public void stopContainer(String containerId) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { String connectAndSyncUrl = controllerUrl + "/management/servers/" + KieServerEnvironment.getServerId() + "/containers/" + containerId + "/status/stopped"; String userName = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver"); String password = loadControllerPassword(config); String token = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN); try { makeHttpPostRequestAndCreateCustomResponse(connectAndSyncUrl, "", null, userName, password, token); break; } catch (Exception e) { // let's check all other controllers in case of running in cluster of controllers logger.warn("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getMessage(), e); } } } } } }
public void startContainer(String containerId) { KieServerState currentState = context.getStateRepository().load(KieServerEnvironment.getServerId()); Set<String> controllers = currentState.getControllers(); KieServerConfig config = currentState.getConfiguration(); if (controllers != null && !controllers.isEmpty()) { for (String controllerUrl : controllers) { if (controllerUrl != null && !controllerUrl.isEmpty()) { String connectAndSyncUrl = controllerUrl + "/management/servers/" + KieServerEnvironment.getServerId() + "/containers/" + containerId + "/status/started"; String userName = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver"); String password = loadControllerPassword(config); String token = config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN); try { makeHttpPostRequestAndCreateCustomResponse(connectAndSyncUrl, "", null, userName, password, token); break; } catch (Exception e) { // let's check all other controllers in case of running in cluster of controllers logger.warn("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getCause() == null ? e.getMessage() : e.getCause().getMessage()); logger.debug("Exception encountered while syncing with controller at {} error {}", connectAndSyncUrl, e.getMessage(), e); } } } } }
public CaseManagementServiceBase(CaseService caseService, CaseRuntimeDataService caseRuntimeDataService, KieServerRegistry context) { this.caseService = caseService; this.caseRuntimeDataService = caseRuntimeDataService; this.marshallerHelper = new MarshallerHelper(context); this.identityProvider = context.getIdentityProvider(); this.context = context; this.taskModelFactory = TaskModelProvider.getFactory(); this.bypassAuthUser = Boolean.parseBoolean(context.getConfig().getConfigItemValue(KieServerConstants.CFG_BYPASS_AUTH_USER, "false")); }
this), "KieServer-ControllerConnect"); connectToControllerThread.start(); if (Boolean.parseBoolean(currentState.getConfiguration().getConfigItemValue(KieServerConstants.CFG_SYNC_DEPLOYMENT, "false"))) { logger.info("Containers were requested to be deployed synchronously, holding application start..."); try { if (Boolean.parseBoolean(currentState.getConfiguration().getConfigItemValue(KieServerConstants.CFG_SYNC_DEPLOYMENT, "false"))) { containerManager.installContainersSync(kieServer, containers, currentState, kieServerSetup); } else {
this.client.init(WebSocketClientConfiguration.builder() .controllerUrl(connectAndSyncUrl) .userName(config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_USER, "kieserver")) .password(KeyStoreHelperUtil.loadControllerPassword(config)) .token(config.getConfigItemValue(KieServerConstants.CFG_KIE_CONTROLLER_TOKEN)) .build()); CountDownLatch waitLatch = new CountDownLatch(1);
String runtimeStrategy = config.getConfigItemValue(KieServerConstants.PCFG_RUNTIME_STRATEGY); if (runtimeStrategy != null && !runtimeStrategy.isEmpty()) { unit.setStrategy(RuntimeStrategy.valueOf(runtimeStrategy)); String mergeMode = config.getConfigItemValue(KieServerConstants.PCFG_MERGE_MODE); if (mergeMode != null && !mergeMode.isEmpty()) { unit.setMergeMode(MergeMode.valueOf(mergeMode)); String ksession = config.getConfigItemValue(KieServerConstants.PCFG_KIE_SESSION); unit.setKsessionName(ksession); String kbase = config.getConfigItemValue(KieServerConstants.PCFG_KIE_BASE); unit.setKbaseName(kbase);
String processInstanceQuerySource = context.getConfig().getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DS, "java:jboss/datasources/ExampleDS");
String taskQuerySource = context.getConfig().getConfigItemValue(KieServerConstants.CFG_PERSISTANCE_DS, "java:jboss/datasources/ExampleDS");
String paramName = matcher.group(1); KieServerConfig configuration = context.getStateRepository().load(KieServerEnvironment.getServerId()).getConfiguration(); dataSource = configuration.getConfigItemValue(paramName, "java:jboss/datasources/ExampleDS"); logger.info("Data source expression {} resolved to {}", input, dataSource); ((KModuleDeploymentService) deploymentService).addListener(((QueryServiceImpl) queryService)); if (config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_DISABLED, "false").equalsIgnoreCase("false")) { String executorQueueName = config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_JMS_QUEUE, "queue/KIE.SERVER.EXECUTOR"); executorService.setInterval(Integer.parseInt(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_INTERVAL, "0"))); executorService.setRetries(Integer.parseInt(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_RETRIES, "3"))); executorService.setThreadPoolSize(Integer.parseInt(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_POOL, "1"))); executorService.setTimeunit(TimeUnit.valueOf(config.getConfigItemValue(KieServerConstants.CFG_EXECUTOR_TIME_UNIT, "SECONDS")));