AT&T 1712 and 1802 release code
[so.git] / asdc-controller / src / main / java / org / openecomp / mso / asdc / client / ASDCConfiguration.java
index bb4b965..98c7173 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -53,6 +53,9 @@ public class ASDCConfiguration implements IConfiguration {
 
     public static final String MSO_PROP_ASDC = "MSO_PROP_ASDC";
     public static final String PARAMETER_PATTERN = "asdc-connections";
+    public static final String MSG_BUS_ADDRESS_ATTRIBUTE_NAME = "messageBusAddress";
+    public static final String COMPONENT_NAMES_ADDRESS_ATTRIBUTE_NAME = "componentNames";
+    public static final String WATCHDOG_TIMEOUT_NAME = "watchDogTimeout";
 
     public static final String CONSUMER_GROUP_ATTRIBUTE_NAME = "consumerGroup";
     public static final String CONSUMER_ID_ATTRIBUTE_NAME = "consumerId";
@@ -113,14 +116,46 @@ public class ASDCConfiguration implements IConfiguration {
 
     }
     
+    @Override
     public java.lang.Boolean isUseHttpsWithDmaap() {
        return false;
     }
+    
+    @Override
+    public boolean isConsumeProduceStatusTopic(){
+       return true;
+    }
+    
+    @Override
+    public List<String> getMsgBusAddress(){
+
+       JsonNode masterConfigNode = getASDCControllerConfigJsonNode ();
+        if (masterConfigNode != null && masterConfigNode.get (MSG_BUS_ADDRESS_ATTRIBUTE_NAME) != null) {
+            List<String> msgAddressList = new ArrayList<>();
+            
+            Iterator<JsonNode> config = masterConfigNode.get(MSG_BUS_ADDRESS_ATTRIBUTE_NAME).elements();
+      
+            while( config.hasNext() ) {
+                String key = (String)config.next().asText();
+                msgAddressList.add(key);
+            }
 
+            if ("NULL".equals (msgAddressList) || msgAddressList.isEmpty ()) {
+                return null;
+            } else {
+                return msgAddressList;
+            }
+        } else {
+            return null;
+        } 
+       
+       
+    }
+    
     public String getAsdcControllerName () {
         return asdcControllerName;
     }
-
+    
     private JsonNode getASDCControllerConfigJsonNode () {
         if (this.msoProperties.getJsonRootNode ().get (PARAMETER_PATTERN) != null) {
             return this.msoProperties.getJsonRootNode ().get (PARAMETER_PATTERN).get (this.asdcControllerName);
@@ -184,6 +219,16 @@ public class ASDCConfiguration implements IConfiguration {
             return null;
         }
     }
+    
+    public int getWatchDogTimeout () {
+        JsonNode masterConfigNode = getASDCControllerConfigJsonNode ();
+        if (masterConfigNode != null && masterConfigNode.get (WATCHDOG_TIMEOUT_NAME) != null) {
+               
+            return masterConfigNode.get (WATCHDOG_TIMEOUT_NAME).asInt ();
+        } else {
+            return 0;
+        }
+    }
 
     @Override
     public String getConsumerID () {
@@ -376,6 +421,11 @@ public class ASDCConfiguration implements IConfiguration {
             throw new ASDCParametersException (POLLING_TIMEOUT_ATTRIBUTE_NAME
                                                + " parameter cannot be found in config mso.properties");
         }
+        
+        if (this.getWatchDogTimeout() == 0) {
+            throw new ASDCParametersException (WATCHDOG_TIMEOUT_NAME
+                                               + " parameter cannot be found in config mso.properties");
+        }
 
         if (this.getRelevantArtifactTypes () == null || this.getRelevantArtifactTypes ().isEmpty ()) {
             throw new ASDCParametersException (RELEVANT_ARTIFACT_TYPES_ATTRIBUTE_NAME
@@ -386,6 +436,12 @@ public class ASDCConfiguration implements IConfiguration {
             throw new ASDCParametersException (USER_ATTRIBUTE_NAME
                                                + " parameter cannot be found in config mso.properties");
         }
+                
+        if (this.getMsgBusAddress() == null || this.getMsgBusAddress().isEmpty ()) {
+            throw new ASDCParametersException (MSG_BUS_ADDRESS_ATTRIBUTE_NAME
+                                               + " parameter cannot be found in config mso.properties");
+        }
+        
     }
 
     /**
@@ -399,7 +455,7 @@ public class ASDCConfiguration implements IConfiguration {
 
         MsoJsonProperties msoProp;
         try {
-            List <String> result = new ArrayList <String> ();
+            List <String> result = new ArrayList<>();
             msoProp = new MsoPropertiesFactory ().getMsoJsonProperties (MSO_PROP_ASDC);
 
             if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) {