Commit 17d7822e authored by Marco Descher's avatar Marco Descher
Browse files

[17024] Cleanup, add keycloak base url

parent d28442df
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -16,25 +16,21 @@ import ch.elexis.core.eenv.IElexisEnvironmentService;
import ch.elexis.core.services.IConfigService;

/**
 * Programmatically register the {@link ElexisEnvironmentService} if conditions are met. That is, 
 * an Elexis-Environment host value is passed.
 * Programmatically register the {@link ElexisEnvironmentService} if conditions are met. That is, an
 * Elexis-Environment host value is passed.
 */
@Component
public class ElexisEnvironmentServiceActivator {
	
	private ServiceRegistration<IElexisEnvironmentService> serviceRegistration;
	
	private String elexisEnvironmentHost;
	
	private Logger log = LoggerFactory.getLogger(getClass());
	
	@Reference
	private IConfigService configService;
	
	@Activate
	public void activate(){
		// 1. try via system property
		elexisEnvironmentHost =
		String elexisEnvironmentHost =
			System.getProperty(ElexisSystemPropertyConstants.EE_HOSTNAME);
		// 2. if empty fetch via environment variable
		if (StringUtils.isBlank(elexisEnvironmentHost)) {
@@ -46,12 +42,13 @@ public class ElexisEnvironmentServiceActivator {
				configService.get(IElexisEnvironmentService.CFG_EE_HOSTNAME, null);
		}
		
		if (StringUtils.isNotBlank(elexisEnvironmentHost)) {
		Logger log = LoggerFactory.getLogger(getClass());
		
		if (StringUtils.isNotBlank(elexisEnvironmentHost)) {
			try {
				// activate the service
				ElexisEnvironmentService elexisEnvironmentService = new ElexisEnvironmentService(
					elexisEnvironmentHost);
				ElexisEnvironmentService elexisEnvironmentService =
					new ElexisEnvironmentService(elexisEnvironmentHost);
				serviceRegistration =
					FrameworkUtil.getBundle(ElexisEnvironmentServiceActivator.class)
						.getBundleContext().registerService(IElexisEnvironmentService.class,
@@ -63,6 +60,7 @@ public class ElexisEnvironmentServiceActivator {
			} catch (Exception e) {
				log.warn("Initializing elexis-environment failed", e);
			}
			
		} else {
			log.debug("No elexis-environment configured");
		}
+4 −0
Original line number Diff line number Diff line
@@ -39,4 +39,8 @@ public interface IElexisEnvironmentService {
		return getBaseUrl() + "/bookstack";
	}
	
	default String getKeycloakBaseUrl(){
		return getBaseUrl() + "/keycloak";
	}
	
}