@Test public void testResolveServerUrl() { if (ServerTemplateConverter.PREFER_KIESERVER_SERVICE) { KieServerState state = repo.load(TEST_KIE_SERVER_ID); assertEquals("http: ServerTemplateConverter.fromState(state).getServerInstance(TEST_KIE_SERVER_ID).getUrl()); } }
protected static Optional<String> resolveServerUrl(KieServerState state) { String serverId = state.getConfiguration().getConfigItemValue(KIE_SERVER_ID, UNKNOWN); String serviceName = state.getConfiguration().getConfigItemValue(KIE_SERVER_SERVICES_OPENSHIFT_SERVICE_NAME, UNKNOWN); Optional<String> resolvedUrl = Optional.ofNullable(state.getConfiguration().getConfigItemValue(KIE_SERVER_LOCATION)); if (PREFER_KIESERVER_SERVICE && resolvedUrl.isPresent()) { String envPrefix = serviceName.replace('-', '_').toUpperCase(); String servicePortEnv = System.getenv(envPrefix.concat(SERVICE_PORT_ENV_SUFFIX)); String serviceHostEnv = System.getenv(envPrefix.concat(SERVICE_HOST_ENV_SUFFIX)); servicePortEnv = servicePortEnv == null ? "8080" : servicePortEnv; if (serviceHostEnv != null) { resolvedUrl = Optional.of(new StringBuffer("http: .append(serviceHostEnv) .append(":") .append(servicePortEnv) .append(SERVICE_PATH) .toString()); } else { logger.warn("Environment variable: [{}] defined by OpenShift Cluster Service for KIE server: [{}] not found.", envPrefix.concat(SERVICE_HOST_ENV_SUFFIX), serverId); if (resolvedUrl.isPresent()) { logger.warn("Use kie server location [{}]", resolvedUrl.get()); } else { logger.warn("Undefined kie server location"); } } } return resolvedUrl; }
ServerTemplateConverter { protected static Optional<String> resolveServerUrl(KieServerState state) { String serverId = state.getConfiguration().getConfigItemValue(KIE_SERVER_ID, UNKNOWN); String serviceName = state.getConfiguration().getConfigItemValue(KIE_SERVER_SERVICES_OPENSHIFT_SERVICE_NAME, UNKNOWN); Optional<String> resolvedUrl = Optional.ofNullable(state.getConfiguration().getConfigItemValue(KIE_SERVER_LOCATION)); if (PREFER_KIESERVER_SERVICE && resolvedUrl.isPresent()) { String envPrefix = serviceName.replace('-', '_').toUpperCase(); String servicePortEnv = System.getenv(envPrefix.concat(SERVICE_PORT_ENV_SUFFIX)); String serviceHostEnv = System.getenv(envPrefix.concat(SERVICE_HOST_ENV_SUFFIX)); servicePortEnv = servicePortEnv == null ? "8080" : servicePortEnv; if (serviceHostEnv != null) { resolvedUrl = Optional.of(new StringBuffer("http: .append(serviceHostEnv) .append(":") .append(servicePortEnv) .append(SERVICE_PATH) .toString()); } else { logger.warn("Environment variable: [{}] defined by OpenShift Cluster Service for KIE server: [{}] not found.", envPrefix.concat(SERVICE_HOST_ENV_SUFFIX), serverId); if (resolvedUrl.isPresent()) { logger.warn("Use kie server location [{}]", resolvedUrl.get()); } else { logger.warn("Undefined kie server location"); } } } return resolvedUrl; } }
ServerTemplateConverter { protected static Optional<String> resolveServerUrl(KieServerState state) { String serverId = state.getConfiguration().getConfigItemValue(KIE_SERVER_ID, UNKNOWN); String serviceName = state.getConfiguration().getConfigItemValue(KIE_SERVER_SERVICES_OPENSHIFT_SERVICE_NAME, UNKNOWN); Optional<String> resolvedUrl = Optional.ofNullable(state.getConfiguration().getConfigItemValue(KIE_SERVER_LOCATION)); if (PREFER_KIESERVER_SERVICE && resolvedUrl.isPresent()) { String envPrefix = serviceName.replace('-', '_').toUpperCase(); String servicePortEnv = System.getenv(envPrefix.concat(SERVICE_PORT_ENV_SUFFIX)); String serviceHostEnv = System.getenv(envPrefix.concat(SERVICE_HOST_ENV_SUFFIX)); servicePortEnv = servicePortEnv == null ? "8080" : servicePortEnv; if (serviceHostEnv != null) { resolvedUrl = Optional.of(new StringBuffer("http: .append(serviceHostEnv) .append(":") .append(servicePortEnv) .append(SERVICE_PATH) .toString()); } else { logger.warn("Environment variable: [{}] defined by OpenShift Cluster Service for KIE server: [{}] not found.", envPrefix.concat(SERVICE_HOST_ENV_SUFFIX), serverId); if (resolvedUrl.isPresent()) { logger.warn("Use kie server location [{}]", resolvedUrl.get()); } else { logger.warn("Undefined kie server location"); } } } return resolvedUrl; } private  ServerTemplateConverter(); }
ServerTemplateConverter { protected static Optional<String> resolveServerUrl(KieServerState state) { String serverId = state.getConfiguration().getConfigItemValue(KIE_SERVER_ID, UNKNOWN); String serviceName = state.getConfiguration().getConfigItemValue(KIE_SERVER_SERVICES_OPENSHIFT_SERVICE_NAME, UNKNOWN); Optional<String> resolvedUrl = Optional.ofNullable(state.getConfiguration().getConfigItemValue(KIE_SERVER_LOCATION)); if (PREFER_KIESERVER_SERVICE && resolvedUrl.isPresent()) { String envPrefix = serviceName.replace('-', '_').toUpperCase(); String servicePortEnv = System.getenv(envPrefix.concat(SERVICE_PORT_ENV_SUFFIX)); String serviceHostEnv = System.getenv(envPrefix.concat(SERVICE_HOST_ENV_SUFFIX)); servicePortEnv = servicePortEnv == null ? "8080" : servicePortEnv; if (serviceHostEnv != null) { resolvedUrl = Optional.of(new StringBuffer("http: .append(serviceHostEnv) .append(":") .append(servicePortEnv) .append(SERVICE_PATH) .toString()); } else { logger.warn("Environment variable: [{}] defined by OpenShift Cluster Service for KIE server: [{}] not found.", envPrefix.concat(SERVICE_HOST_ENV_SUFFIX), serverId); if (resolvedUrl.isPresent()) { logger.warn("Use kie server location [{}]", resolvedUrl.get()); } else { logger.warn("Undefined kie server location"); } } } return resolvedUrl; } private  ServerTemplateConverter(); static ServerTemplate fromState(KieServerState state); static KieServerState toState(ServerTemplate template); }
ServerTemplateConverter { protected static Optional<String> resolveServerUrl(KieServerState state) { String serverId = state.getConfiguration().getConfigItemValue(KIE_SERVER_ID, UNKNOWN); String serviceName = state.getConfiguration().getConfigItemValue(KIE_SERVER_SERVICES_OPENSHIFT_SERVICE_NAME, UNKNOWN); Optional<String> resolvedUrl = Optional.ofNullable(state.getConfiguration().getConfigItemValue(KIE_SERVER_LOCATION)); if (PREFER_KIESERVER_SERVICE && resolvedUrl.isPresent()) { String envPrefix = serviceName.replace('-', '_').toUpperCase(); String servicePortEnv = System.getenv(envPrefix.concat(SERVICE_PORT_ENV_SUFFIX)); String serviceHostEnv = System.getenv(envPrefix.concat(SERVICE_HOST_ENV_SUFFIX)); servicePortEnv = servicePortEnv == null ? "8080" : servicePortEnv; if (serviceHostEnv != null) { resolvedUrl = Optional.of(new StringBuffer("http: .append(serviceHostEnv) .append(":") .append(servicePortEnv) .append(SERVICE_PATH) .toString()); } else { logger.warn("Environment variable: [{}] defined by OpenShift Cluster Service for KIE server: [{}] not found.", envPrefix.concat(SERVICE_HOST_ENV_SUFFIX), serverId); if (resolvedUrl.isPresent()) { logger.warn("Use kie server location [{}]", resolvedUrl.get()); } else { logger.warn("Undefined kie server location"); } } } return resolvedUrl; } private  ServerTemplateConverter(); static ServerTemplate fromState(KieServerState state); static KieServerState toState(ServerTemplate template);  }