2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 java.io.UnsupportedEncodingException;
25 import java.net.URLEncoder;
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.Collection;
29 import java.util.LinkedHashMap;
30 import java.util.List;
33 import java.util.Objects;
34 import java.util.stream.IntStream;
35 import org.onap.policy.common.logging.flexlogger.FlexLogger;
36 import org.onap.policy.common.logging.flexlogger.Logger;
37 import org.onap.policy.rest.adapter.ClosedLoopFaultBody;
38 import org.onap.policy.rest.adapter.ClosedLoopFaultTrapDatas;
39 import org.onap.policy.rest.adapter.ClosedLoopFaultTriggerUISignatures;
40 import org.onap.policy.rest.adapter.ClosedLoopSignatures;
41 import org.onap.policy.rest.adapter.PolicyRestAdapter;
42 import org.onap.policy.rest.dao.CommonClassDao;
43 import org.onap.policy.rest.jpa.OnapName;
44 import org.onap.policy.rest.jpa.PolicyEntity;
45 import org.onap.policy.rest.jpa.VarbindDictionary;
46 import org.onap.portalsdk.core.controller.RestrictedBaseController;
47 import org.springframework.beans.factory.annotation.Autowired;
48 import org.springframework.stereotype.Controller;
49 import org.springframework.web.bind.annotation.RequestMapping;
51 import com.fasterxml.jackson.databind.DeserializationFeature;
52 import com.fasterxml.jackson.databind.JsonNode;
53 import com.fasterxml.jackson.databind.ObjectMapper;
54 import com.fasterxml.jackson.databind.ObjectWriter;
56 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
57 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
58 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
59 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
60 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
61 import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
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() {
93 public PolicyRestAdapter setDataToPolicyRestAdapter(PolicyRestAdapter policyData, JsonNode root) {
95 ObjectMapper mapper = new ObjectMapper();
96 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
97 ClosedLoopFaultTrapDatas trapDatas = mapper
98 .readValue(root.get("trapData").toString(), ClosedLoopFaultTrapDatas.class);
99 ClosedLoopFaultTrapDatas faultDatas = mapper
100 .readValue(root.get("faultData").toString(), ClosedLoopFaultTrapDatas.class);
101 ClosedLoopGridJSONData policyJsonData = mapper
102 .readValue(root.get("policyData").get("policy").toString(), ClosedLoopGridJSONData.class);
103 ClosedLoopFaultBody jsonBody = mapper
104 .readValue(root.get("policyData").get("policy").get("jsonBodyData").toString(),
105 ClosedLoopFaultBody.class);
107 // Build trapSignatureDatas list from faultData
108 List<Object> trapSignatureDatas = new ArrayList<>();
109 if (trapDatas.getTrap1() != null) {
110 trapSignatureDatas.add(trapDatas);
112 // Extract resultBody and set jsonBody with trap ClosedLoopSignatures
113 String resultBody = getResultBody(policyJsonData, trapSignatureDatas);
114 ClosedLoopSignatures triggerSignatures = new ClosedLoopSignatures();
115 triggerSignatures.setSignatures(resultBody);
116 if (policyData.getClearTimeOut() != null) {
117 triggerSignatures.setTimeWindow(Integer.parseInt(policyData.getClearTimeOut()));
118 triggerSignatures.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
119 ClosedLoopFaultTriggerUISignatures uiTriggerSignatures = new ClosedLoopFaultTriggerUISignatures();
120 if (!trapSignatureDatas.isEmpty()) {
121 uiTriggerSignatures.setSignatures(getUITriggerSignature(TRAP, trapSignatureDatas.get(0)));
122 if (!policyJsonData.getConnecttriggerSignatures().isEmpty()) {
124 .setConnectSignatures(getUIConnectTraps(policyJsonData.getConnecttriggerSignatures()));
127 jsonBody.setTriggerSignaturesUsedForUI(uiTriggerSignatures);
128 jsonBody.setTriggerTimeWindowUsedForUI(Integer.parseInt(policyData.getClearTimeOut()));
129 jsonBody.setTrapMaxAge(Integer.parseInt(policyData.getTrapMaxAge()));
132 jsonBody.setTriggerSignatures(triggerSignatures);
134 // Build faultSignatureData list from faultData
135 List<Object> faultSignatureDatas = new ArrayList<>();
136 if (faultDatas.getTrap1() != null) {
137 faultSignatureDatas.add(faultDatas);
139 // Extract faultBody and set jsonBody with fault ClosedLoopSignatures
140 String faultBody = getFaultBody(policyJsonData, faultSignatureDatas);
141 ClosedLoopSignatures faultSignatures = new ClosedLoopSignatures();
142 faultSignatures.setSignatures(faultBody);
143 if (policyData.getVerificationclearTimeOut() != null) {
144 faultSignatures.setTimeWindow(Integer.parseInt(policyData.getVerificationclearTimeOut()));
145 ClosedLoopFaultTriggerUISignatures uifaultSignatures = new ClosedLoopFaultTriggerUISignatures();
146 if (!faultSignatureDatas.isEmpty()) {
147 uifaultSignatures.setSignatures(getUITriggerSignature(FAULT, faultSignatureDatas.get(0)));
148 if (!policyJsonData.getConnectVerificationSignatures().isEmpty()) {
150 .setConnectSignatures(getUIConnectTraps(policyJsonData.getConnectVerificationSignatures()));
153 jsonBody.setVerificationSignaturesUsedForUI(uifaultSignatures);
154 jsonBody.setVerificationTimeWindowUsedForUI(Integer.parseInt(policyData.getVerificationclearTimeOut()));
156 jsonBody.setVerificationSignatures(faultSignatures);
157 ObjectWriter om = new ObjectMapper().writer();
158 String json = om.writeValueAsString(jsonBody);
159 policyData.setJsonBody(json);
161 } catch (Exception e) {
162 policyLogger.error("Exception Occured while setting data to Adapter", e);
167 // TODO: Can getResultBody() and getFaultBody() be merged?
168 private String getResultBody(final ClosedLoopGridJSONData policyJsonData, final List<Object> trapSignatureDatas) {
169 StringBuilder resultBody = new StringBuilder();
170 if (!policyJsonData.getConnecttriggerSignatures().isEmpty()) {
171 resultBody.append("(");
172 IntStream.range(0, policyJsonData.getConnecttriggerSignatures().size())
173 .mapToObj(i -> connectTriggerSignature(i, policyJsonData.getConnecttriggerSignatures(),
174 trapSignatureDatas.get(0))).forEach(resultBody::append);
175 resultBody.append(resultBody).append(")");
177 if (!trapSignatureDatas.isEmpty()) {
178 resultBody.append(callTrap("nill", trapSignatureDatas.get(0)));
181 return resultBody.toString();
184 private String getFaultBody(final ClosedLoopGridJSONData policyJsonData, final List<Object> faultSignatureDatas) {
185 StringBuilder faultBody = new StringBuilder();
186 if (!policyJsonData.getConnectVerificationSignatures().isEmpty()) {
187 faultBody.append("(");
188 IntStream.range(0, policyJsonData.getConnectVerificationSignatures().size())
189 .mapToObj(i -> connectTriggerSignature(i, policyJsonData.getConnectVerificationSignatures(),
190 faultSignatureDatas.get(0))).forEach(faultBody::append);
191 faultBody.append(")");
193 if (!faultSignatureDatas.isEmpty()) {
194 faultBody.append(callTrap("nill", faultSignatureDatas.get(0)));
197 return faultBody.toString();
200 @SuppressWarnings("unchecked")
201 private String connectTriggerSignature(int index, List<Object> triggerSignatures, Object object) {
202 StringBuilder resultBody = new StringBuilder();
203 Map<String, String> connectTraps = (Map<String, String>) triggerSignatures.get(index);
206 if (connectTraps.keySet().contains(NOT_BOX)) {
207 notBox = connectTraps.get(NOT_BOX);
209 resultBody.append("(").append(notBox);
210 } catch (NullPointerException e) {
211 policyLogger.info("General error", e);
212 resultBody.append("(");
216 // Append connectTrap1 body to resultBody
217 appendTrapToResultBody(triggerSignatures, object, resultBody, connectTraps, CONNECT_TRAP_1);
219 // Update trap1 count to resultBody
220 String trapCount1 = connectTraps.get(TRAP_COUNT_1);
221 resultBody.append(", Time = ").append(trapCount1).append(")");
223 // Append connectTrap2 body to resultBody
224 appendTrapToResultBody(triggerSignatures, object, resultBody, connectTraps, CONNECT_TRAP_2);
226 // Update operatorBox to resultBody
227 String operatorBox = connectTraps.get(OPERATOR_BOX);
228 resultBody.append(operatorBox).append("(");
230 // Update trap2 count to resultBody
231 String trapCount2 = connectTraps.get(TRAP_COUNT_2);
232 resultBody.append(", Time = ").append(trapCount2).append(")");
233 } catch (NullPointerException e) {
234 policyLogger.info("General error", e);
236 return resultBody.toString();
239 private void appendTrapToResultBody(List<Object> triggerSignatures, Object object, StringBuilder resultBody,
240 Map<String, String> connectTraps, String connectTrapName) {
241 String connectTrap = connectTraps.get(connectTrapName);
242 if (connectTrap.startsWith(TRAP) || connectTrap.startsWith(FAULT)) {
243 String trapBody = callTrap(connectTrap, object);
244 resultBody.append(trapBody);
245 } else if (connectTrap.startsWith("C")) {
246 for (int i = 0; i <= triggerSignatures.size(); i++) {
247 Map<String, String> triggerSignature = (Map<String, String>) triggerSignatures.get(i);
248 if (triggerSignature.get("id").equals(connectTrap)) {
249 resultBody.append("(");
250 String connectBody = connectTriggerSignature(i, triggerSignatures, object);
251 resultBody.append(connectBody).append(")");
252 } else { // FIXME: Is this a bug and can it be removed?
259 private String callTrap(String trap, Object object) {
260 String signatureBody = "";
261 ClosedLoopFaultTrapDatas trapDatas = (ClosedLoopFaultTrapDatas) object;
262 List<Object> attributeList = new ArrayList<>();
264 if (!"nill".equals(trap)) {
265 List<String> trapTypes = new ArrayList<>();
266 if (trap.startsWith(TRAP)) {
267 trapTypes = Arrays.asList("Trap1", "Trap2", "Trap3", "Trap4", "Trap5", "Trap6");
268 } else if (trap.startsWith(FAULT)) {
269 trapTypes = Arrays.asList("Fault1", "Fault2", "Fault3", "Fault4", "Fault5", "Fault6");
272 if (trapTypes.get(0).equals(trap)) {
273 attributeList = trapDatas.getTrap1();
274 } else if (trapTypes.get(1).equals(trap)) {
275 attributeList = trapDatas.getTrap2();
276 } else if (trapTypes.get(2).equals(trap)) {
277 attributeList = trapDatas.getTrap3();
278 } else if (trapTypes.get(3).equals(trap)) {
279 attributeList = trapDatas.getTrap4();
280 } else if (trapTypes.get(4).equals(trap)) {
281 attributeList = trapDatas.getTrap5();
282 } else if (trapTypes.get(5).equals(trap)) {
283 attributeList = trapDatas.getTrap6();
285 } catch (Exception e) {
286 policyLogger.warn("Error during callTrap", e);
287 return "(" + trap + ")";
290 if (trapDatas.getTrap1() == null) {
293 attributeList = trapDatas.getTrap1();
295 signatureBody = signatureBody + "(" + readAttributes(attributeList, attributeList.size() - 1) + ")";
296 return signatureBody;
299 @SuppressWarnings("unchecked")
300 private String readAttributes(List<Object> object, int index) {
301 String attributes = "";
302 Map<String, String> trapSignatures = (Map<String, String>) object.get(index);
303 // Read the Elements.
305 if (trapSignatures.keySet().contains(NOT_BOX)) {
306 notBox = trapSignatures.get(NOT_BOX);
308 if (notBox != null) {
309 attributes = attributes + notBox.toString();
312 // Get Attributes for trap1 name
313 Object trapName1 = trapSignatures.get(TRIGGER_1);
314 if (trapName1 == null) {
317 attributes = getTrapAttributesString(object, attributes, trapName1);
319 Object comboBox = trapSignatures.get(OPERATOR_BOX);
320 if (comboBox != null) {
321 attributes = attributes + comboBox.toString();
326 // Get Attributes for trap1 name
327 Object trapName2 = trapSignatures.get(TRIGGER_2);
328 if (trapName2 != null) {
329 attributes = getTrapAttributesString(object, attributes, trapName2);
334 private String getTrapAttributesString(List<Object> objectList, String attributesStr, Object trapName) {
335 String trap1Attrib = trapName.toString();
336 if (trap1Attrib.startsWith("A")) {
338 int iy = Integer.parseInt(trap1Attrib.substring(1)) - 1;
339 attributesStr = attributesStr + "(" + readAttributes(objectList, iy) + ")";
340 } catch (NumberFormatException e) {
342 trap1Attrib = getVarbindOID(trap1Attrib);
343 attributesStr = attributesStr + "(" + URLEncoder.encode(trap1Attrib, ENC_UTF_8) + ")";
344 } catch (UnsupportedEncodingException e1) {
345 policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values", e1);
350 trap1Attrib = getVarbindOID(trap1Attrib);
351 attributesStr = attributesStr + "(" + URLEncoder.encode(trap1Attrib, ENC_UTF_8) + ")";
352 } catch (UnsupportedEncodingException e) {
353 policyLogger.error("Caused Exception while Encoding Varbind Dictionary Values", e);
356 return attributesStr;
359 private String getVarbindOID(String attrib) {
360 VarbindDictionary varbindId;
362 varbindId = (VarbindDictionary) commonclassdao
363 .getEntityItem(VarbindDictionary.class, "varbindName", attrib);
364 return varbindId.getVarbindOID();
365 } catch (Exception e) {
366 policyLogger.error("Error during retrieving varbindName " + attrib, e);
371 //connect traps data set to JSON Body as String
372 @SuppressWarnings({"unchecked", "rawtypes"})
373 private String getUIConnectTraps(List<Object> connectTrapSignatures) {
374 StringBuilder resultBody = new StringBuilder();
375 String connectMainBody = "";
376 for (Object connectTrapSignature : connectTrapSignatures) {
377 Map<String, String> connectTraps = (Map<String, String>) connectTrapSignature;
378 String connectBody = "";
379 if (connectTraps instanceof LinkedHashMap<?, ?>) {
381 String connectTrap1 = "";
382 String trapCount1 = "";
383 String operatorBox = "";
384 String connectTrap2 = "";
385 String trapCount2 = "";
386 if (((LinkedHashMap) connectTraps).keySet().contains(NOT_BOX)) {
387 notBox = ((LinkedHashMap) connectTraps).get(NOT_BOX).toString();
389 if (((LinkedHashMap) connectTraps).get(CONNECT_TRAP_1) != null) {
390 connectTrap1 = ((LinkedHashMap) connectTraps).get(CONNECT_TRAP_1).toString();
392 if (((LinkedHashMap) connectTraps).get(TRAP_COUNT_1) != null) {
393 trapCount1 = ((LinkedHashMap) connectTraps).get(TRAP_COUNT_1).toString();
395 if (((LinkedHashMap) connectTraps).get(OPERATOR_BOX) != null) {
396 operatorBox = ((LinkedHashMap) connectTraps).get(OPERATOR_BOX).toString();
398 if (((LinkedHashMap) connectTraps).get(CONNECT_TRAP_2) != null) {
399 connectTrap2 = ((LinkedHashMap) connectTraps).get(CONNECT_TRAP_2).toString();
401 if (((LinkedHashMap) connectTraps).get(TRAP_COUNT_2) != null) {
402 trapCount2 = ((LinkedHashMap) connectTraps).get(TRAP_COUNT_2).toString();
405 notBox + "@!" + connectTrap1 + "@!" + trapCount1 + "@!" + operatorBox + "@!" + connectTrap2 + "@!"
406 + trapCount2 + "#!?!";
408 resultBody.append(connectBody);
410 connectMainBody = connectMainBody + resultBody;
411 return connectMainBody;
414 // get Trigger signature from JSON body
415 private String getUITriggerSignature(String trap, Object object2) {
416 ClosedLoopFaultTrapDatas trapDatas = (ClosedLoopFaultTrapDatas) object2;
417 List<Object> attributeList = new ArrayList<>();
419 if (trap.startsWith(TRAP) || trap.startsWith(FAULT)) {
420 if (trapDatas.getTrap1() != null) {
421 attributeList.add(trapDatas.getTrap1());
423 if (trapDatas.getTrap2() != null) {
424 attributeList.add(trapDatas.getTrap2());
426 if (trapDatas.getTrap3() != null) {
427 attributeList.add(trapDatas.getTrap3());
429 if (trapDatas.getTrap4() != null) {
430 attributeList.add(trapDatas.getTrap4());
432 if (trapDatas.getTrap5() != null) {
433 attributeList.add(trapDatas.getTrap5());
435 if (trapDatas.getTrap6() != null) {
436 attributeList.add(trapDatas.getTrap6());
439 return getTriggerBody(attributeList);
442 @SuppressWarnings({"rawtypes", "unchecked"})
443 private String getTriggerBody(final List<Object> attributeList) {
444 StringBuilder triggerBody = new StringBuilder();
445 for (Object o : attributeList) {
446 StringBuilder signatureBody = new StringBuilder();
447 List<Object> connectTraps = (ArrayList<Object>) o;
448 for (Object connectTrap : connectTraps) {
449 String connectBody = "";
450 if (connectTrap instanceof LinkedHashMap<?, ?>) {
452 String trigger1 = "";
453 String operatorBox = "";
454 String trigger2 = "";
455 if (((LinkedHashMap) connectTrap).keySet().contains(NOT_BOX)) {
456 notBox = ((LinkedHashMap) connectTrap).get(NOT_BOX).toString();
458 if (((LinkedHashMap) connectTrap).get(TRIGGER_1) != null) {
459 trigger1 = ((LinkedHashMap) connectTrap).get(TRIGGER_1).toString();
461 if (((LinkedHashMap) connectTrap).get(OPERATOR_BOX) != null) {
462 operatorBox = ((LinkedHashMap) connectTrap).get(OPERATOR_BOX).toString();
464 if (((LinkedHashMap) connectTrap).get(TRIGGER_2) != null) {
465 trigger2 = ((LinkedHashMap) connectTrap).get(TRIGGER_2).toString();
467 connectBody = notBox + "@!" + trigger1 + "@!" + operatorBox + "@!" + trigger2 + "#!";
469 signatureBody.append(connectBody);
471 triggerBody.append(signatureBody).append("?!");
473 return triggerBody.toString();
476 public void prePopulateClosedLoopFaultPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
477 if (policyAdapter.getPolicyData() instanceof PolicyType) {
478 PolicyType policy = (PolicyType) policyAdapter.getPolicyData();
480 // Set PolicyAdapter policyName, description
481 setPolicyAdapterPolicyNameAndDescription(policyAdapter, policy);
483 // Set PolicyAdapter JsonBodyData, timeout settings
484 setClosedLoopJSONFile(policyAdapter, entity);
486 // Get the target data under policy.
487 TargetType target = policy.getTarget();
488 if (target == null) {
492 // Under target we have AnyOFType
493 List<AnyOfType> anyOfList = target.getAnyOf();
494 if (anyOfList == null) {
498 // Set PolicyAdapter OnapNameField, riskType, riskLevel, guard, ttlDate from match attributes
499 setPolicyAdapterMatchAttributes(policyAdapter, anyOfList);
503 private void setPolicyAdapterMatchAttributes(PolicyRestAdapter policyAdapter, List<AnyOfType> anyOfList) {
505 //Extract nonNull list of AllOfType objs from each AnyOfType obj
506 .map(AnyOfType::getAllOf).filter(Objects::nonNull)
507 .forEach(allOfList ->
508 //Extract nonNull list of MatchType objs from each AllOFType obj
509 allOfList.stream().map(AllOfType::getMatch).filter(Objects::nonNull)
510 .flatMap(Collection::stream)
512 // Under the match we have attribute value and
513 // attributeDesignator. So,finally down to the actual attribute.
514 AttributeValueType attributeValue = match.getAttributeValue();
515 String value = (String) attributeValue.getContent().get(0);
516 AttributeDesignatorType designator = match.getAttributeDesignator();
517 String attributeId = designator.getAttributeId();
518 // First match in the target is OnapName, so set that value.
519 if ("ONAPName".equals(attributeId)) {
520 policyAdapter.setOnapName(value);
521 OnapName onapName = new OnapName();
522 onapName.setOnapName(value);
523 policyAdapter.setOnapNameField(onapName);
524 } else if ("RiskType".equals(attributeId)) {
525 policyAdapter.setRiskType(value);
526 } else if ("RiskLevel".equals(attributeId)) {
527 policyAdapter.setRiskLevel(value);
528 } else if ("guard".equals(attributeId)) {
529 policyAdapter.setGuard(value);
530 } else if ("TTLDate".equals(attributeId) && !value.contains("NA")) {
531 PolicyController controller = new PolicyController();
532 String newDate = controller.convertDate(value);
533 policyAdapter.setTtlDate(newDate);
538 private void setPolicyAdapterPolicyNameAndDescription(PolicyRestAdapter policyAdapter, PolicyType policy) {
539 policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
540 String policyNameValue = policyAdapter.getPolicyName()
541 .substring(policyAdapter.getPolicyName().indexOf("Fault_") + 6);
542 policyAdapter.setPolicyName(policyNameValue);
545 description = policy.getDescription().substring(0, policy.getDescription().indexOf("@CreatedBy:"));
546 } catch (Exception e) {
548 "Error during collecting the description tag info for createClosedLoopFault " + policyNameValue, e);
549 description = policy.getDescription();
551 policyAdapter.setPolicyDescription(description);
554 private void setClosedLoopJSONFile(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
555 ObjectMapper mapper = new ObjectMapper();
557 ClosedLoopFaultBody closedLoopBody = mapper
558 .readValue(entity.getConfigurationData().getConfigBody(), ClosedLoopFaultBody.class);
559 if ("ACTIVE".equalsIgnoreCase(closedLoopBody.getClosedLoopPolicyStatus())) {
560 closedLoopBody.setClosedLoopPolicyStatus("Active");
562 closedLoopBody.setClosedLoopPolicyStatus("InActive");
564 policyAdapter.setJsonBodyData(closedLoopBody);
565 if (closedLoopBody.getTrapMaxAge() != null) {
566 policyAdapter.setTrapMaxAge(closedLoopBody.getTrapMaxAge().toString());
568 if (closedLoopBody.getTriggerTimeWindowUsedForUI() != null) {
569 policyAdapter.setClearTimeOut(closedLoopBody.getTriggerTimeWindowUsedForUI().toString());
571 if (closedLoopBody.getVerificationTimeWindowUsedForUI() != null) {
573 .setVerificationclearTimeOut(closedLoopBody.getVerificationTimeWindowUsedForUI().toString());
575 } catch (Exception e) {
576 policyLogger.error("Exception Occured" + e);
581 class ClosedLoopGridJSONData {
583 private String clearTimeOut;
584 private String trapMaxAge;
585 private String verificationclearTimeOut;
586 private List<Object> connecttriggerSignatures;
587 private List<Object> connectVerificationSignatures;
589 public String getClearTimeOut() {
593 public void setClearTimeOut(String clearTimeOut) {
594 this.clearTimeOut = clearTimeOut;
597 public String getTrapMaxAge() {
601 public void setTrapMaxAge(String trapMaxAge) {
602 this.trapMaxAge = trapMaxAge;
605 public String getVerificationclearTimeOut() {
606 return verificationclearTimeOut;
609 public void setVerificationclearTimeOut(String verificationclearTimeOut) {
610 this.verificationclearTimeOut = verificationclearTimeOut;
614 public List<Object> getConnecttriggerSignatures() {
615 return connecttriggerSignatures;
618 public void setConnecttriggerSignatures(List<Object> connecttriggerSignatures) {
619 this.connecttriggerSignatures = connecttriggerSignatures;
622 public List<Object> getConnectVerificationSignatures() {
623 return connectVerificationSignatures;
626 public void setConnectVerificationSignatures(List<Object> connectVerificationSignatures) {
627 this.connectVerificationSignatures = connectVerificationSignatures;