aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-config-params/provider/src
diff options
context:
space:
mode:
authorkusuma kumari M <km583p@att.com>2017-11-21 12:06:29 -0500
committerPatrick Brady <pb071s@att.com>2017-11-21 18:25:19 +0000
commit322cee74e47be24a8001e89d5f3e268efff2245f (patch)
treed02c2beb9d345401dda46c137eeb669a6c198f26 /appc-config/appc-config-params/provider/src
parentd46ebc90676ca287b167de7991d4c05ce321bbc2 (diff)
Bug Fixes in DG's chef ,Ansible and Encry tool
Issue-ID: APPC-320 Change-Id: I7ba57aa0018fa415987dee98d8d4d8a21453dbd0 Signed-off-by: kusuma kumari M <km583p@att.com>
Diffstat (limited to 'appc-config/appc-config-params/provider/src')
-rw-r--r--appc-config/appc-config-params/provider/src/main/java/org/openecomp/sdnc/config/params/parser/PropertyDefinitionNode.java392
1 files changed, 196 insertions, 196 deletions
diff --git a/appc-config/appc-config-params/provider/src/main/java/org/openecomp/sdnc/config/params/parser/PropertyDefinitionNode.java b/appc-config/appc-config-params/provider/src/main/java/org/openecomp/sdnc/config/params/parser/PropertyDefinitionNode.java
index 8948e02e1..4916c46a8 100644
--- a/appc-config/appc-config-params/provider/src/main/java/org/openecomp/sdnc/config/params/parser/PropertyDefinitionNode.java
+++ b/appc-config/appc-config-params/provider/src/main/java/org/openecomp/sdnc/config/params/parser/PropertyDefinitionNode.java
@@ -48,202 +48,202 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
public class PropertyDefinitionNode implements SvcLogicJavaPlugin{
- private static final EELFLogger log = EELFManager.getInstance().getLogger(PropertyDefinitionNode.class);
-
- public void processMissingParamKeys(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
- log.info("Received processParamKeys call with params : " + inParams);
- String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try{
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
-
- String requestParamJson = inParams.get(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA);
- String pdContent = inParams.get(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT);
-
- if(StringUtils.isBlank(pdContent)){
- throw new Exception("Request Param (pdContent) is Missing ..");
- }
-
- if(StringUtils.isBlank(requestParamJson)){
- throw new Exception("Request Param (jsonData) is Missing ..");
- }
-
- PropertyDefinition propertyDefinition = parsePDContent(pdContent);
- if(propertyDefinition != null){
- requestParamJson = mergeMissingRequestParamFromPD(propertyDefinition, requestParamJson);
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_CONFIGURATION_PARAMETER, requestParamJson);
- }
-
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
- } catch (Exception e) {
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,e.getMessage());
- log.error("Failed in merging data to template " + e.getMessage());
- throw new SvcLogicException(e.getMessage());
- }
- }
-
- public void processExternalSystemParamKeys(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
- log.info("Received processExternalSystemParamKeys call with params : " + inParams);
- String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try{
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
-
- String requestParamJson = inParams.get(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA);
- String pdContent = inParams.get(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT);
- String systemName = inParams.get(ParamsHandlerConstant.INPUT_PARAM_SYSTEM_NAME);
-
-
- if(StringUtils.isBlank(pdContent)){
- throw new Exception("Request Param (pdContent) is Missing ..");
- }
-
- if(StringUtils.isBlank(requestParamJson)){
- throw new Exception("Request Param (jsonData) is Missing ..");
- }
-
- if(StringUtils.isBlank(systemName)){
- throw new Exception("Request Param (systemName) is Missing ..");
- }
-
- PropertyDefinition propertyDefinition = parsePDContent(pdContent);
- if(propertyDefinition != null){
- getSystemRequestParamInfoFromPD(propertyDefinition, requestParamJson, systemName, ctx);
- }
-
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
- } catch (Exception e) {
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,e.getMessage());
- log.error("Failed in merging data to template " + e.getMessage());
- throw new SvcLogicException(e.getMessage());
- }
- }
-
-
- public void mergeJsonData(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
- log.info("Received mergeJsonData call with params : " + inParams);
- String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try{
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
-
- String requestParamJson = inParams.get(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA);
- String mergeJsonData = inParams.get(ParamsHandlerConstant.INPUT_PARAM_MERGE__JSON_DATA);
-
- if(StringUtils.isBlank(requestParamJson)){
- throw new Exception("Request Param (jsonData) is Missing ..");
- }
-
- if(StringUtils.isBlank(mergeJsonData)){
- throw new Exception("Request Param (mergeJsonData) is Missing ..");
- }
-
- requestParamJson = mergeJson(requestParamJson, mergeJsonData);
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_CONFIGURATION_PARAMETER, requestParamJson);
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
- } catch (Exception e) {
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,e.getMessage());
- log.error("Failed in merging data to template " + e.getMessage());
- throw new SvcLogicException(e.getMessage());
- }
- }
-
-
- /* */
-
- private PropertyDefinition parsePDContent(String pdContent) throws JsonParseException, JsonMappingException, IOException{
- PropertyDefinition propertyDefinition = null;
- if(StringUtils.isNotBlank(pdContent)){
- ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- propertyDefinition = mapper.readValue(pdContent, PropertyDefinition.class);
- }
- return propertyDefinition;
- }
-
-
- private String mergeMissingRequestParamFromPD(PropertyDefinition propertyDefinition, String requestParamJson) throws Exception{
-
- if(propertyDefinition == null){
- throw new Exception("PropertyDefinition is Missing ..");
- }
-
- if(StringUtils.isBlank(requestParamJson)){
- throw new Exception("Request Param is Missing ..");
- }
-
- ObjectMapper mapper = new ObjectMapper();
- Map<String, String> requestParamMap = mapper.readValue(requestParamJson, HashMap.class);
- if(requestParamMap != null){
- List<Parameter> parameters = propertyDefinition.getParameters();
- for (Parameter parameter : parameters) {
- if(parameter != null){
-
- log.info("Checking Key " + parameter.getName() + ":: Source :" +parameter.getSource());
- // Add Only non external system keys,If it is not present in request Params
- if( !requestParamMap.containsKey(parameter.getName())
- && StringUtils.isBlank(parameter.getSource())
- ){
- log.info("Adding New Key " + parameter.getName());
- requestParamMap.put(parameter.getName(), parameter.getDefaultValue());
- }
- }
- }
- requestParamJson = mapper.writeValueAsString(requestParamMap);
- log.info("Processed Request Param " + requestParamJson);
- }
-
- return requestParamJson;
- }
-
- private void getSystemRequestParamInfoFromPD(PropertyDefinition propertyDefinition, String requestParamJson, String systemName, SvcLogicContext ctx) throws Exception{
-
- if(propertyDefinition == null){
- throw new Exception("PropertyDefinition is Missing ..");
- }
-
- if(StringUtils.isBlank(requestParamJson)){
- throw new Exception("Request Param is Missing ..");
- }
-
- ObjectMapper mapper = new ObjectMapper();
- Map<String, String> requestParamMap = mapper.readValue(requestParamJson, HashMap.class);
- if(requestParamMap != null){
- List<Parameter> parameters = propertyDefinition.getParameters();
-
- List<String> externalSystemKeys = new ArrayList<String>();
- for (Parameter parameter : parameters) {
- if(parameter != null){
- if( !requestParamMap.containsKey(parameter.getName()) && StringUtils.isNotBlank(parameter.getSource()) ){
- log.info("Adding New System Key " + parameter.getName() + ":"+ mapper.writeValueAsString(parameter));
- externalSystemKeys.add(parameter.getName());
- ctx.setAttribute(systemName +"."+parameter.getName(), mapper.writeValueAsString(parameter));
- }
- }
- }
-
- String systemKeys = systemName+".keys";
- ctx.setAttribute(systemKeys, mapper.writeValueAsString(externalSystemKeys));
- }
- }
-
-
- private String mergeJson(String requestParamJson, String systemParamJson) throws Exception {
- ObjectMapper mapper = new ObjectMapper();
- Map<String, String> requestParamMap = mapper.readValue(requestParamJson, HashMap.class);
- if(requestParamMap != null){
- Map<String, String> systemParamMap = mapper.readValue(systemParamJson, HashMap.class);
- if(systemParamMap != null){
- for (String systemParamKey : systemParamMap.keySet()) {
- log.trace("Megging System Key Values " + systemParamKey);
- requestParamMap.put( systemParamKey , systemParamMap.get(systemParamKey));
- }
- }
- requestParamJson = mapper.writeValueAsString(requestParamMap);
- log.info("Processed Request Param " + requestParamJson);
- }
-
- return requestParamJson;
- }
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(PropertyDefinitionNode.class);
+
+ public void processMissingParamKeys(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ log.info("Received processParamKeys call with params : " + inParams);
+ String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try{
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
+
+ String requestParamJson = inParams.get(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA);
+ String pdContent = inParams.get(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT);
+
+ if(StringUtils.isBlank(pdContent)){
+ throw new Exception("Request Param (pdContent) is Missing ..");
+ }
+
+ if(StringUtils.isBlank(requestParamJson)){
+ throw new Exception("Request Param (jsonData) is Missing ..");
+ }
+
+ PropertyDefinition propertyDefinition = parsePDContent(pdContent);
+ if(propertyDefinition != null){
+ requestParamJson = mergeMissingRequestParamFromPD(propertyDefinition, requestParamJson);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_CONFIGURATION_PARAMETER, requestParamJson);
+ }
+
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,e.getMessage());
+ log.error("Failed in merging data to template " + e.getMessage());
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+
+ public void processExternalSystemParamKeys(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ log.info("Received processExternalSystemParamKeys call with params : " + inParams);
+ String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try{
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
+
+ String requestParamJson = inParams.get(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA);
+ String pdContent = inParams.get(ParamsHandlerConstant.INPUT_PARAM_PD_CONTENT);
+ String systemName = inParams.get(ParamsHandlerConstant.INPUT_PARAM_SYSTEM_NAME);
+
+
+ if(StringUtils.isBlank(pdContent)){
+ throw new Exception("Request Param (pdContent) is Missing ..");
+ }
+
+ if(StringUtils.isBlank(requestParamJson)){
+ throw new Exception("Request Param (jsonData) is Missing ..");
+ }
+
+ if(StringUtils.isBlank(systemName)){
+ throw new Exception("Request Param (systemName) is Missing ..");
+ }
+
+ PropertyDefinition propertyDefinition = parsePDContent(pdContent);
+ if(propertyDefinition != null){
+ getSystemRequestParamInfoFromPD(propertyDefinition, requestParamJson, systemName, ctx);
+ }
+
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,e.getMessage());
+ log.error("Failed in merging data to template " + e.getMessage());
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+
+
+ public void mergeJsonData(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ log.info("Received mergeJsonData call with params : " + inParams);
+ String responsePrefix = inParams.get(ParamsHandlerConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try{
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
+
+ String requestParamJson = inParams.get(ParamsHandlerConstant.INPUT_PARAM_JSON_DATA);
+ String mergeJsonData = inParams.get(ParamsHandlerConstant.INPUT_PARAM_MERGE__JSON_DATA);
+
+ if(StringUtils.isBlank(requestParamJson)){
+ throw new Exception("Request Param (jsonData) is Missing ..");
+ }
+
+ if(StringUtils.isBlank(mergeJsonData)){
+ throw new Exception("Request Param (mergeJsonData) is Missing ..");
+ }
+
+ requestParamJson = mergeJson(requestParamJson, mergeJsonData);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_CONFIGURATION_PARAMETER, requestParamJson);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_SUCCESS);
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_STATUS, ParamsHandlerConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + ParamsHandlerConstant.OUTPUT_PARAM_ERROR_MESSAGE,e.getMessage());
+ log.error("Failed in merging data to template " + e.getMessage());
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+
+
+ /* */
+
+ private PropertyDefinition parsePDContent(String pdContent) throws JsonParseException, JsonMappingException, IOException{
+ PropertyDefinition propertyDefinition = null;
+ if(StringUtils.isNotBlank(pdContent)){
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ propertyDefinition = mapper.readValue(pdContent, PropertyDefinition.class);
+ }
+ return propertyDefinition;
+ }
+
+
+ private String mergeMissingRequestParamFromPD(PropertyDefinition propertyDefinition, String requestParamJson) throws Exception{
+
+ if(propertyDefinition == null){
+ throw new Exception("PropertyDefinition is Missing ..");
+ }
+
+ if(StringUtils.isBlank(requestParamJson)){
+ throw new Exception("Request Param is Missing ..");
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, String> requestParamMap = mapper.readValue(requestParamJson, HashMap.class);
+ if(requestParamMap != null){
+ List<Parameter> parameters = propertyDefinition.getParameters();
+ for (Parameter parameter : parameters) {
+ if(parameter != null){
+
+ log.info("Checking Key " + parameter.getName() + ":: Source :" +parameter.getSource());
+ // Add Only non external system keys,If it is not present in request Params
+ if( !requestParamMap.containsKey(parameter.getName())
+ && StringUtils.isBlank(parameter.getSource())
+ ){
+ log.info("Adding New Key " + parameter.getName());
+ requestParamMap.put(parameter.getName(), parameter.getDefaultValue());
+ }
+ }
+ }
+ requestParamJson = mapper.writeValueAsString(requestParamMap);
+ log.info("Processed Request Param " + requestParamJson);
+ }
+
+ return requestParamJson;
+ }
+
+ private void getSystemRequestParamInfoFromPD(PropertyDefinition propertyDefinition, String requestParamJson, String systemName, SvcLogicContext ctx) throws Exception{
+
+ if(propertyDefinition == null){
+ throw new Exception("PropertyDefinition is Missing ..");
+ }
+
+ if(StringUtils.isBlank(requestParamJson)){
+ throw new Exception("Request Param is Missing ..");
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, String> requestParamMap = mapper.readValue(requestParamJson, HashMap.class);
+ if(requestParamMap != null){
+ List<Parameter> parameters = propertyDefinition.getParameters();
+
+ List<String> externalSystemKeys = new ArrayList<String>();
+ for (Parameter parameter : parameters) {
+ if(parameter != null){
+ if( !requestParamMap.containsKey(parameter.getName()) && StringUtils.isNotBlank(parameter.getSource()) && !StringUtils.equalsIgnoreCase(parameter.getSource(),"Manual") ){
+ log.info("Adding New System Key " + parameter.getName() + ":"+ mapper.writeValueAsString(parameter));
+ externalSystemKeys.add(parameter.getName());
+ ctx.setAttribute(systemName +"."+parameter.getName(), mapper.writeValueAsString(parameter));
+ }
+ }
+ }
+
+ String systemKeys = systemName+".keys";
+ ctx.setAttribute(systemKeys, mapper.writeValueAsString(externalSystemKeys));
+ }
+ }
+
+
+ private String mergeJson(String requestParamJson, String systemParamJson) throws Exception {
+ ObjectMapper mapper = new ObjectMapper();
+ Map<String, String> requestParamMap = mapper.readValue(requestParamJson, HashMap.class);
+ if(requestParamMap != null){
+ Map<String, String> systemParamMap = mapper.readValue(systemParamJson, HashMap.class);
+ if(systemParamMap != null){
+ for (String systemParamKey : systemParamMap.keySet()) {
+ log.trace("Megging System Key Values " + systemParamKey);
+ requestParamMap.put( systemParamKey , systemParamMap.get(systemParamKey));
+ }
+ }
+ requestParamJson = mapper.writeValueAsString(requestParamMap);
+ log.info("Processed Request Param " + requestParamJson);
+ }
+
+ return requestParamJson;
+ }