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;
    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;
    }

    /**
     * Initialize the properties of JSON Reader
     * and read the values of environment.json file
    */
    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");

    }

    /**
     * Return the getters and setters about values.
    */
    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;
    }
}
@@ -769,26 +769,69 @@
  String 
-api
+mongo
 Server;
+%0A    private static String mongoDataBase;
 %0A%0A    pr
@@ -2577,19 +2577,21 @@
         
-api
+mongo
 Server =
@@ -2652,11 +2652,15 @@
 d, %22
-API
+MongoDB
 %22, %22
@@ -2668,16 +2668,120 @@
 erver%22);
+%0A        mongoDataBase = jsonObjectMain.getKeyValue(%22Environments%22, %22id%22, envId, %22MongoDB%22, %22database%22);
 %0A%0A    %7D%0A
@@ -3597,11 +3597,13 @@
  get
-Api
+Mongo
 Serv
@@ -3628,17 +3628,95 @@
 urn 
-apiServer
+mongoServer;%0A    %7D%0A%0A    public String getMongoDataBase() %7B%0A        return mongoDataBase
 ;%0A  

Add the Attributes and Methods for MongoDB in the environment.json file