2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Bell Canada
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controller;
24 import com.fasterxml.jackson.databind.DeserializationFeature;
25 import com.fasterxml.jackson.databind.JsonNode;
26 import com.fasterxml.jackson.databind.ObjectMapper;
28 import java.io.UnsupportedEncodingException;
29 import java.net.URLEncoder;
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.Collection;
33 import java.util.LinkedHashMap;
34 import java.util.List;
36 import java.util.Objects;
37 import java.util.stream.IntStream;
40 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
41 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
42 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
43 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
44 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
45 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
47 import org.onap.policy.common.logging.flexlogger.FlexLogger;
48 import org.onap.policy.common.logging.flexlogger.Logger;
49 import org.onap.policy.rest.adapter.ClosedLoopFaultBody;
50 import org.onap.policy.rest.adapter.ClosedLoopFaultTrapDatas;
51 import org.onap.policy.rest.adapter.ClosedLoopFaultTriggerUISignatures;
52 import org.onap.policy.rest.adapter.ClosedLoopSignatures;
53 import org.onap.policy.rest.adapter.PolicyRestAdapter;
54 import org.onap.policy.rest.dao.CommonClassDao;
55 import org.onap.policy.rest.jpa.OnapName;
56 import org.onap.policy.rest.jpa.PolicyEntity;
57 import org.onap.policy.rest.jpa.VarbindDictionary;
58 import org.onap.portalsdk.core.controller.RestrictedBaseController;
59 import org.springframework.beans.factory.annotation.Autowired;
60 import org.springframework.stereotype.Controller;
61 import org.springframework.web.bind.annotation.RequestMapping;
65 public class CreateClosedLoopFaultController extends RestrictedBaseController {
67 private static final Logger policyLogger = FlexLogger.getLogger(CreateClosedLoopFaultController.class);
68 private static final String FAULT = "Fault";
69 private static final String TRAP = "Trap";
70 private static final String NOT_BOX = "notBox";
71 private static final String OPERATOR_BOX = "operatorBox";
72 private static final String CONNECT_TRAP_1 = "connectTrap1";
73 private static final String TRAP_COUNT_1 = "trapCount1";
74 private static final String CONNECT_TRAP_2 = "connectTrap2";
75 private static final String TRAP_COUNT_2 = "trapCount2";
76 private static final String TRIGGER_1 = "trigger1";
77 private static final String ENC_UTF_8 = "UTF-8";
78 private static final String TRIGGER_2 = "trigger2";
80 protected PolicyRestAdapter policyAdapter = null;
82 private static CommonClassDao commonclassdao;
85 private CreateClosedLoopFaultController(CommonClassDao commonclassdao) {
86 CreateClosedLoopFaultController.commonclassdao = commonclassdao;
89 public CreateClosedLoopFaultController() {
94 * setDataToPolicyRestAdapter.
96 * @param policyData PolicyRestAdapter
97 * @param root JsonNode
98 * @return PolicyRestAdapter
100 public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) {
102 ObjectMapper mapper = new ObjectMapper();
103 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
104 final ClosedLoopFaultTrapDatas trapDatas =
105 mapper.readValue(root.get("trapData").toString(), ClosedLoopFaultTrapDatas.class);
106 final ClosedLoopFaultTrapDatas faultDatas =
107 mapper.readValue(root.get("faultData").toString(), ClosedLoopFaultTrapDatas.class);
108 final ClosedLoopGridJsonData policyJsonData =
109 mapper.readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJsonData.class);
110 final ClosedLoopFaultBody jsonBody = mapper.readValue(
111 root.get("policyData").get("policy").get("jsonBodyData").toString(), ClosedLoopFaultBody.class);
113 // Build trapSignatureDatas list from faultData
114 List<Object> trapSignatureDatas = new ArrayList<>();
115 if (trapDatas.getTrap1() != null) {
116 trapSignatureDatas.add(trapDatas);
118 // Extract resultBody and set jsonBody with trap ClosedLoopSignatures
119 String resultBody = getResultBody(policyJsonData, trapSignatureDatas);
120 ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures();
121 triggerSignatures.setSignatures(resultBody);
122 if (policyData.getClearTimeOut() != null) {
123 triggerSignatures.setTimeWindow(Integer.parseInt(policyData.getClearTimeOut()));
124 triggerSignatures.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
125 ClosedLoopFaultTriggerUISignatures uiTriggerSignatures = new ClosedLoopFaultTriggerUISignatures();
126 if (!trapSignatureDatas.isEmpty()) {
127 uiTriggerSignatures.setSignatures(getUiTriggerSignature(TRAP, trapSignatureDatas.get(0)));
128 if (!policyJsonData.getConnecttriggerSignatures().isEmpty()) {
130 .setConnectSignatures(getUiConnectTraps(policyJsonData.getConnecttriggerSignatures()));
133 jsonBody.setTriggerSignaturesUsedForUI(uiTriggerSignatures);
134 jsonBody.setTriggerTimeWindowUsedForUI(Integer.parseInt(policyData.getClearTimeOut()));
135 jsonBody.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
138 jsonBody.setTriggerSignatures(triggerSignatures);
140 // Build faultSignatureData list from faultData
141 List<Object> faultSignatureDatas = new ArrayList<>();
142 if (faultDatas.getTrap1() != null) {
143 faultSignatureDatas.add(faultDatas);
145 // Extract faultBody and set jsonBody with fault ClosedLoopSignatures
146 String faultBody = getFaultBody(policyJsonData, faultSignatureDatas);
147 ClosedLoopSignatures faultSignatures = new ClosedLoopSignatures();
148 faultSignatures.setSignatures(faultBody);
149 if (policyData.getVerificationclearTimeOut() != null) {
150 faultSignatures.setTimeWindow(Integer.parseInt(policyData.getVerificationclearTimeOut()));
151 ClosedLoopFaultTriggerUISignatures uifaultSignatures = new ClosedLoopFaultTriggerUISignatures();
152 if (!faultSignatureDatas.isEmpty()) {
153 uifaultSignatures.setSignatures(getUiTriggerSignature(FAULT, faultSignatureDatas.get(0)));
154 if (!policyJsonData.getConnectVerificationSignatures().isEmpty()) {
155 uifaultSignatures.setConnectSignatures(
156 getUiConnectTraps(policyJsonData.getConnectVerificationSignatures()));
159 jsonBody.setVerificationSignaturesUsedForUI(uifaultSignatures);
160 jsonBody.setVerificationTimeWindowUsedForUI(Integer.parseInt(policyData.getVerificationclearTimeOut()));
162 jsonBody.setVerificationSignatures(faultSignatures);
163 policyData.setJsonBody(new ObjectMapper().writer().writeValueAsString(jsonBody));
165 } catch (Exception e) {
166 policyLogger.error("Exception Occured while setting data to Adapter", e);
171 // TODO: Can getResultBody() and getFaultBody() be merged?
172 private String getResultBody(final ClosedLoopGridJsonData policyJsonData, final List<Object> trapSignatureDatas) {
173 StringBuilder resultBody = new StringBuilder();
174 if (!policyJsonData.getConnecttriggerSignatures().isEmpty()) {
175 resultBody.append("(");
176 IntStream.range(0, policyJsonData.getConnecttriggerSignatures().size())
177 .mapToObj(i -> connectTriggerSignature(i, policyJsonData.getConnecttriggerSignatures(),
178 trapSignatureDatas.get(0)))
179 .forEach(resultBody::append);
180 resultBody.append(resultBody).append(")");
182 if (!trapSignatureDatas.isEmpty()) {
183 resultBody.append(callTrap("nill", trapSignatureDatas.get(0)));
186 return resultBody.toString();
189 private String getFaultBody(final ClosedLoopGridJsonData policyJsonData, final List<Object> faultSignatureDatas) {
190 StringBuilder faultBody = new StringBuilder();
191 if (!policyJsonData.getConnectVerificationSignatures().isEmpty()) {
192 faultBody.append("(");
193 IntStream.range(0, policyJsonData.getConnectVerificationSignatures().size())
194 .mapToObj(i -> connectTriggerSignature(i, policyJsonData.getConnectVerificationSignatures(),
195 faultSignatureDatas.get(0)))
196 .forEach(faultBody::append);
197 faultBody.append(")");
199 if (!faultSignatureDatas.isEmpty()) {
200 faultBody.append(callTrap("nill", faultSignatureDatas.get(0)));
203 return faultBody.toString();
206 @SuppressWarnings("unchecked")
207 private String connectTriggerSignature(int index, List<Object> triggerSignatures, Object object) {
208 StringBuilder resultBody = new StringBuilder();
209 Map<String, String> connectTraps = (Map<String, String>) triggerSignatures.get(index);
212 if (connectTraps.keySet().contains(NOT_BOX)) {
213 notBox = connectTraps.get(NOT_BOX);
215 resultBody.append("(").append(notBox);
216 } catch (NullPointerException e) {
217 policyLogger.info("General error", e);
218 resultBody.append("(");
222 // Append connectTrap1 body to resultBody
223 appendTrapToResultBody(triggerSignatures, object, resultBody, connectTraps, CONNECT_TRAP_1);
225 // Update trap1 count to resultBody
226 String trapCount1 = connectTraps.get(TRAP_COUNT_1);
227 resultBody.append(", Time = ").append(trapCount1).append(")");
229 // Append connectTrap2 body to resultBody
230 appendTrapToResultBody(triggerSignatures, object, resultBody, connectTraps, CONNECT_TRAP_2);
232 // Update operatorBox to resultBody
233 String operatorBox = connectTraps.get(OPERATOR_BOX);
234 resultBody.append(operatorBox).append("(");
236 // Update trap2 count to resultBody
237 String trapCount2 = connectTraps.get(TRAP_COUNT_2);
238 resultBody.append(", Time = ").append(trapCount2).append(")");
239 } catch (NullPointerException e) {
240 policyLogger.info("General error", e);
242 return resultBody.toString();
245 private void appendTrapToResultBody(List<Object> triggerSignatures, Object object, StringBuilder resultBody,
246 Map<String, String> connectTraps, String connectTrapName) {
247 String connectTrap = connectTraps.get(connectTrapName);
248 if (connectTrap.startsWith(TRAP) || connectTrap.startsWith(FAULT)) {
249 String trapBody = callTrap(connectTrap, object);
250 resultBody.append(trapBody);
251 } else if (connectTrap.startsWith("C")) {
252 for (int i = 0; i <= triggerSignatures.size(); i++) {
253 Map<String, String> triggerSignature = (Map<String, String>) triggerSignatures.get(i);
254 if (triggerSignature.get("id").equals(connectTrap)) {
255 resultBody.append("(");
256 String connectBody = connectTriggerSignature(i, triggerSignatures, object);
257 resultBody.append(connectBody).append(")");
258 } else { // FIXME: Is this a bug and can it be removed?
265 private String callTrap(String trap, Object object) {
266 String signatureBody = "";
267 ClosedLoopFaultTrapDatas trapDatas = (ClosedLoopFaultTrapDatas) object;
268 List<Object> attributeList = new ArrayList<>();
270 if (!"nill".equals(trap)) {
271 List<String> trapTypes = new ArrayList<>();
272 if (trap.startsWith(TRAP)) {
273 trapTypes = Arrays.asList("Trap1", "Trap2", "Trap3", "Trap4", "Trap5", "Trap6");
274 } else if (trap.startsWith(FAULT)) {
275 trapTypes = Arrays.asList("Fault1", "Fault2", "Fault3", "Fault4", "Fault5", "Fault6");
278 if (trapTypes.get(0).equals(trap)) {
279 attributeList = trapDatas.getTrap1();
280 } else if (trapTypes.get(1).equals(trap)) {
281 attributeList = trapDatas.getTrap2();
282 } else if (trapTypes.get(2).equals(trap)) {
283 attributeList = trapDatas.getTrap3();
284 } else if (trapTypes.get(3).equals(trap)) {
285 attributeList = trapDatas.getTrap4();
286 } else if (trapTypes.get(4).equals(trap)) {
287 attributeList = trapDatas.getTrap5();
288 } else if (trapTypes.get(5).equals(trap)) {
289 attributeList = trapDatas.getTrap6();
291 } catch (Exception e) {
292 policyLogger.warn("Error during callTrap", e);
293 return "(" + trap + ")";
296 if (trapDatas.getTrap1() == null) {
299 attributeList = trapDatas.getTrap1();
301 signatureBody = signatureBody + "(" + readAttributes(attributeList, attributeList.size() - 1) + ")";
302 return signatureBody;
305 @SuppressWarnings("unchecked")
306 private String readAttributes(List<Object> object, int index) {
307 String attributes = "";
308 Map<String, String> trapSignatures = (Map<String, String>) object.get(index);
309 // Read the Elements.
311 if (trapSignatures.keySet().contains(NOT_BOX)) {
312 notBox = trapSignatures.get(NOT_BOX);
314 if (notBox != null) {
315 attributes = attributes + notBox.toString();
318 // Get Attributes for trap1 name
319 Object trapName1 = trapSignatures.get(TRIGGER_1);
320 if (trapName1 == null) {
323 attributes = getTrapAttributesString(object, attributes, trapName1);
325 Object comboBox = trapSignatures.get(OPERATOR_BOX);
326 if (comboBox != null) {
327 attributes = attributes + comboBox.toString();
332 // Get Attributes for trap1 name
333 Object trapName2 = trapSignatures.get(TRIGGER_2);
334 if (trapName2 != null) {
335 attributes = getTrapAttributesString(object, attributes, trapName2);
340 private String getTrapAttributesString(List<Object> objectList, String attributesStr, Object trapName) {
341 String trap1Attrib = trapName.toString();
342 if (trap1Attrib.startsWith("A")) {
344 int iy = Integer.parseInt(trap1Attrib.substring(1)) - 1;
345 attributesStr = attributesStr + "(" + readAttributes(objectList, iy) + ")";
346 } catch (NumberFormatException e) {
348 trap1Attrib = getVarbindOid(trap1Attrib);
349 attributesStr = attributesStr + "(" + URLEncoder.encode(trap1Attrib, ENC_UTF_8) + ")";
350 } catch (UnsupportedEncodingException e1) {
351 policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values", e1);
356 trap1Attrib = getVarbindOid(trap1Attrib);
357 attributesStr = attributesStr + "(" + URLEncoder.encode(trap1Attrib, ENC_UTF_8) + ")";
358 } catch (UnsupportedEncodingException e) {
359 policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values", e);
362 return attributesStr;
365 private String getVarbindOid(String attrib) {
366 VarbindDictionary varbindId;
369 (VarbindDictionary) commonclassdao.getEntityItem(VarbindDictionary.class, "varbindName", attrib);
370 return varbindId.getVarbindOID();
371 } catch (Exception e) {
372 policyLogger.error("Error during retrieving varbindName " + attrib, e);
377 // connect traps data set to JSON Body as String
378 @SuppressWarnings({"unchecked", "rawtypes"})
379 private String getUiConnectTraps(List<Object> connectTrapSignatures) {
380 StringBuilder resultBody = new StringBuilder();
381 String connectMainBody = "";
382 for (Object connectTrapSignature : connectTrapSignatures) {
383 Map<String, String> connectTraps = (Map<String, String>) connectTrapSignature;
384 String connectBody = "";
385 if (connectTraps instanceof LinkedHashMap<?, ?>) {
387 String connectTrap1 = "";
388 String trapCount1 = "";
389 String operatorBox = "";
390 String connectTrap2 = "";
391 String trapCount2 = "";
392 if (((LinkedHashMap) connectTraps).keySet().contains(NOT_BOX)) {
393 notBox = ((LinkedHashMap) connectTraps).get(NOT_BOX).toString();
395 if (((LinkedHashMap) connectTraps).get(CONNECT_TRAP_1) != null) {
396 connectTrap1 = ((LinkedHashMap) connectTraps).get(CONNECT_TRAP_1).toString();
398 if (((LinkedHashMap) connectTraps).get(TRAP_COUNT_1) != null) {
399 trapCount1 = ((LinkedHashMap) connectTraps).get(TRAP_COUNT_1).toString();
401 if (((LinkedHashMap) connectTraps).get(OPERATOR_BOX) != null) {
402 operatorBox = ((LinkedHashMap) connectTraps).get(OPERATOR_BOX).toString();
404 if (((LinkedHashMap) connectTraps).get(CONNECT_TRAP_2) != null) {
405 connectTrap2 = ((LinkedHashMap) connectTraps).get(CONNECT_TRAP_2).toString();
407 if (((LinkedHashMap) connectTraps).get(TRAP_COUNT_2) != null) {
408 trapCount2 = ((LinkedHashMap) connectTraps).get(TRAP_COUNT_2).toString();
410 connectBody = notBox + "@!" + connectTrap1 + "@!" + trapCount1 + "@!" + operatorBox + "@!"
411 + connectTrap2 + "@!" + trapCount2 + "#!?!";
413 resultBody.append(connectBody);
415 connectMainBody = connectMainBody + resultBody;
416 return connectMainBody;
419 // get Trigger signature from JSON body
420 private String getUiTriggerSignature(String trap, Object object2) {
421 ClosedLoopFaultTrapDatas trapDatas = (ClosedLoopFaultTrapDatas) object2;
422 List<Object> attributeList = new ArrayList<>();
424 if (trap.startsWith(TRAP) || trap.startsWith(FAULT)) {
425 if (trapDatas.getTrap1() != null) {
426 attributeList.add(trapDatas.getTrap1());
428 if (trapDatas.getTrap2() != null) {
429 attributeList.add(trapDatas.getTrap2());
431 if (trapDatas.getTrap3() != null) {
432 attributeList.add(trapDatas.getTrap3());
434 if (trapDatas.getTrap4() != null) {
435 attributeList.add(trapDatas.getTrap4());
437 if (trapDatas.getTrap5() != null) {
438 attributeList.add(trapDatas.getTrap5());
440 if (trapDatas.getTrap6() != null) {
441 attributeList.add(trapDatas.getTrap6());
444 return getTriggerBody(attributeList);
447 @SuppressWarnings({"rawtypes", "unchecked"})
448 private String getTriggerBody(final List<Object> attributeList) {
449 StringBuilder triggerBody = new StringBuilder();
450 for (Object o : attributeList) {
451 StringBuilder signatureBody = new StringBuilder();
452 List<Object> connectTraps = (ArrayList<Object>) o;
453 for (Object connectTrap : connectTraps) {
454 String connectBody = "";
455 if (connectTrap instanceof LinkedHashMap<?, ?>) {
457 String trigger1 = "";
458 String operatorBox = "";
459 String trigger2 = "";
460 if (((LinkedHashMap) connectTrap).keySet().contains(NOT_BOX)) {
461 notBox = ((LinkedHashMap) connectTrap).get(NOT_BOX).toString();
463 if (((LinkedHashMap) connectTrap).get(TRIGGER_1) != null) {
464 trigger1 = ((LinkedHashMap) connectTrap).get(TRIGGER_1).toString();
466 if (((LinkedHashMap) connectTrap).get(OPERATOR_BOX) != null) {
467 operatorBox = ((LinkedHashMap) connectTrap).get(OPERATOR_BOX).toString();
469 if (((LinkedHashMap) connectTrap).get(TRIGGER_2) != null) {
470 trigger2 = ((LinkedHashMap) connectTrap).get(TRIGGER_2).toString();
472 connectBody = notBox + "@!" + trigger1 + "@!" + operatorBox + "@!" + trigger2 + "#!";
474 signatureBody.append(connectBody);
476 triggerBody.append(signatureBody).append("?!");
478 return triggerBody.toString();
482 * prePopulateClosedLoopFaultPolicyData.
484 * @param policyAdapter PolicyRestAdapter
485 * @param entity PolicyEntity
487 public void prePopulateClosedLoopFaultPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
488 if (policyAdapter.getPolicyData() instanceof PolicyType) {
489 PolicyType policy = (PolicyType) policyAdapter.getPolicyData();
491 // Set PolicyAdapter policyName, description
492 setPolicyAdapterPolicyNameAndDescription(policyAdapter, policy);
494 // Set PolicyAdapter JsonBodyData, timeout settings
495 setClosedLoopJsonFile(policyAdapter, entity);
497 // Get the target data under policy.
498 TargetType target = policy.getTarget();
499 if (target == null) {
503 // Under target we have AnyOFType
504 List<AnyOfType> anyOfList = target.getAnyOf();
505 if (anyOfList == null) {
509 // Set PolicyAdapter OnapNameField, riskType, riskLevel, guard, ttlDate from match attributes
510 setPolicyAdapterMatchAttributes(policyAdapter, anyOfList);
514 private void setPolicyAdapterMatchAttributes(PolicyRestAdapter policyAdapter, List<AnyOfType> anyOfList) {
516 // Extract nonNull list of AllOfType objs from each AnyOfType obj
517 .map(AnyOfType::getAllOf).filter(Objects::nonNull).forEach(allOfList ->
518 // Extract nonNull list of MatchType objs from each AllOFType obj
519 allOfList.stream().map(AllOfType::getMatch).filter(Objects::nonNull).flatMap(Collection::stream)
521 // Under the match we have attribute value and
522 // attributeDesignator. So,finally down to the actual attribute.
523 AttributeValueType attributeValue = match.getAttributeValue();
524 String value = (String) attributeValue.getContent().get(0);
525 AttributeDesignatorType designator = match.getAttributeDesignator();
526 String attributeId = designator.getAttributeId();
527 // First match in the target is OnapName, so set that value.
528 if ("ONAPName".equals(attributeId)) {
529 policyAdapter.setOnapName(value);
530 OnapName onapName = new OnapName();
531 onapName.setOnapName(value);
532 policyAdapter.setOnapNameField(onapName);
533 } else if ("RiskType".equals(attributeId)) {
534 policyAdapter.setRiskType(value);
535 } else if ("RiskLevel".equals(attributeId)) {
536 policyAdapter.setRiskLevel(value);
537 } else if ("guard".equals(attributeId)) {
538 policyAdapter.setGuard(value);
539 } else if ("TTLDate".equals(attributeId) && !value.contains("NA")) {
540 PolicyController controller = new PolicyController();
541 String newDate = controller.convertDate(value);
542 policyAdapter.setTtlDate(newDate);
547 private void setPolicyAdapterPolicyNameAndDescription(PolicyRestAdapter policyAdapter, PolicyType policy) {
548 policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
549 String policyNameValue =
550 policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf("Fault_") + 6);
551 policyAdapter.setPolicyName(policyNameValue);
554 description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
555 } catch (Exception e) {
557 "Error during collecting the description tag info for createClosedLoopFault " + policyNameValue, e);
558 description = policy.getDescription();
560 policyAdapter.setPolicyDescription(description);
563 private void setClosedLoopJsonFile(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
565 ClosedLoopFaultBody closedLoopBody =
566 new ObjectMapper().readValue(entity.getConfigurationData().getConfigBody(),
567 ClosedLoopFaultBody.class);
568 if ("ACTIVE".equalsIgnoreCase(closedLoopBody.getClosedLoopPolicyStatus())) {
569 closedLoopBody.setClosedLoopPolicyStatus("Active");
571 closedLoopBody.setClosedLoopPolicyStatus("InActive");
573 policyAdapter.setJsonBodyData(closedLoopBody);
574 if (closedLoopBody.getTrapMaxAge() != null) {
575 policyAdapter.setTrapMaxAge(closedLoopBody.getTrapMaxAge().toString());
577 if (closedLoopBody.getTriggerTimeWindowUsedForUI() != null) {
578 policyAdapter.setClearTimeOut(closedLoopBody.getTriggerTimeWindowUsedForUI().toString());
580 if (closedLoopBody.getVerificationTimeWindowUsedForUI() != null) {
582 .setVerificationclearTimeOut(closedLoopBody.getVerificationTimeWindowUsedForUI().toString());
584 } catch (Exception e) {
585 policyLogger.error("Exception Occured" + e);
593 class ClosedLoopGridJsonData {
595 private String clearTimeOut;
596 private String trapMaxAge;
597 private String verificationclearTimeOut;
598 private List<Object> connecttriggerSignatures;
599 private List<Object> connectVerificationSignatures;