- protected void saveConfigurations(String policyName, String prevPolicyName, String jsonBody) {
- final Path gitPath = Paths.get(policyAdapter.getUserGitPath().toString());
- String policyDir = policyAdapter.getParentPath().toString();
- int startIndex = policyDir.indexOf(gitPath.toString()) + gitPath.toString().length() + 1;
- policyDir = policyDir.substring(startIndex, policyDir.length());
- logger.info("print the main domain value"+policyDir);
- String path = policyDir.replace('\\', '.');
- if(path.contains("/")){
- path = policyDir.replace('/', '.');
- logger.info("print the path:" +path);
- }
-
- try {
- String configFileName = getConfigFile(policyName);
-
- File file;
- if(CONFIG_HOME.contains("\\"))
- {
- file = new File(CONFIG_HOME + "\\" + path + "."+ configFileName);
- }
- else
- {
- file = new File(CONFIG_HOME + "/" + path + "."+ configFileName);
- }
-
- // if file doesnt exists, then create it
- if (!file.exists()) {
- file.createNewFile();
- }
-
- //Getting the previous policy Config Json file to be used for updating the dictionary tables
- if (policyAdapter.isEditPolicy()) {
-
- String prevConfigFileName = getConfigFile(prevPolicyName);
-
- File oldFile;
- if(CONFIG_HOME.contains("\\"))
- {
- oldFile = new File(CONFIG_HOME + "\\" + path + "."+ prevConfigFileName);
- }
- else
- {
- oldFile = new File(CONFIG_HOME + "/" + path + "."+ prevConfigFileName);
- }
-
- String filepath = oldFile.toString();
-
- String prevJsonBody = readFile(filepath, StandardCharsets.UTF_8);
- policyAdapter.setPrevJsonBody(prevJsonBody);