aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-network-inventory-client/provider
diff options
context:
space:
mode:
Diffstat (limited to 'appc-outbound/appc-network-inventory-client/provider')
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java144
1 files changed, 68 insertions, 76 deletions
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java
index f9aa42d7c..87bcb6cc8 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java
@@ -28,7 +28,6 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
-
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
@@ -39,101 +38,97 @@ import org.onap.appc.instar.interfaceImpl.InterfaceIpAddressImpl;
import org.onap.appc.instar.interfaces.RestClientInterface;
import org.onap.appc.instar.interfaces.RuleHandlerInterface;
import org.onap.appc.instar.utils.InstarClientConstant;
-import org.onap.sdnc.config.params.data.Parameter;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.sdnc.config.params.data.Parameter;
+
+public class InstarClientNode implements SvcLogicJavaPlugin {
-public class InstarClientNode implements SvcLogicJavaPlugin
-{
private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarClientNode.class);
public void getInstarInfo(Map<String, String> inParams, SvcLogicContext ctx)
- throws SvcLogicException{
+ throws SvcLogicException {
log.info("Received getInstarInfo call with params : " + inParams);
- String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try
- {
+ String responsePrefix = inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try {
responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
- String [] instarKeys = getKeys(inParams.get(InstarClientConstant.INSTAR_KEYS));
- for (String instarKey : instarKeys){
+ String[] instarKeys = getKeys(inParams.get(InstarClientConstant.INSTAR_KEYS));
+ for (String instarKey : instarKeys) {
log.info("Processing Key : " + instarKey);
log.info("Searching key for : " + "INSTAR." + instarKey);
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- RuleHandlerInterface handler = null;
+ RuleHandlerInterface handler;
log.info("Received Context : " + ctx.getAttribute("INSTAR." + instarKey));
- Parameter params = mapper.readValue(ctx.getAttribute(InstarClientConstant.SOURCE_SYSTEM_INSTAR + "." + instarKey), Parameter.class);
+ Parameter params = mapper
+ .readValue(ctx.getAttribute(InstarClientConstant.SOURCE_SYSTEM_INSTAR + "." + instarKey),
+ Parameter.class);
- log.info("Processing rule Type : " + params.getRuleType());
- switch(params.getRuleType()){
- case InstarClientConstant.INTERFACE_IP_ADDRESS:
- handler = new InterfaceIpAddressImpl(params, ctx);
- break;
- default:
- throw new Exception("No Rule Defined to process :" + params.getRuleType());
+ log.info("Processing rule Type : " + params.getRuleType());
+ if (params.getRuleType().equals(InstarClientConstant.INTERFACE_IP_ADDRESS)) {
+ handler = new InterfaceIpAddressImpl(params, ctx);
+ } else {
+ throw new SvcLogicException("No Rule Defined to process :" + params.getRuleType());
}
handler.processRule();
-
}
log.info("responsePrefix =" + responsePrefix);
- ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, ctx.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES,
+ ctx.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS,
+ InstarClientConstant.OUTPUT_STATUS_SUCCESS);
ctx.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, null);
- }
- catch (Exception e)
- {
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE);
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS,
+ InstarClientConstant.OUTPUT_STATUS_FAILURE);
ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
- log.error("Failed processing Instar request" + e.getMessage());
- e.printStackTrace();
+ log.error("Failed processing Instar request", e);
throw new SvcLogicException(e.getMessage());
}
}
- private static String[] getKeys(String keyString) {
- String fn = "InstarClientNode.getKeys";
- System.out.println("Received Key String as :" + keyString);
- keyString = keyString.replace("[","");
- keyString = keyString.replace("]", "");
- keyString = keyString.replace("\"", "");
- if(keyString.contains(","))
- {
- String[] keys = keyString.split(",");
- return keys;
- }
- else{
- String[] keys = {keyString};
- return keys;
- }
+ private static String[] getKeys(String keyString) {
+ log.error("Received Key String as :" + keyString);
+
+ String key = keyString
+ .replace("[", "")
+ .replace("]", "")
+ .replace("\"", "");
+
+ if (key.contains(",")) {
+ return key.split(",");
+ } else {
+ return new String[]{key};
+ }
}
+
public void getInstarData(Map<String, String> inParams, SvcLogicContext ctx)
- throws SvcLogicException{
- log.info("Received getInstarData call with params : " + inParams);
- String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try
- {
- HashMap<String, String> input = new HashMap<String, String>();
- input.putAll(inParams);
- RestClientInterface rcINterface = new InstarRestClientImpl(input);
- String response = rcINterface.sendRequest(inParams.get("operationName"));
+ throws SvcLogicException {
+ log.info("Received getInstarData call with params : " + inParams);
+ String responsePrefix = inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try {
+ HashMap<String, String> input = new HashMap<>();
+ input.putAll(inParams);
+ RestClientInterface rcINterface = new InstarRestClientImpl(input);
+ String response = rcINterface.sendRequest(inParams.get("operationName"));
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS);
- ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, response);
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS,
+ InstarClientConstant.OUTPUT_STATUS_SUCCESS);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, response);
- }
- catch (Exception e)
- {
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
- log.error("Failed processing Instar request" + e.getMessage());
- e.printStackTrace();
- throw new SvcLogicException(e.getMessage());
- }
- }
-public void getAaiInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS,
+ InstarClientConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
+ log.error("Failed processing Instar request", e);
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+
+ public void getAaiInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
log.info("Received getAaiInfo call with params : " + inParams);
- String responsePrefix = (String) inParams.get(AaiClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ String responsePrefix = inParams.get(AaiClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
try {
responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
String[] aaiKeys = getKeys(inParams.get(AaiClientConstant.AAI_KEYS));
@@ -141,28 +136,25 @@ public void getAaiInfo(Map<String, String> inParams, SvcLogicContext ctx) throws
log.info("Processing Key : " + aaiKey);
log.info("Searching key for : " + "AAI." + aaiKey);
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- RuleHandlerInterface handler = null;
+ RuleHandlerInterface handler;
log.info("Received Context : " + ctx.getAttribute("AAI." + aaiKey));
Parameter params = mapper.readValue(
- ctx.getAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + aaiKey), Parameter.class);
+ ctx.getAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + aaiKey), Parameter.class);
log.info("Processing rule Type : " + params.getRuleType());
handler = new AaiInterfaceRulesHandler(params, ctx);
handler.processRule();
-
}
-
log.info("responsePrefix =" + responsePrefix);
ctx.setAttribute(responsePrefix + AaiClientConstant.AAI_KEY_VALUES,
- ctx.getAttribute(AaiClientConstant.AAI_KEY_VALUES));
+ ctx.getAttribute(AaiClientConstant.AAI_KEY_VALUES));
ctx.setAttribute(responsePrefix + AaiClientConstant.OUTPUT_PARAM_STATUS,
- AaiClientConstant.OUTPUT_STATUS_SUCCESS);
+ AaiClientConstant.OUTPUT_STATUS_SUCCESS);
ctx.setAttribute(AaiClientConstant.AAI_KEY_VALUES, null);
} catch (Exception e) {
ctx.setAttribute(responsePrefix + AaiClientConstant.OUTPUT_PARAM_STATUS,
- InstarClientConstant.OUTPUT_STATUS_FAILURE);
+ InstarClientConstant.OUTPUT_STATUS_FAILURE);
ctx.setAttribute(responsePrefix + AaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
- log.error("Failed processing AAI data" + e.getMessage());
- e.printStackTrace();
+ log.error("Failed processing AAI data", e);
throw new SvcLogicException(e.getMessage());
}
}