diff options
author | Keighron, Lori (lk2924) <lk2924@att.com> | 2019-11-19 15:12:06 -0500 |
---|---|---|
committer | Keighron, Lori (lk2924) <lk2924@att.com> | 2019-11-19 15:16:48 -0500 |
commit | d6801d69b3d29ce0aa99d3214f7cf4bfd02fb706 (patch) | |
tree | 792454cfbccfcbcaa1e957cc608e2444e701ba24 /appc-config/appc-flow-controller | |
parent | d37a45ab352084738b3f95cb64cc83d4e1484d0b (diff) |
Apply defect and Fortify fixes to config bundle code
Apply defect and Fortify fixes to config bundle code
Change-Id: I30ec12950c8e2ddcee8a643a9b74a06486c7d6bf
Issue-ID: APPC-1787
Signed-off-by: Keighron, Lori (lk2924) <lk2924@att.com>
Diffstat (limited to 'appc-config/appc-flow-controller')
6 files changed, 23 insertions, 6 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java index 408f0a305..d8036f57a 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java @@ -52,7 +52,8 @@ public class RestExecutor implements FlowExecutorInterface { @Override public Map<String, String> execute(Transaction transaction, SvcLogicContext ctx) throws Exception { - log.info("Configuring Rest Operation....." + transaction.toString()); + String woPswd = transaction.toString().replaceAll("pswd=(.*?), ", "pswd=XXXX, "); + log.info("Configuring Rest Operation....." + woPswd); Map<String, String> outputMessage = new HashMap<>(); Client client = null; diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java index e298967d0..74932b41e 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java @@ -28,6 +28,7 @@ import static org.onap.appc.flow.controller.utils.FlowControllerConstants.DESING import static org.onap.appc.flow.controller.utils.FlowControllerConstants.GRAPH; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PARAM_RESPONSE_PREFIX; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.NODE; +import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_ERROR_CODE; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_STATUS; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_STATUS_FAILURE; @@ -104,6 +105,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin { } catch (Exception e) { ctx.setAttribute(responsePrefix + OUTPUT_PARAM_STATUS, OUTPUT_STATUS_FAILURE); ctx.setAttribute(responsePrefix + OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + ctx.setAttribute(responsePrefix + OUTPUT_PARAM_ERROR_CODE, ctx.getAttribute(OUTPUT_PARAM_ERROR_CODE)); log.error("Error occurred in processFlow ", e); throw new SvcLogicException(e.getMessage()); } diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java index 276301ed3..345b3e12e 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowSequenceGenerator.java @@ -23,6 +23,8 @@ import static org.onap.appc.flow.controller.utils.FlowControllerConstants.DESING import static org.onap.appc.flow.controller.utils.FlowControllerConstants.EXTERNAL; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.FLOW_SEQUENCE; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.GENERATION_NODE; +import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_ERROR_CODE; +import static org.onap.appc.flow.controller.utils.FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.RUNTIME; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.SEQUENCE_TYPE; import static org.onap.appc.flow.controller.utils.FlowControllerConstants.VNFC_TYPE; @@ -131,8 +133,21 @@ class FlowSequenceGenerator { flowSequence = output.toString(); log.info("MultistepSequenceGenerator-Output: " + flowSequence); - if (!flowSequence.contains("transactions")) { - throw new Exception("No transactions were generated for this request"); + // check for transactions data + if (!flowSequence.contains("transaction-id")) { + // check for status data + JSONObject statusJson = new JSONObject(output.toString()).optJSONObject("status"); + if (statusJson != null) { + log.info("statusJson=" + statusJson); + if (statusJson.has("code")) { + // extract code and set into ctx + log.info("Setting " + OUTPUT_PARAM_ERROR_CODE + "=" + statusJson.get("code").toString() + " in context ctx"); + ctx.setAttribute(OUTPUT_PARAM_ERROR_CODE, statusJson.get("code").toString()); + log.info("Setting " + OUTPUT_PARAM_ERROR_MESSAGE + "=" + statusJson.get("message").toString() + " in context ctx"); + ctx.setAttribute(OUTPUT_PARAM_ERROR_MESSAGE, statusJson.get("message").toString()); + } + } + throw new Exception("Failed to generate the sequence for this request"); } } else if (sequenceType.equalsIgnoreCase(EXTERNAL)) { diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java index c4000dfe1..411cea5b7 100644 --- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java @@ -34,6 +34,7 @@ public class FlowControllerConstants { public static final String OUTPUT_PARAM_STATUS = "status"; public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + public static final String OUTPUT_PARAM_ERROR_CODE = "error-code"; public static final String OUTPUT_STATUS_SUCCESS = "success"; public static final String OUTPUT_STATUS_FAILURE = "failure"; diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java index d89059ddf..64914bb8c 100644 --- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowControlNodeTest.java @@ -37,7 +37,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import org.onap.appc.flow.controller.data.ResponseAction; -import org.onap.appc.flow.controller.data.Transaction; import org.onap.appc.flow.controller.dbervices.FlowControlDBService; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java index 1846a0922..8658e4512 100644 --- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/FlowSequenceGeneratorTest.java @@ -171,7 +171,6 @@ public class FlowSequenceGeneratorTest { String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx); - //Assert.assertEquals("{'dummy-json-object':'some-param'}".replaceAll("'", "\""), flowSequence); Assert.assertEquals("{'transactions':[{'transaction-id':'1','payload':''}]}".replaceAll("'", "\""), flowSequence); } @@ -185,7 +184,7 @@ public class FlowSequenceGeneratorTest { // {"status":{"code":450,"message":"Request is not supported"}} map.put("restResponse", "{'output':{'status':{'code':450,'message':'Request is not supported'}}}".replaceAll("'", "\"")); when(restExecutor.execute(any(Transaction.class), eq(localCtx))).thenReturn(map); - expectedException.expectMessage("No transactions were generated for this request"); + expectedException.expectMessage("Failed to generate the sequence for this request"); String flowSequence = flowSequenceGenerator.getFlowSequence(inParams, ctx, localCtx); } |