package framework;

import common.JSONReader;

/**
 * Created with IntelliJ IDEA.
 * User: jhasmanyquiroz
 * Date: 12/8/15
 * Time: 3:06 PM
 * To change this template use File | Settings | File Templates.
 */
public class CredentialsManager {
    private JSONReader jsonObjectMain;
    private static  CredentialsManager instance = null;
    private static String envId;

    private static String adminURL;
    private static String tabletURL;
    private static String roomManagerService;
    private static String adminUserName;
    private static String adminUserPassword;
    private static String tabletUserName;
    private static String tabletUserPassword;
    private static String exchangeUserName;
    private static String exchangeUserPassword;
    private static String apiServer;

    protected CredentialsManager() {
        initialize();
    }

    /**
     * Return the instance of CredentialsManager.
     */
    public static CredentialsManager getInstance() {
        if(instance == null) {
            instance = new CredentialsManager();
        }
        return instance;
    }

    private void initialize() {
        String filePath = System.getProperty("user.dir")+"\\environment.json";
        jsonObjectMain = new JSONReader(filePath);
        String environmentId = System.getProperty("envId");
        if (environmentId == null || environmentId.isEmpty()){
            envId = "RM02";
        } else {
            envId = environmentId;
        }

        adminURL = jsonObjectMain.getKeyValue("Environments", "id", envId, "admin URL");
        tabletURL = jsonObjectMain.getKeyValue("Environments", "id", envId, "tablet URL");
        roomManagerService = jsonObjectMain.getKeyValue("Environments", "id", envId, "room manager service");
        adminUserName = jsonObjectMain.getKeyValue("Environments", "id", envId, "admin user", "name");
        adminUserPassword = jsonObjectMain.getKeyValue("Environments", "id", envId, "admin user", "password");
        tabletUserName = jsonObjectMain.getKeyValue("Environments", "id", envId, "tablet user", "name");
        tabletUserPassword = jsonObjectMain.getKeyValue("Environments", "id", envId, "tablet user", "password");
        exchangeUserName = jsonObjectMain.getKeyValue("Environments", "id", envId, "exchange user", "name");
        exchangeUserPassword = jsonObjectMain.getKeyValue("Environments", "id", envId, "exchange user", "password");
        apiServer = jsonObjectMain.getKeyValue("Environments", "id", envId, "api", "server");

    }

    public String getBaseAdminURL() {
        return adminURL;
    }

    public String getBaseTabletURL() {
        return tabletURL;
    }

    public String getRoomManagerService() {
        return roomManagerService;
    }

    public String getAdminUserName() {
        return adminUserName;
    }

    public String getAdminUserPassword() {
        return adminUserPassword;
    }

    public String getTabletUserName() {
        return tabletUserName;
    }

    public String getTabletUserPassword() {
        return tabletUserPassword;
    }

    public String getExchangeUserName() {
        return exchangeUserName;
    }

    public String getExchangeUserPassword() {
        return exchangeUserPassword;
    }

    public String getApiServer() {
        return apiServer;
    }
}
@@ -326,15 +326,8 @@
 ance
- = null
 ;%0A  
@@ -909,17 +909,16 @@
 er.%0A    
- 
 */%0A    p
@@ -1083,24 +1083,139 @@
 nce;%0A    %7D%0A%0A
+    /**%0A     * Initialize the properties of JSON Reader%0A     * and read the values of environment.json file%0A    */%0A
     private 
@@ -2603,19 +2603,19 @@
 envId, %22
-api
+API
 %22, %22serv
@@ -2620,32 +2620,99 @@
 rver%22);%0A%0A    %7D%0A%0A
+    /**%0A     * Return the getters and setters about values.%0A    */%0A
     public Strin

Fix the problems with read the information of environment.json file