parmval = parameters.get("config-component-configPassword");
if ((parmval != null) && (parmval.length() > 0)) {
- log.debug("Overwriting configPassword with " + parmval);
+ //log.debug("Overwriting configPassword with " + parmval);
configPassword = parmval;
}
import java.io.IOException;
import java.io.StringReader;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
public Document getCompareDoc(String inXml) throws ParserConfigurationException, SAXException, IOException
{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ dbFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
StringReader reader = new StringReader(inXml);
InputSource inputSource = new InputSource(reader);
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.io.StringReader;
+
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.codehaus.jettison.json.JSONArray;
public static boolean isXML(String data) {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ dbFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
dBuilder.parse(new InputSource(new StringReader(data)));
return true;
String action = args[4];
String port = args[5];
String url = args[6];
- log.info("vnfType = " + vnfType + " protocol = " + protocol + " " + USER_PARAM + "=" + user + " " + PASS_PARAM
- + "=" + password + " action=" + action + " " + PORT_PARAM + "=" + port + " " + URL_PARAM + "=" + url);
+ //log.info("vnfType = " + vnfType + " protocol = " + protocol + " " + USER_PARAM + "=" + user + " " + PASS_PARAM
+ // + "=" + password + " action=" + action + " " + PORT_PARAM + "=" + port + " " + URL_PARAM + "=" + url);
if (StringUtils.isBlank(user)) {
log.info("ERROR-USER can not be null");
@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;
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;
} 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());
}
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;
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)) {
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";
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;
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);
}
// {"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);
}