/**
 * Copyright 2014 SeaClouds
 * Contact: SeaClouds
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package eu.seaclouds.platform.dashboard;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class to parse Java system properties to static keys.
 */
public class ConfigParameters {
    static Logger log = LoggerFactory.getLogger(ConfigParameters.class);

    // Planner connection
    public static String PLANNER_ENDPOINT;

    // Monitor connection
    public static String MONITOR_ENDPOINT;

    // Deployer connection
    public static String DEPLOYER_ENDPOINT;
    // Credentials
    public static String DEPLOYER_USERNAME;
    public static String DEPLOYER_PASSWORD;

    // SLA connection
    public static String SLA_ENDPOINT;

    static {
        PLANNER_ENDPOINT = System.getProperty("planner.endpoint");
        MONITOR_ENDPOINT = System.getProperty("monitor.endpoint");

        String deployerAddress = System.getProperty("deployer.host");
        String deployerHttpPort = System.getProperty("deployer.httpPort");
        if (deployerAddress != null) {
            DEPLOYER_ENDPOINT = "http://" + deployerAddress
                    + ":" + (deployerHttpPort == null ? "8081" : deployerHttpPort);

            DEPLOYER_USERNAME = System.getProperty("deployer.username");
            DEPLOYER_PASSWORD = System.getProperty("deployer.password");
        } else {
            log.error("Property 'deployer.host' not defined");
        }

        SLA_ENDPOINT = System.getProperty("sla.endpoint");
    }
}
@@ -1130,27 +1130,8 @@
 NT;%0A
-    // Credentials%0A
     
@@ -1273,24 +1273,25 @@
 _ENDPOINT;%0A%0A
+%0A
     static %7B
@@ -1291,16 +1291,99 @@
 tatic %7B%0A
+        /*%0A            Loading config keys from Java system properties%0A         */%0A
         
@@ -1415,34 +1415,29 @@
 .get
-Property(%22planner.endpoint
+env(%22PLANNER_ENDPOINT
 %22);%0A
@@ -1477,39 +1477,33 @@
 .get
-Property(%22monitor.endpoint
+env(%22MONITOR_ENDPOINT
 %22);%0A
-%0A
     
@@ -1511,332 +1511,117 @@
    S
-tring deployerAddress = System.getProperty(%22deployer.host%22);%0A        String deployerHttpPort = System.getProperty(%22deployer.httpPort%22);%0A        if (deployerAddress != null) %7B%0A            DEPLOYER_ENDPOINT = %22http://%22 + deployerAddress%0A                    + %22:%22 + (deployerHttpPort == null ? %228081%22 : deployerHttpPort);%0A%0A    
+LA_ENDPOINT = System.getenv(%22SLA_ENDPOINT%22);%0A        DEPLOYER_ENDPOINT = System.getenv(%22DEPLOYER_ENDPOINT%22);%0A
     
@@ -1658,43 +1658,34 @@
 .get
-Property(%22deployer.username%22);%0A    
+env(%22DEPLOYER_USERNAME%22);%0A
     
@@ -1722,123 +1722,35 @@
 .get
-Property(%22deployer.password%22);%0A        %7D else %7B%0A            log.error(%22Property 'deployer.host' not defined%22);%0A    
+env(%22DEPLOYER_PASSWORD%22);%0A%0A
     
@@ -1760,66 +1760,24 @@
     
-   
+//
  SLA
-_ENDPOINT = System.getProperty(%22sla.endpoint%22);%0A    %7D
+ connection%0A
 %0A%7D

FIX (Dashboard): Retrieving Components' endpoints from env variables instead of properties