- policyData.setPolicyType("Config");
- policyData.setConfigPolicyType(parameters.getPolicyConfigType().toString());
-
- // Config Specific
- policyData.setConfigBodyData(parameters.getConfigBody()); // Base
- policyData.setConfigType((parameters.getConfigBodyType() != null)
- ? parameters.getConfigBodyType().toString().toUpperCase()
- : null); // Base
-
- if ("FW".equalsIgnoreCase(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("Firewall Config");
-
- // get values and attributes from the JsonObject
- if (json != null) {
- if (json.get("securityZoneId") != null) {
- String securityZone = json.get("securityZoneId").toString().replace("\"", "");
- policyData.setSecurityZone(securityZone);
- }
- if (json.get(CONFIG_NAME) != null) {
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- }
-
- } else if ("MS".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("Micro Service");
-
- // get values and attributes from the JsonObject
- if (json != null) {
- if (json.containsKey(CONTENT)) {
- String content = json.get(CONTENT).toString();
- ObjectMapper mapper = new ObjectMapper();
- JsonNode policyJson = null;
- try {
- policyJson = mapper.readTree(content);
- } catch (IOException e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON
- + parameters.getConfigBody();
- LOGGER.error(message, e);
- return null;
- }
- policyData.setPolicyJSON(policyJson);
- }
- if (json.containsKey(SERVICE)) {
- String serviceType = json.get(SERVICE).toString().replace("\"", "");
- policyData.setServiceType(serviceType);
- }
- if (json.containsKey("uuid")) {
- String uuid = json.get("uuid").toString().replace("\"", "");
- policyData.setUuid(uuid);
- }
- if (json.containsKey(LOCATION)) {
- String msLocation = json.get(LOCATION).toString().replace("\"", "");
- policyData.setLocation(msLocation);
- }
- if (json.containsKey(CONFIG_NAME)) {
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- if (json.containsKey(PRIORITY)) {
- String priority = json.get(PRIORITY).toString().replace("\"", "");
- policyData.setPriority(priority);
- }
- if (json.containsKey(VERSION)) {
- String version = json.get(VERSION).toString().replace("\"", "");
- policyData.setVersion(version);
- }
- if (json.containsKey(POLICYSCOPE)) {
- String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
- policyData.setPolicyScope(policyScope);
- }
- if (json.containsKey(RISKTYPE)) {
- String riskType = json.get(RISKTYPE).toString().replace("\"", "");
- policyData.setRiskType(riskType);
- }
- if (json.containsKey(RISKLEVEL)) {
- String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
- policyData.setRiskLevel(riskLevel);
- }
- if (json.containsKey(GUARD)) {
- String guard = json.get(GUARD).toString().replace("\"", "");
- policyData.setGuard(guard);
- }
- } else {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON + parameters.getConfigBody();
- LOGGER.error(message);
- return null;
- }
-
- } else if ("Optimization".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("Optimization");
-
- // get values and attributes from the JsonObject
- if (json != null) {
- if (json.containsKey(CONTENT)) {
- String content = json.get(CONTENT).toString();
- ObjectMapper mapper = new ObjectMapper();
- JsonNode policyJson = null;
- try {
- policyJson = mapper.readTree(content);
- } catch (IOException e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + INVALIDJSON
- + parameters.getConfigBody();
- LOGGER.error(message, e);
- return null;
- }
- policyData.setPolicyJSON(policyJson);
- }
- if (json.containsKey(SERVICE)) {
- String serviceType = json.get(SERVICE).toString().replace("\"", "");
- policyData.setServiceType(serviceType);
- }
- if (json.containsKey("uuid")) {
- String uuid = json.get("uuid").toString().replace("\"", "");
- policyData.setUuid(uuid);
- }
- if (json.containsKey(LOCATION)) {
- String msLocation = json.get(LOCATION).toString().replace("\"", "");
- policyData.setLocation(msLocation);
- }
- if (json.containsKey(CONFIG_NAME)) {
- String configName = json.get(CONFIG_NAME).toString().replace("\"", "");
- policyData.setConfigName(configName);
- }
- if (json.containsKey(PRIORITY)) {
- String priority = json.get(PRIORITY).toString().replace("\"", "");
- policyData.setPriority(priority);
- }
- if (json.containsKey(VERSION)) {
- String version = json.get(VERSION).toString().replace("\"", "");
- policyData.setVersion(version);
- }
- if (json.containsKey(POLICYSCOPE)) {
- String policyScope = json.get(POLICYSCOPE).toString().replace("\"", "");
- policyData.setPolicyScope(policyScope);
- }
- if (json.containsKey(RISKTYPE)) {
- String riskType = json.get(RISKTYPE).toString().replace("\"", "");
- policyData.setRiskType(riskType);
- }
- if (json.containsKey(RISKLEVEL)) {
- String riskLevel = json.get(RISKLEVEL).toString().replace("\"", "");
- policyData.setRiskLevel(riskLevel);
- }
- if (json.containsKey(GUARD)) {
- String guard = json.get(GUARD).toString().replace("\"", "");
- policyData.setGuard(guard);
- }
- }
-
- } else if ("Fault".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("ClosedLoop_Fault");
-
- if (json != null) {
- policyData.setJsonBody(json.toString());
- if (json.get(ONAPNAME) != null) {
- String onapName = json.get(ONAPNAME).toString().replace("\"", "");
- policyData.setOnapName(onapName);
- }
- }
-
- } else if ("PM".equals(parameters.getPolicyConfigType().toString())) {
-
- policyData.setConfigPolicyType("ClosedLoop_PM");
-
- if (json != null) {
- policyData.setJsonBody(json.toString());
- if (json.get(ONAPNAME) != null) {
- String onapName = json.get(ONAPNAME).toString().replace("\"", "");
- policyData.setOnapName(onapName);
- }
- if (json.get(SERVICETYPE_POLICY_NAME) != null) {
- String serviceType = json.get(SERVICETYPE_POLICY_NAME).toString().replace("\"", "");
- LinkedHashMap<String, String> serviceTypePolicyName = new LinkedHashMap<>();
- serviceTypePolicyName.put(SERVICETYPE_POLICY_NAME, serviceType);
- policyData.setServiceTypePolicyName(serviceTypePolicyName);
- }
- }
- } else if ("BRMS_Param".equals(parameters.getPolicyConfigType().toString())) {
- Map<AttributeType, Map<String, String>> drlRuleAndUiParams = parameters.getAttributes();
- Map<String, String> rule = drlRuleAndUiParams.get(AttributeType.RULE);
- policyData.setRuleName(rule.get("templateName"));