@SuppressWarnings("unchecked")
	public static void onDeployMSRules(JSONObject json){
		
		log.info("onDeployMSRules called.. : " + json.toJSONString());
		
		MSConfig serviceCfg = MSConfig.getInstance();
		JSONObject jsonResp= new JSONObject();
		
		String ruleDirPath = serviceCfg.getConfigMap().get("RuleFileDir");
    	String ruleFileString = (String) json.get("ruleString");
    	String ruleFileName = "";
    	
    	InputStream ins = null;
		FileOutputStream out = null;
		BufferedReader br = null;
		
		if(json.containsKey("groupName")){
			
			ruleFileName += ((String)json.get("groupName")).toLowerCase() + ".conf";
			
		} else{
			
			 UUID randomName = UUID.randomUUID();
			 ruleFileName += randomName.toString() + ".conf";
			 
		}
		
		try {
			
			//modified string writing to modsecurity configurations
			log.info("Writing a rule to File :" + ruleFileName);
			File file = new File(ruleDirPath + "/" + ruleFileName);
			file.createNewFile();
			out = new FileOutputStream(file);
			out.write(ruleFileString.getBytes());
			out.close();
			
			log.info("ModSecurity Rules Written ... ");
			
			//For Restarting modsecurity so that modified configuration can be applied
			JSONObject restartJson = new JSONObject();
			restartJson.put("action", "restart");
			
			String cmd = serviceCfg.getConfigMap().get("MSRestart"); 
			
			String status = (String)executeShScript(cmd, restartJson).get("status");
			
			//if rule file is giving syntax error while deploying rules on server end 
			if(status.equals("1")){
				
				if(file.delete()){
					log.info("Successfully deleted conflicting file : " + file.getName());
					executeShScript(cmd, restartJson);
				} else {
					log.info("unable to delete file : " + file.getName());
				}
				jsonResp.put("action", "deployRules");
				jsonResp.put("status", "1");
				jsonResp.put("message", "Unable to deploy specified Rules. They either" +
						"conflicting to the already deployed rules");
			
			} else {
				
				jsonResp.put("action", "deployRules");
				jsonResp.put("status", "0");
				jsonResp.put("message", "Rules Deployed!");
			
			}
			
			
		} catch (FileNotFoundException e1) {
			
			jsonResp.put("action", "deployRules");
			jsonResp.put("status", "1");
			jsonResp.put("message", "Internal Service is down!");
			e1.printStackTrace();
			
		} catch(IOException | NullPointerException e){
			
			jsonResp.put("action", "deployRules");
			jsonResp.put("status", "0");
			jsonResp.put("message", "Unable to create rule file on Server.");
			e.printStackTrace();
			
		}
		
		log.info("Sending Json :" + jsonResp.toJSONString());
		ConnectorService.getConnectorProducer().send(jsonResp.toJSONString());
		jsonResp.clear();
	}