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 void setConfiguration(KieServerConfig configuration) { if (this.configuration != null) { // if config already exists merge it with precedence given by the argument for (KieServerConfigItem item : configuration.getConfigItems()) { KieServerConfigItem existing = this.configuration.getConfigItem(item.getName()); if (existing != null) { this.configuration.removeConfigItem(existing); } configuration.addConfigItem(item); } } else { this.configuration = configuration; } } }
public void addConfigItem(KieServerConfigItem configItem) { KieServerConfigItem existing = getConfigItem(configItem.getName()); if (existing != null) { removeConfigItem(existing); } this.configItems.add(configItem); }
KieServerConfig config = new KieServerConfig(kieContainerInstance.getResource().getConfigItems()); 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);
@Test public void testConfigPassword(){ final KieServerConfig serverConfig = new KieServerConfig(); final String defaultPassword = "default"; serverConfig.addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, defaultPassword, null)); final String password = loadControllerPassword(serverConfig); assertEquals(defaultPassword, password); }
public KieServerState load(String serverId) { if (knownStates.containsKey(serverId)) { return knownStates.get(serverId); } synchronized (knownStates) { File serverStateFile = new File(repositoryDir, serverId + ".xml"); KieServerState kieServerState = new KieServerState(); if (serverStateFile.exists()) { kieServerState = (KieServerState) xs.fromXML(serverStateFile); // override controllers if given as system property String defaultController = System.getProperty(KieServerConstants.KIE_SERVER_CONTROLLER); if (defaultController != null && !defaultController.trim().isEmpty()) { String[] controllerList = defaultController.split(","); Set<String> controllers = new HashSet<String>(); for (String controller : controllerList) { controllers.add(controller.trim()); } kieServerState.setControllers(controllers); } KieServerStateRepositoryUtils.populateWithSystemProperties(kieServerState.getConfiguration()); } else { KieServerConfig config = new KieServerConfig(); KieServerStateRepositoryUtils.populateWithSystemProperties(config); kieServerState.setConfiguration(config); } knownStates.put(serverId, kieServerState); return kieServerState; } }
public static void populateWithProperties(KieServerConfig config, Properties properties) { // populate the config state with properties that are valid to kie server for (String property : properties.stringPropertyNames()) { if (property.startsWith("org.kie.server") || property.startsWith("org.kie.executor")) { KieServerConfigItem configItem = new KieServerConfigItem(property, properties.getProperty(property), String.class.getName()); config.addConfigItem(configItem); } } }
public String getConfigItemValue(String name) { KieServerConfigItem item = getConfigItem(name); if (item != null) { return item.getValue(); } return null; }
KieServerConfig serverConfig = new KieServerConfig(); for (Map.Entry<Capability, ServerConfig> entry : serverTemplate.getConfigs().entrySet()) { serverConfig.addConfigItem(configItem);
KieServerState serverState = new KieServerState(); KieServerConfig config = new KieServerConfig(); Properties properties = new Properties(); properties.putAll(System.getProperties());
public String getConfigItemValue(String name, String defaultValue) { KieServerConfigItem item = getConfigItem(name); if (item != null) { return item.getValue(); } return defaultValue; }
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 + "/"; } }
@Test public void testConfigDefaultPassword(){ final KieServerConfig serverConfig = new KieServerConfig(); final String password = loadControllerPassword(serverConfig); assertEquals("kieserver1!", password); }
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 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 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 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")); }