summaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src/main/java
diff options
context:
space:
mode:
authorGeorge, Lina (lg941u) <lg941u@att.com>2018-01-08 16:38:33 -0500
committerSkip Wonnell <skip@att.com>2018-01-09 15:48:19 +0000
commit55f9e7db829f1d8d01a71a8e44388f2c4f49d004 (patch)
treed61fa88af4632300ff5971b94ced115295966c7f /appc-config/appc-flow-controller/provider/src/main/java
parent1aeb9b6a5193739f738adfc95397b3b6bce99cda (diff)
Updates to config flow-controller bundle
Issue-ID: APPC-378 Change-Id: Ie2d649c54abac69d721e60bc64ab9fa23eef5ca0 Signed-off-by: George, Lina (lg941u) <lg941u@att.com>
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/main/java')
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/ActionIdentifier.java42
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/dbervices/FlowControlDBService.java276
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java29
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/node/FlowControlNode.java204
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/EncryptionTool.java170
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/FlowControllerConstants.java27
6 files changed, 518 insertions, 230 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/ActionIdentifier.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/ActionIdentifier.java
index abce46862..9fc1527eb 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/ActionIdentifier.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/ActionIdentifier.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,12 +23,14 @@ package org.onap.appc.flow.controller.data;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ActionIdentifier {
-
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((vnfId == null) ? 0 : vnfId.hashCode());
+ result = prime * result + ((vnfcName == null) ? 0 : vnfcName.hashCode());
+ result = prime * result + ((vserverId == null) ? 0 : vserverId.hashCode());
return result;
}
@@ -46,11 +48,41 @@ public class ActionIdentifier {
return false;
} else if (!vnfId.equals(other.vnfId))
return false;
+ if (vnfcName == null) {
+ if (other.vnfcName != null)
+ return false;
+ } else if (!vnfcName.equals(other.vnfcName))
+ return false;
+ if (vserverId == null) {
+ if (other.vserverId != null)
+ return false;
+ } else if (!vserverId.equals(other.vserverId))
+ return false;
return true;
}
@JsonProperty("vnf-id")
private String vnfId ;
+ @JsonProperty("vserver-id")
+ private String vserverId;
+ @JsonProperty("vnfc-name")
+ private String vnfcName;
+
+ public String getVserverId() {
+ return vserverId;
+ }
+
+ public void setVserverId(String vserverId) {
+ this.vserverId = vserverId;
+ }
+
+ public String getVnfcName() {
+ return vnfcName;
+ }
+
+ public void setVnfcName(String vnfcName) {
+ this.vnfcName = vnfcName;
+ }
public String getVnfId() {
return vnfId;
@@ -62,9 +94,7 @@ public class ActionIdentifier {
@Override
public String toString() {
- return "ActionIdentifier [vnfId=" + vnfId + "]";
+ return "ActionIdentifier [vnfId=" + vnfId + ", vserverId=" + vserverId + ", vnfcName=" + vnfcName + "]";
}
-
-
}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/dbervices/FlowControlDBService.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/dbervices/FlowControlDBService.java
index 41251c5cf..9da9bcde9 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/dbervices/FlowControlDBService.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/dbervices/FlowControlDBService.java
@@ -22,6 +22,7 @@ package org.onap.appc.flow.controller.dbervices;
import java.util.Map;
+import org.apache.commons.lang.StringUtils;
import org.onap.appc.flow.controller.data.Transaction;
import org.onap.appc.flow.controller.utils.EscapeUtils;
import org.onap.appc.flow.controller.utils.FlowControllerConstants;
@@ -39,183 +40,240 @@ public class FlowControlDBService {
private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowControlDBService.class);
private SvcLogicResource serviceLogic;
private static FlowControlDBService dgGeneralDBService = null;
+
public static FlowControlDBService initialise() {
if (dgGeneralDBService == null) {
dgGeneralDBService = new FlowControlDBService();
}
return dgGeneralDBService;
}
+
private FlowControlDBService() {
if (serviceLogic == null) {
serviceLogic = new SqlResource();
}
}
- public void getFlowReferenceData(SvcLogicContext ctx, Map<String, String> inParams, SvcLogicContext localContext) throws SvcLogicException {
-
+ public void getFlowReferenceData(SvcLogicContext ctx, Map<String, String> inParams, SvcLogicContext localContext)
+ throws SvcLogicException {
+
String fn = "DBService.getflowModelInfo";
- // log.debug("Testing " + ctx.getAttribute(FlowExecutorConstants.VNF_TYPE) + " and " + ctx.getAttribute(FlowExecutorConstants.ACTION_LEVEL));
- String whereClause = " where ACTION = $" +FlowControllerConstants.REQUEST_ACTION ;
-
- if(ctx.getAttribute(FlowControllerConstants.VNF_TYPE) !=null)
+ String whereClause = " where ACTION = $" + FlowControllerConstants.REQUEST_ACTION;
+
+ if (StringUtils.isNotBlank(ctx.getAttribute(FlowControllerConstants.VNF_TYPE)))
whereClause = whereClause.concat(" and VNF_TYPE = $" + FlowControllerConstants.VNF_TYPE);
-
- if(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL) !=null)
+ if (StringUtils.isNotBlank(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL)))
whereClause = whereClause.concat(" and ACTION_LEVEL = $" + FlowControllerConstants.ACTION_LEVEL);
-
+
QueryStatus status = null;
- if (serviceLogic != null && localContext != null) {
- String key = "select SEQUENCE_TYPE, CATEGORY, GENERATION_NODE, EXECUTION_NODE from " + FlowControllerConstants.DB_MULTISTEP_FLOW_REFERENCE +
- whereClause ;
+ if (serviceLogic != null& localContext != null) {
+ String key = "select SEQUENCE_TYPE, CATEGORY, GENERATION_NODE, EXECUTION_NODE from "
+ + FlowControllerConstants.DB_MULTISTEP_FLOW_REFERENCE + whereClause;
log.debug(fn + "Query String : " + key);
status = serviceLogic.query("SQL", false, null, key, null, null, localContext);
- if(status.toString().equals("FAILURE"))
+ if (status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting FlowReferenceData ");
- }
+ }
}
+
public String getEndPointByAction(String action) {
- // TODO Auto-generated method stub
return null;
}
+
public String getDesignTimeFlowModel(SvcLogicContext localContext) throws SvcLogicException {
- String fn = "DBService.getDesignTimeFlowModel ";
+ String fn = "DBService.getDesignTimeFlowModel ";
QueryStatus status = null;
- if (serviceLogic != null && localContext != null) {
- String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from " + FlowControllerConstants.DB_SDC_ARTIFACTS
- + " where artifact_name in (select artifact_name from " + FlowControllerConstants.DB_SDC_REFERENCE +
- " where vnf_type= $" + FlowControllerConstants.VNF_TYPE +
- " and vnfc_type = $" + FlowControllerConstants.VNFC_TYPE +
- " and action = $" + FlowControllerConstants.REQUEST_ACTION +
- " and file_category = $" + FlowControllerConstants.CATEGORY + " )" ;
-
-
+ if (serviceLogic != null& localContext != null) {
+ String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from "
+ + FlowControllerConstants.DB_SDC_ARTIFACTS + " where artifact_name in (select artifact_name from "
+ + FlowControllerConstants.DB_SDC_REFERENCE + " where vnf_type= $" + FlowControllerConstants.VNF_TYPE
+ + " and vnfc_type = $" + FlowControllerConstants.VNFC_TYPE + " and action = $"
+ + FlowControllerConstants.REQUEST_ACTION + " and file_category = $"
+ + FlowControllerConstants.CATEGORY + " )";
+
log.debug(fn + "Query String : " + queryString);
- status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext);
+ status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext);
- if(status.toString().equals("FAILURE"))
+ if (status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting FlowReferenceData ");
-
- String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_SDC_ARTIFACTS +
- " where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
-
+
+ String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_SDC_ARTIFACTS
+ + " where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
+
log.debug(fn + "Query String : " + queryString1);
- status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext);
- if(status.toString().equals("FAILURE"))
+ status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext);
+ if (status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting FlowReferenceData ");
}
return localContext != null ? localContext.getAttribute("artifact-content") : null;
}
+
public QueryStatus loadSequenceIntoDB(SvcLogicContext localContext) throws SvcLogicException {
-
+
QueryStatus status = null;
-
+
if (localContext != null) {
String fn = "DBService.saveArtifacts";
-
+
localContext.setAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED,
- EscapeUtils.escapeSql(localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT)));
- log.debug("ESCAPED sequence for DB : " + localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED));
-
+ EscapeUtils.escapeSql(localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT)));
+ log.debug("ESCAPED sequence for DB : "
+ + localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED));
+
for (Object key : localContext.getAttributeKeySet()) {
String parmName = (String) key;
String parmValue = localContext.getAttribute(parmName);
- log.debug(" loadSequenceIntoDB " + parmName + "=" + parmValue);
-
+ log.debug(" loadSequenceIntoDB " + parmName + "=" + parmValue);
}
-
- String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS +
- " set request_id = $" + FlowControllerConstants.REQUEST_ID +
- " , action = $" + FlowControllerConstants.REQUEST_ACTION +
- " , action_level = $" + FlowControllerConstants.ACTION_LEVEL +
- " , vnf_type = $" + FlowControllerConstants.VNF_TYPE +
- " , category = $" + FlowControllerConstants.CATEGORY +
- " , artifact_content = $" + FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED +
- " , updated_date = sysdate() ";
-
+
+ String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS + " set request_id = $"
+ + FlowControllerConstants.REQUEST_ID + " , action = $" + FlowControllerConstants.REQUEST_ACTION
+ + " , action_level = $" + FlowControllerConstants.ACTION_LEVEL + " , vnf_type = $"
+ + FlowControllerConstants.VNF_TYPE + " , category = $" + FlowControllerConstants.CATEGORY
+ + " , artifact_content = $" + FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED
+ + " , updated_date = sysdate() ";
+
log.debug(fn + "Query String : " + queryString);
status = serviceLogic.save("SQL", false, false, queryString, null, null, localContext);
- if(status.toString().equals("FAILURE"))
- throw new SvcLogicException("Error While processing storing Artifact: " +localContext.getAttribute(FlowControllerConstants.ARTIFACT_NAME));
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error While processing storing Artifact: "
+ + localContext.getAttribute(FlowControllerConstants.ARTIFACT_NAME));
}
return status;
}
- public void populateModuleAndRPC(Transaction transaction, String vnf_type) throws SvcLogicException {
+
+ public void populateModuleAndRPC(Transaction transaction, String vnf_type) throws Exception {
String fn = "FlowControlDBService.populateModuleAndRPC ";
QueryStatus status = null;
- SvcLogicContext context = new SvcLogicContext();
-
- String key = "select execution_type, execution_module, execution_rpc from " + FlowControllerConstants.DB_PROCESS_FLOW_REFERENCE +
- " where action = '" + transaction.getAction() + "'" +
- " and action_level = '" + transaction.getActionLevel() + "'" +
- " and protocol in ( select protocol from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE +
- " where action = '" + transaction.getAction() + "'" ;
- if(vnf_type !=null && !vnf_type.isEmpty())
- key = key + " and vnf_type ='" + vnf_type + "' )" ;
- else
- key = key + " ) " ;
+ SvcLogicContext context = new SvcLogicContext();
+ String protocolType = null;
+
+ protocolType = getProtocolType(transaction, vnf_type, fn, context, protocolType);
+
+ String key = "select execution_type, execution_module, execution_rpc from "
+ + FlowControllerConstants.DB_PROCESS_FLOW_REFERENCE + " where action = '" + transaction.getAction()
+ + "'" + " and action_level = '" + transaction.getActionLevel() + "'" + " and protocol = '"
+ + protocolType + "'";
+
log.debug(fn + "Query String : " + key);
status = serviceLogic.query("SQL", false, null, key, null, null, context);
- if(status.toString().equals("FAILURE"))
+ if (status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting FlowReferenceData ");
-
+
transaction.setExecutionModule(context.getAttribute(FlowControllerConstants.EXECUTTION_MODULE));
transaction.setExecutionRPC(context.getAttribute(FlowControllerConstants.EXECUTION_RPC));
transaction.setExecutionType(context.getAttribute(FlowControllerConstants.EXECUTION_TYPE));
-
+
+ }
+
+ private String getProtocolType(Transaction transaction, String vnf_type, String fn, SvcLogicContext context,
+ String protocolType) throws Exception {
+ QueryStatus status;
+ String protocolQuery;
+ int protocolCount;
+ protocolQuery = "select count(protocol) from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE
+ + " where action = '" + transaction.getAction() + "'" + " and action_level = '"
+ + transaction.getActionLevel() + "'";
+
+ log.debug(fn + "Query String : " + protocolQuery);
+ status = serviceLogic.query("SQL", false, null, protocolQuery, null, null, context);
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting FlowReferenceData ");
+
+ log.debug(" Protocol Count " + context.getAttribute("count(protocol)"));
+ protocolCount = Integer.parseInt(context.getAttribute("count(protocol)"));
+
+ if (protocolCount == 1) {
+ protocolQuery = "select protocol from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE
+ + " where action = '" + transaction.getAction() + "'" + " and action_level = '"
+ + transaction.getActionLevel() + "'";
+
+ log.debug(fn + "Query String : " + protocolQuery);
+ status = serviceLogic.query("SQL", false, null, protocolQuery, null, null, context);
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting FlowReferenceData ");
+ protocolType = context.getAttribute("protocol");
+ }
+ else {
+ protocolQuery = "select count(protocol) from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE
+ + " where action = '" + transaction.getAction() + "'" + " and action_level = '"
+ + transaction.getActionLevel() + "'" + " and vnf_type = '" + vnf_type + "'";
+
+ log.debug(fn + "Query String : " + protocolQuery);
+ status = serviceLogic.query("SQL", false, null, protocolQuery, null, null, context);
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting FlowReferenceData ");
+
+ log.debug(" Protocol Count " + context.getAttribute("count(protocol)"));
+ protocolCount = Integer.parseInt(context.getAttribute("count(protocol)"));
+ if(protocolCount > 1){
+ throw new Exception("Got more than 2 values..");
+ }else if(protocolCount == 1){
+ protocolQuery = "select protocol from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE
+ + " where action = '" + transaction.getAction() + "'" + " and action_level = '"
+ + transaction.getActionLevel() + "'"+ " and vnf_type = '" + vnf_type + "'";
+ log.debug(fn + "Query String : " + protocolQuery);
+ status = serviceLogic.query("SQL", false, null, protocolQuery, null, null, context);
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting FlowReferenceData ");
+ protocolType = context.getAttribute("protocol");
+ }
+ }
+ return protocolType;
}
-
+
public String getDependencyInfo(SvcLogicContext localContext) throws SvcLogicException {
- String fn = "DBService.getDependencyInfo ";
+ String fn = "DBService.getDependencyInfo ";
QueryStatus status = null;
- if (serviceLogic != null && localContext != null) {
- String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from " + FlowControllerConstants.DB_SDC_ARTIFACTS
- + " where artifact_name in (select artifact_name from " + FlowControllerConstants.DB_SDC_REFERENCE +
- " where vnf_type= $" + FlowControllerConstants.VNF_TYPE +
- " and file_category = '" + FlowControllerConstants.DEPENDENCYMODEL +"' )" ;
-
+ if (serviceLogic != null& localContext != null) {
+ String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from "
+ + FlowControllerConstants.DB_SDC_ARTIFACTS + " where artifact_name in (select artifact_name from "
+ + FlowControllerConstants.DB_SDC_REFERENCE + " where vnf_type= $" + FlowControllerConstants.VNF_TYPE
+ + " and file_category = '" + FlowControllerConstants.DEPENDENCYMODEL + "' )";
+
log.debug(fn + "Query String : " + queryString);
- status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext);
+ status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext);
- if(status.toString().equals("FAILURE"))
+ if (status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting dependencydata ");
-
- String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_SDC_ARTIFACTS +
- " where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
-
+
+ String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_SDC_ARTIFACTS
+ + " where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
+
log.debug(fn + "Query String : " + queryString1);
- status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext);
- if(status.toString().equals("FAILURE"))
+ status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext);
+ if (status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting dependencyData ");
}
return localContext != null ? localContext.getAttribute("artifact-content") : null;
}
-
- public String getCapabilitiesData(SvcLogicContext localContext) throws SvcLogicException {
- String fn = "DBService.getCapabilitiesData ";
- QueryStatus status = null;
- if (serviceLogic != null && localContext != null) {
- String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from " + FlowControllerConstants.DB_SDC_ARTIFACTS
- + " where artifact_name in (select artifact_name from " + FlowControllerConstants.DB_SDC_REFERENCE +
- " where vnf_type= $" + FlowControllerConstants.VNF_TYPE +
- " and file_category = '" + FlowControllerConstants.CAPABILITY +"' )" ;
-
- log.info(fn + "Query String : " + queryString);
- status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext);
-
- if(status.toString().equals("FAILURE"))
- throw new SvcLogicException("Error - while getting capabilitiesData ");
-
- String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_SDC_ARTIFACTS +
- " where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
-
- log.debug(fn + "Query String : " + queryString1);
- status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext);
- if(status.toString().equals("FAILURE"))
- throw new SvcLogicException("Error - while getting capabilitiesData ");
- }
- return localContext != null ? localContext.getAttribute("artifact-content") : null;
+
+ public String getCapabilitiesData(SvcLogicContext localContext) throws SvcLogicException {
+ String fn = "DBService.getCapabilitiesData ";
+ QueryStatus status = null;
+ if (serviceLogic != null& localContext != null) {
+ String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from "
+ + FlowControllerConstants.DB_SDC_ARTIFACTS + " where artifact_name in (select artifact_name from "
+ + FlowControllerConstants.DB_SDC_REFERENCE + " where vnf_type= $" + FlowControllerConstants.VNF_TYPE
+ + " and file_category = '" + FlowControllerConstants.CAPABILITY + "' )";
+
+ log.info(fn + "Query String : " + queryString);
+ status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext);
+
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting capabilitiesData ");
+
+ String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_SDC_ARTIFACTS
+ + " where artifact_name = $artifactName and internal_version = $maxInternalVersion ";
+
+ log.debug(fn + "Query String : " + queryString1);
+ status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext);
+ if (status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting capabilitiesData ");
}
+ return localContext != null ? localContext.getAttribute("artifact-content") : null;
+ }
}
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 180a612d6..0f901e0fe 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,6 +32,7 @@ import javax.net.ssl.SSLContext;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.MediaType;
+import org.apache.commons.lang3.StringUtils;
import org.onap.appc.flow.controller.data.Response;
import org.onap.appc.flow.controller.data.Transaction;
import org.onap.appc.flow.controller.interfaces.FlowExecutorInterface;
@@ -51,7 +52,7 @@ public class RestExecutor implements FlowExecutorInterface {
private static final EELFLogger log = EELFManager.getInstance().getLogger(RestExecutor.class);
private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
Properties props = new Properties();
- public RestExecutor() throws Exception {
+ public RestExecutor() throws Exception {
String propDir = System.getenv(SDNC_CONFIG_DIR_VAR);
if (propDir == null)
throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
@@ -70,10 +71,10 @@ public class RestExecutor implements FlowExecutorInterface {
catch (Exception e){
log.warn("Could not close FileInputStream", e);
}
- }
+ }
}
@Override
- public HashMap<String, String> execute(Transaction transaction, SvcLogicContext ctx) throws Exception{
+ public HashMap<String, String> execute(Transaction transaction, SvcLogicContext ctx) throws Exception{
log.info("Configuring Rest Operation....." + transaction.toString());
Response response = new Response();
HashMap<String, String> outputMessage = new HashMap<String, String>();
@@ -82,8 +83,8 @@ public class RestExecutor implements FlowExecutorInterface {
ClientResponse clientResponse = null;
String responseDataType=MediaType.APPLICATION_JSON;
String requestDataType=MediaType.APPLICATION_JSON;
-
-
+
+
try{
DefaultClientConfig defaultClientConfig = new DefaultClientConfig();
System.setProperty("jsse.enableSNIExtension", "false");
@@ -114,15 +115,21 @@ public class RestExecutor implements FlowExecutorInterface {
response.setResponseCode(String.valueOf(clientResponse.getStatus()));
ArrayList<Response> responses = new ArrayList<Response>();
responses.add(response);
- transaction.setResponses(responses);
+ transaction.setResponses(responses);
outputMessage.put("restResponse", clientResponse.getEntity(String.class));
}
else{
+
+ String errorMsg = clientResponse.getEntity(String.class);
+ if (StringUtils.isNotBlank(errorMsg)) {
+ log.debug("Error Message from Client Response" + errorMsg);
+ }
+
throw new Exception("Can not determine the state of : " + transaction.getActionLevel() + " HTTP error code : "
+ clientResponse.getStatus());
-
+
}
-
+
log.info("Completed Rest Operation.....");
}catch (Exception e) {
@@ -141,7 +148,7 @@ public class RestExecutor implements FlowExecutorInterface {
return outputMessage;
}
-
+
private HostnameVerifier getHostnameVerifier() {
return new HostnameVerifier() {
@Override
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 010729f29..e0ef5fd7e 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,6 +30,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.json.JSONObject;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@@ -53,6 +54,7 @@ import org.onap.appc.flow.controller.interfaceData.VnfInfo;
import org.onap.appc.flow.controller.interfaceData.Vnfcs;
import org.onap.appc.flow.controller.interfaceData.Vnfcslist;
import org.onap.appc.flow.controller.interfaces.FlowExecutorInterface;
+import org.onap.appc.flow.controller.utils.EncryptionTool;
import org.onap.appc.flow.controller.utils.FlowControllerConstants;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
@@ -76,7 +78,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
public void processFlow(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
log.debug("Received processParamKeys call with params : " + inParams);
- String responsePrefix = inParams.get(FlowControllerConstants.INPUT_PARAM_RESPONSE_PRIFIX);
+ String responsePrefix = inParams.get(FlowControllerConstants.INPUT_PARAM_RESPONSE_PRIFIX);
try
{
responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
@@ -85,7 +87,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
localContext.setAttribute(FlowControllerConstants.REQUEST_ID, ctx.getAttribute(FlowControllerConstants.REQUEST_ID));
localContext.setAttribute(FlowControllerConstants.VNF_TYPE, ctx.getAttribute(FlowControllerConstants.VNF_TYPE));
localContext.setAttribute(FlowControllerConstants.REQUEST_ACTION, ctx.getAttribute(FlowControllerConstants.REQUEST_ACTION));
- localContext.setAttribute(FlowControllerConstants.ACTION_LEVEL, ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL));
+ localContext.setAttribute(FlowControllerConstants.ACTION_LEVEL, ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL));
localContext.setAttribute(FlowControllerConstants.RESPONSE_PREFIX, responsePrefix);
ctx.setAttribute(FlowControllerConstants.RESPONSE_PREFIX, responsePrefix);
dbservice.getFlowReferenceData(ctx, inParams, localContext);
@@ -96,10 +98,10 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
log.debug("processFlow " + parmName + "=" + parmValue);
}
- processFlowSequence(inParams, ctx, localContext);
+ processFlowSequence(inParams, ctx, localContext);
if(!ctx.getAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS).equals(FlowControllerConstants.OUTPUT_STATUS_SUCCESS))
throw new SvcLogicException(ctx.getAttribute(responsePrefix + FlowControllerConstants.OUTPUT_STATUS_MESSAGE));
-
+
} catch (Exception e) {
ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_FAILURE);
ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
@@ -108,10 +110,10 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
}
}
- private void processFlowSequence( Map<String, String> inParams, SvcLogicContext ctx, SvcLogicContext localContext) throws Exception
+ private void processFlowSequence( Map<String, String> inParams, SvcLogicContext ctx, SvcLogicContext localContext) throws Exception
{
String fn = "FlowExecutorNode.processflowSequence";
- log.debug(fn + "Received model for flow : " + localContext.toString());
+ log.debug(fn + "Received model for flow : " + localContext.toString());
FlowControlDBService dbservice = FlowControlDBService.initialise();
String flowSequnce =null;
for (Object key : localContext.getAttributeKeySet()) {
@@ -125,13 +127,13 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
if(localContext.getAttribute(FlowControllerConstants.GENERATION_NODE) != null){
GraphExecutor transactionExecutor = new GraphExecutor();
Boolean generatorExists = transactionExecutor.hasGraph("APPC_COMMOM", localContext.getAttribute(FlowControllerConstants.GENERATION_NODE), null, "sync");
- if(generatorExists){
+ if(generatorExists){
flowSequnce = transactionExecutor.executeGraph("APPC_COMMOM", localContext.getAttribute(FlowControllerConstants.GENERATION_NODE),
null, "sync", null).getProperty(FlowControllerConstants.FLOW_SEQUENCE);
}
else
- throw new Exception("Can not find Custom defined Flow Generator for " + localContext.getAttribute(FlowControllerConstants.GENERATION_NODE));
- }
+ throw new Exception("Can not find Custom defined Flow Generator for " + localContext.getAttribute(FlowControllerConstants.GENERATION_NODE));
+ }
else if(((String) localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE)).equalsIgnoreCase(FlowControllerConstants.DESINGTIME)){
localContext.setAttribute(FlowControllerConstants.VNFC_TYPE, ctx.getAttribute(FlowControllerConstants.VNFC_TYPE));
flowSequnce = dbservice.getDesignTimeFlowModel(localContext);
@@ -139,15 +141,19 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
throw new Exception("Flow Sequence is not found User Desinged VNF " + ctx.getAttribute(FlowControllerConstants.VNF_TYPE));
}
else if(((String) localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE)).equalsIgnoreCase(FlowControllerConstants.RUNTIME)){
-
+
Transaction transaction = new Transaction();
String input = collectInputParams(ctx,transaction);
- log.info("collectInputParamsData" + input );
-
- RestExecutor restExe = new RestExecutor();
+ log.info("CollectInputParamsData-Input: " + input );
+
+ RestExecutor restExe = new RestExecutor();
HashMap<String,String>flowSeq= restExe.execute(transaction, localContext);
- flowSequnce=flowSeq.get("restResponse");
-
+
+ JSONObject sequence=new JSONObject(flowSeq.get("restResponse"));
+ if(sequence.has("output"))
+ flowSequnce = sequence.getJSONObject("output").toString();
+ log.info("MultistepSequenceGenerator-Output: "+flowSequnce);
+
if(flowSequnce == null)
throw new Exception("Failed to get the Flow Sequece runtime for VNF type" + ctx.getAttribute(FlowControllerConstants.VNF_TYPE));
@@ -156,7 +162,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
//String input = collectInputParams(localContext);
// flowSequnce = ""; //get it from the External interface calling the Rest End point - TBD
if(flowSequnce == null)
- throw new Exception("Flow Sequence not found for " + ctx.getAttribute(FlowControllerConstants.VNF_TYPE));
+ throw new Exception("Flow Sequence not found for " + ctx.getAttribute(FlowControllerConstants.VNF_TYPE));
}
else
{
@@ -167,7 +173,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
else{
FlowGenerator flowGenerator = new FlowGenerator();
Transactions trans = flowGenerator.createSingleStepModel(inParams,ctx);
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper();
flowSequnce = mapper.writeValueAsString(trans);
log.debug("Single step Flow Sequence : " + flowSequnce);
@@ -175,7 +181,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
log.debug("Received Flow Sequence : " + flowSequnce);
HashMap<Integer, Transaction> transactionMap = createTransactionMap(flowSequnce, localContext);
- exeuteAllTransaction(transactionMap, ctx);
+ exeuteAllTransaction(transactionMap, ctx);
log.info("Executed all the transacstion successfully");
}
@@ -185,14 +191,14 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
String fn = "FlowExecutorNode.exeuteAllTransaction ";
int retry = 0;
FlowExecutorInterface flowExecutor = null;
- for (int key = 1; key <= transactionMap.size() ; key++ )
- {
+ for (int key = 1; key <= transactionMap.size() ; key++ )
+ {
log.debug(fn + "Starting transactions ID " + key + " :)=" + retry);
Transaction transaction = transactionMap.get(key);
if(!preProcessor(transactionMap, transaction)){
log.info("Skipping Transaction ID " + transaction.getTransactionId());
continue;
- }
+ }
if(transaction.getExecutionType() != null){
switch (transaction.getExecutionType()){
case FlowControllerConstants.GRAPH :
@@ -219,9 +225,9 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
log.debug(fn + "Sending Intermediate Message back .... ");
sendIntermediateMessage();
}
- if(responseAction.getRetry() != null && Integer.parseInt(responseAction.getRetry()) > retry ){
+ if(responseAction.getRetry() != null && Integer.parseInt(responseAction.getRetry()) > retry ){
log.debug(fn + "Ooppss!!! We will retry again ....... ");
- key--;
+ key--;
retry++;
log.debug(fn + "key =" + key + "retry =" + retry);
@@ -236,7 +242,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
}
if(responseAction.getJump() != null && Integer.parseInt(responseAction.getJump()) > 0 ){
key = Integer.parseInt(responseAction.getJump());
- key --;
+ key --;
}
log.debug(fn + "key =" + key + "retry =" + retry);
@@ -252,9 +258,9 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
}
- private ResponseAction handleResponse(Transaction transaction) {
+ private ResponseAction handleResponse(Transaction transaction) {
log.info("Handling Response for transaction Id " + transaction.getTransactionId());
- DefaultResponseHandler defaultHandler = new DefaultResponseHandler();
+ DefaultResponseHandler defaultHandler = new DefaultResponseHandler();
return defaultHandler.handlerResponse(transaction);
}
@@ -263,7 +269,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
log.debug("Starting Preprocessing Logic ");
boolean runthisStep = false;
try{
- if(transaction.getPrecheck() != null && transaction.getPrecheck().getPrecheckOptions() != null
+ if(transaction.getPrecheck() != null && transaction.getPrecheck().getPrecheckOptions() != null
&& !transaction.getPrecheck().getPrecheckOptions().isEmpty()){
List<PrecheckOption> precheckOptions = transaction.getPrecheck().getPrecheckOptions();
for(PrecheckOption precheck : precheckOptions){
@@ -271,15 +277,15 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
ObjectMapper mapper = new ObjectMapper();
log.info("Mapper= " + mapper.writeValueAsString(trans));
HashMap<Object, Object> trmap = mapper.readValue(mapper.writeValueAsString(trans), HashMap.class);
- if(trmap.get(precheck.getParamName()) != null &&
+ if(trmap.get(precheck.getParamName()) != null &&
((String) trmap.get(precheck.getParamName())).equalsIgnoreCase(precheck.getParamValue()))
runthisStep = true;
else
runthisStep = false;
- if(transaction.getPrecheck().getPrecheckOperator() != null &&
+ if(transaction.getPrecheck().getPrecheckOperator() != null &&
transaction.getPrecheck().getPrecheckOperator().equalsIgnoreCase("any") && runthisStep)
- break;
+ break;
}
}
@@ -299,19 +305,19 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
return runthisStep ;
}
- private HashMap<Integer, Transaction> createTransactionMap(String flowSequnce, SvcLogicContext localContext) throws SvcLogicException, JsonParseException, JsonMappingException, IOException {
- ObjectMapper mapper = new ObjectMapper();
+ private HashMap<Integer, Transaction> createTransactionMap(String flowSequnce, SvcLogicContext localContext) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
Transactions transactions = mapper.readValue(flowSequnce,Transactions.class);
- HashMap<Integer, Transaction> transMap = new HashMap<Integer, Transaction>();
- for(Transaction transaction : transactions.getTransactions()){
+ HashMap<Integer, Transaction> transMap = new HashMap<Integer, Transaction>();
+ for(Transaction transaction : transactions.getTransactions()){
compileFlowDependencies(transaction, localContext);
- //loadTransactionIntoStatus(transactions, ctx); //parse the Transactions Object and create records in process_flow_status table
- transMap.put(transaction.getTransactionId(), transaction);
- }
+ //loadTransactionIntoStatus(transactions, ctx); //parse the Transactions Object and create records in process_flow_status table
+ transMap.put(transaction.getTransactionId(), transaction);
+ }
return transMap;
}
- private void compileFlowDependencies(Transaction transaction, SvcLogicContext localContext) throws SvcLogicException, JsonParseException, JsonMappingException, IOException {
+ private void compileFlowDependencies(Transaction transaction, SvcLogicContext localContext) throws Exception {
String fn = "FlowExecutorNode.compileFlowDependencies";
FlowControlDBService dbservice = FlowControlDBService.initialise();
@@ -319,59 +325,68 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
ObjectMapper mapper = new ObjectMapper();
log.debug("Indivisual Transaction Details :" + transaction.toString());
if((localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE) == null) ||
- ( localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE) != null &&
+ ( localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE) != null &&
! localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE).equalsIgnoreCase(FlowControllerConstants.DESINGTIME))){
localContext.setAttribute("artifact-content", mapper.writeValueAsString(transaction));
dbservice.loadSequenceIntoDB(localContext);
}
//get a field in transction class as transactionhandle interface and register the Handler here for each trnactions
}
-
- private String collectInputParams(SvcLogicContext ctx, Transaction transaction) throws Exception {
+
+ private String collectInputParams(SvcLogicContext ctx,Transaction transaction) throws Exception {
String fn = "FlowExecuteNode.collectInputParams";
Properties prop = loadProperties();
log.info("Loaded Properties " + prop.toString());
String vnfId = ctx.getAttribute(FlowControllerConstants.VNF_ID);
+ String inputData = null;
log.debug(fn + "vnfId :" + vnfId);
if (StringUtils.isBlank(vnfId)) {
throw new Exception("VnfId is missing");
}
- ActionIdentifier actionIdentifier = new ActionIdentifier();
- actionIdentifier.setVnfId(vnfId);
- actionIdentifier.setVserverId(ctx.getAttribute(FlowControllerConstants.VSERVER_ID));
- actionIdentifier.setVnfcName(ctx.getAttribute(FlowControllerConstants.VNFC_NAME));
-
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setAction(ctx.getAttribute(FlowControllerConstants.ACTION));
- requestInfo.setActionLevel(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL));
- requestInfo.setPayload(ctx.getAttribute(FlowControllerConstants.PAYLOAD));
- requestInfo.setActionIdentifier(actionIdentifier);
-
- InventoryInfo inventoryInfo = getInventoryInfo(ctx,vnfId);
- DependencyInfo dependencyInfo = getDependencyInfo(ctx);
- Capabilities capabilites = getCapabilitesData(ctx);
-
- Input input = new Input();
- input.setRequestInfo(requestInfo);
- input.setInventoryInfo(inventoryInfo);
- input.setDependencyInfo(dependencyInfo);
- input.setCapabilities(capabilites);
- //input.setTunableParameters(null);
-
-
- log.info(fn + "Input parameters:" + input.toString());
-
- String inputData = null;
try {
+
+ ActionIdentifier actionIdentifier = new ActionIdentifier();
+ log.debug("Enter ActionIdentifier");
+ if (StringUtils.isNotBlank(vnfId)) {
+ actionIdentifier.setVnfId(vnfId);
+ }
+ if (StringUtils.isNotBlank(ctx.getAttribute(FlowControllerConstants.VSERVER_ID))) {
+ actionIdentifier.setVserverId(ctx.getAttribute(FlowControllerConstants.VSERVER_ID));
+ }
+ if (StringUtils.isNotBlank(ctx.getAttribute(FlowControllerConstants.VNFC_NAME))) {
+ actionIdentifier.setVnfcName(ctx.getAttribute(FlowControllerConstants.VNFC_NAME));
+ }
+ log.info("ActionIdentifierData" + actionIdentifier.toString());
+
+ RequestInfo requestInfo = new RequestInfo();
+ log.info("Enter RequestInfo");
+ requestInfo.setAction(ctx.getAttribute(FlowControllerConstants.REQUEST_ACTION));
+ requestInfo.setActionLevel(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL));
+ requestInfo.setPayload(ctx.getAttribute(FlowControllerConstants.PAYLOAD));
+ requestInfo.setActionIdentifier(actionIdentifier);
+ log.debug("RequestInfo: " + requestInfo.toString());
+
+ InventoryInfo inventoryInfo = getInventoryInfo(ctx, vnfId);
+ DependencyInfo dependencyInfo = getDependencyInfo(ctx);
+ Capabilities capabilites = getCapabilitesData(ctx);
+
+ Input input = new Input();
+ log.info("Enter InputData");
+ input.setRequestInfo(requestInfo);
+ input.setInventoryInfo(inventoryInfo);
+ input.setDependencyInfo(dependencyInfo);
+ input.setCapabilities(capabilites);
+ log.info(fn + "Input parameters:" + input.toString());
+
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE,true);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
inputData = mapper.writeValueAsString(input);
- log.info("InputDataJson:"+inputData);
+ log.info("InputDataJson:" + inputData);
} catch (Exception e) {
e.printStackTrace();
@@ -380,18 +395,21 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
String resourceUri = prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_URL);
log.info(fn + "resourceUri= " + resourceUri);
+ EncryptionTool et = EncryptionTool.getInstance();
+ String pass = et.decrypt(prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_PWD));
+
transaction.setPayload(inputData);
transaction.setExecutionRPC("POST");
transaction.setuId(prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_UID));
- transaction.setPswd(prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_PWD));
+ transaction.setPswd(pass);
transaction.setExecutionEndPoint(resourceUri);
return inputData;
}
-
+
private DependencyInfo getDependencyInfo(SvcLogicContext ctx) throws Exception {
-
+
String fn = "FlowExecutorNode.getDependencyInfo";
DependencyInfo dependencyInfo = new DependencyInfo();
FlowControlDBService dbservice = FlowControlDBService.initialise();
@@ -402,18 +420,18 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- JsonNode dependencyInfoData = mapper.readTree(dependencyData).get("dependencyInfo");
- JsonNode vnfcData = mapper.readTree(dependencyInfoData.toString()).get("vnfcs");
+ //JsonNode dependencyInfoData = mapper.readTree(dependencyData).get("dependencyInfo");
+ JsonNode vnfcData = mapper.readTree(dependencyData.toString()).get("vnfcs");
List<Vnfcs> vnfclist = Arrays.asList(mapper.readValue(vnfcData.toString(), Vnfcs[].class));
dependencyInfo.getVnfcs().addAll(vnfclist);
-
+
log.info("Dependency Output:"+ dependencyInfo.toString());
}
return dependencyInfo;
}
-
+
private Capabilities getCapabilitesData(SvcLogicContext ctx)throws Exception {
String fn = "FlowExecutorNode.getCapabilitesData";
@@ -474,7 +492,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
capabilities.getVnf().addAll(vnfsList);
capabilities.getVfModule().addAll(vfModulesList);
capabilities.getVm().addAll(vmList);
-
+
log.info("Capabilities Output:"+ capabilities.toString());
}
@@ -482,19 +500,21 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
return capabilities;
}
-
+
private InventoryInfo getInventoryInfo(SvcLogicContext ctx, String vnfId) throws Exception{
-
+
String fn = "FlowExecutorNode.getInventoryInfo";
- String vmcount = ctx.getAttribute("tmp.vnfInfo.vm-count");
- int vmCount = Integer.parseInt(vmcount);
- log.info(fn +"vmcount:"+ vmCount);
VnfInfo vnfInfo = new VnfInfo();
vnfInfo.setVnfId(vnfId);
vnfInfo.setVnfName(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name"));
vnfInfo.setVnfType(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type"));
+ String vmcount = ctx.getAttribute("tmp.vnfInfo.vm-count");
+ if(StringUtils.isNotBlank(vmcount)){
+ int vmCount = Integer.parseInt(vmcount);
+ log.info(fn +"vmcount:"+ vmCount);
+
Vm vm = new Vm();
Vnfcslist vnfc = new Vnfcslist();
@@ -502,7 +522,7 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
for (int i = 0; i < vmCount; i++) {
- vm.setVserverId(ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vserverId"));
+ vm.setVserverId(ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vserver-id"));
String vnfccount = ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-count");
int vnfcCount = Integer.parseInt(vnfccount);
@@ -514,14 +534,15 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
vnfInfo.getVm().add(vm);
}
}
-
+ }
InventoryInfo inventoryInfo = new InventoryInfo();
inventoryInfo.setVnfInfo(vnfInfo);
-
+ log.info(fn + "Inventory Output:" +inventoryInfo.toString());
+
return inventoryInfo;
-
+
}
-
+
private String getFlowSequence() throws IOException {
String sequenceModel = IOUtils.toString(FlowControlNode.class.getClassLoader().getResourceAsStream("sequence.json"), Charset.defaultCharset());
@@ -529,14 +550,14 @@ public class FlowControlNode implements SvcLogicJavaPlugin{
return null;
}
-
+
private static Properties loadProperties() throws Exception {
Properties props = new Properties();
String propDir = System.getenv(SDNC_CONFIG_DIR_VAR);
if (propDir == null)
throw new Exception("Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
String propFile = propDir + FlowControllerConstants.APPC_FLOW_CONTROLLER;
- InputStream propStream = new FileInputStream(propFile);
+ InputStream propStream = new FileInputStream(propFile);
try
{
props.load(propStream);
@@ -559,4 +580,5 @@ private static Properties loadProperties() throws Exception {
return props;
}
+
}
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/EncryptionTool.java b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/EncryptionTool.java
new file mode 100644
index 000000000..61b3cd51c
--- /dev/null
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/utils/EncryptionTool.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.flow.controller.utils;
+
+
+import java.security.Provider;
+import java.security.Provider.Service;
+import java.security.Security;
+
+import org.jasypt.contrib.org.apache.commons.codec_1_3.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used to encapsulate the encryption and decryption support in one place and to
+ * provide a utility to encrypt and decrypt data.
+ */
+public class EncryptionTool {
+
+ /**
+ * The prefix we insert onto any data we encrypt so that we can tell if it is encrpyted later and
+ * therefore decrypt it
+ */
+ public static final String ENCRYPTED_VALUE_PREFIX = "enc:";
+
+ /**
+ * The instance of the encryption utility object
+ */
+ private static EncryptionTool instance = null;
+
+ /**
+ * The logger for this class.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(EncryptionTool.class);
+
+ /**
+ * The secret passphrase (PBE) that we use to perform encryption and decryption. The algorithm we
+ * are using is a symmetrical cipher.
+ */
+ private static char[] secret = {'C', '_', 'z', 'l', '!', 'K', '!', '4', '?', 'O', 'z', 'E', 'K', 'E', '>', 'U', 'R',
+ '/', '%', 'Y', '\\', 'f', 'b', '"', 'e', 'n', '{', '"', 'l', 'U', 'F', '+', 'E', '\'', 'R', 'T', 'p', '1',
+ 'V', '4', 'l', 'a', '9', 'w', 'v', '5', 'Z', '#', 'i', 'V', '"', 'd', 'l', '!', 'L', 'M', 'g', 'L', 'Q',
+ '{', 'v', 'v', 'K', 'V'};
+
+
+
+ /**
+ * Get an instance of the EncryptionTool
+ *
+ * @return The encryption tool to be used
+ */
+ public static final synchronized EncryptionTool getInstance() {
+ if (instance == null) {
+ instance = new EncryptionTool();
+ }
+ return instance;
+ }
+
+ /**
+ * Create the EncryptionTool instance
+ */
+ private EncryptionTool() {
+
+ StringBuilder sb = new StringBuilder("Found the following security algorithms:");
+ for (Provider p : Security.getProviders()) {
+ for (Service s : p.getServices()) {
+ String algo = s.getAlgorithm();
+ sb.append(String.format("%n -Algorithm [ %s ] in provider [ %s ] and service [ %s ]", algo, p.getName(),
+ s.getClassName()));
+ }
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(sb.toString());
+ }
+ }
+
+ /**
+ * Decrypt the provided encrypted text
+ *
+ * @param cipherText THe cipher text to be decrypted. If the ciphertext is not encrypted, then it is
+ * returned as is.
+ * @return the clear test of the (possibly) encrypted value. The original value if the string is not
+ * encrypted.
+ */
+ public synchronized String decrypt(String cipherText) {
+ if (isEncrypted(cipherText)) {
+ String encValue = cipherText.substring(ENCRYPTED_VALUE_PREFIX.length());
+ byte[] plainByte = Base64.decodeBase64(encValue.getBytes());
+ byte[] decryptByte = xorWithSecret(plainByte);
+ return new String(decryptByte);
+ } else {
+ return cipherText;
+ }
+
+ }
+
+ /**
+ * Encrypt the provided clear text
+ *
+ * @param clearText The clear text to be encrypted
+ * @return the encrypted text. If the clear text is empty (null or zero length), then an empty
+ * string is returned. If the clear text is already encrypted, it is not encrypted again and
+ * is returned as is. Otherwise, the clear text is encrypted and returned.
+ */
+ public synchronized String encrypt(String clearText) {
+ if (clearText != null) {
+ byte[] encByte = xorWithSecret(clearText.getBytes());
+ String encryptedValue = new String(Base64.encodeBase64(encByte));
+ return ENCRYPTED_VALUE_PREFIX + encryptedValue;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Is a value encrypted? A value is considered to be encrypted if it begins with the
+ * {@linkplain #ENCRYPTED_VALUE_PREFIX encrypted value prefix}.
+ *
+ * @param value the value to check.
+ * @return true/false;
+ */
+ private static boolean isEncrypted(final String value) {
+ return value != null && value.startsWith(ENCRYPTED_VALUE_PREFIX);
+ }
+
+ /**
+ * XORs the input byte array with the secret key, padding 0x0 to the end of the secret key if the
+ * input is longer and returns a byte array the same size as input
+ *
+ * @param inp The byte array to be XORed with secret
+ * @return A byte array the same size as inp or null if input is null.
+ */
+ private byte[] xorWithSecret(byte[] inp) {
+ if (inp == null) {
+ return new byte[0];
+ }
+
+ byte[] secretBytes = new String(secret).getBytes();
+ int size = inp.length;
+
+ byte[] out = new byte[size];
+ for (int i = 0; i < size; i++) {
+ out[i] = (byte) ((inp[i]) ^ (secretBytes[i % secretBytes.length]));
+ }
+ return out;
+ }
+
+}
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 1881e3e45..2b9ce03ce 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
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,7 @@
package org.onap.appc.flow.controller.utils;
public class FlowControllerConstants {
-
+
public static String STRING_ENCODING = "utf-8";
public static String Y = "Y";
public static String N = "N";
@@ -29,14 +29,14 @@ public class FlowControllerConstants {
public static String DATA_TYPE_JSON = "JSON";
public static String DATA_TYPE_XML = "XML";
public static String DATA_TYPE_SQL = "SQL";
-
+
public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix";
-
+
public static String OUTPUT_PARAM_STATUS = "status";
public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";
public static String OUTPUT_STATUS_SUCCESS = "success";
public static String OUTPUT_STATUS_FAILURE = "failure";
-
+
public static final String DESINGTIME = "DesignTime";
public static final String RUNTIME = "RunTime";
public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties";
@@ -59,15 +59,15 @@ public class FlowControllerConstants {
public static final String EXTERNAL = "External";
public static final String ACTION_LEVEL = "action-level";
public static final String ARTIFACT_NAME = "artifact-name";
-
- public static enum endPointType {DG,REST,NODE};
+
+ public static enum endPointType {DG,REST,NODE};
public static enum flowStatus {PENDING,IN_PROCESS,COMPLETED};
-
+
public static final String GENERATION_NODE = "GENERATION-NODE";
public static final String SEQUENCE_TYPE = "SEQUENCE-TYPE";
public static final String CATEGORY = "CATEGORY";
public static final String EXECUTION_NODE = "EXECUTION-NODE";
-
+
public static final String REQUEST_ID = "reqeust-id";
public static final String ARTIFACT_CONTENT = "artifact-content";
@@ -79,8 +79,8 @@ public class FlowControllerConstants {
public static final String GRAPH = "graph";
public static final String NODE = "node";
public static final String REST = "rest";
-
-
+
+
public static final String DB_SDC_ARTIFACTS = "ASDC_ARTIFACTS";
public static final String DB_SDC_REFERENCE = "ASDC_REFERENCE";
public static final String DB_REQUEST_ARTIFACTS = "REQUEST_ARTIFACTS";
@@ -104,7 +104,7 @@ public class FlowControllerConstants {
public static final String INPUT_REQUEST_ACTION_TYPE = "request-action-type";
public static final String INPUT_REQUEST_ACTION = "request-action";
public static final String HTTP = "http://";
-
+
public static final String VNF_ID = "vnf-id";
public static final String VSERVER_ID = "vserver-id";
public static final String SEQ_GENERATOR_URL = "seq_generator_url";
@@ -114,4 +114,5 @@ public class FlowControllerConstants {
public static final String DEPENDENCYMODEL ="tosca_dependency_model";
public static final String VF_MODULE ="vf-module";
public static final String VNFC_NAME = "vnfc-name";
+ public static final String AAI_VNF_TYPE ="aai-vnf-type";
}