Fix cluster object to use http port 63/43763/1
authordglFromAtt <dgl@research.att.com>
Thu, 19 Apr 2018 22:06:04 +0000 (18:06 -0400)
committerdglFromAtt <dgl@research.att.com>
Thu, 19 Apr 2018 22:06:12 +0000 (18:06 -0400)
Change-Id: I8cf3f4caf4701be7fd95bb35f94f75592d7b4c05
Signed-off-by: dglFromAtt <dgl@research.att.com>
Issue-ID: DMAAP-295

pom.xml
src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java
src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java
src/test/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResourceTest.java
version.properties

diff --git a/pom.xml b/pom.xml
index a95b13f..22dcc7a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <jettyVersion>9.3.9.v20160517</jettyVersion> 
                <eelf.version>0.0.1</eelf.version>
-               <artifact.version>1.0.4-SNAPSHOT</artifact.version>
+               <artifact.version>1.0.5-SNAPSHOT</artifact.version>
                <!-- SONAR -->
                <jacoco.version>0.7.7.201606060606</jacoco.version>
                <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
index a8ace78..4db6ca3 100644 (file)
@@ -54,37 +54,31 @@ public class MrProvConnection extends BaseLoggingClass{
 
        
        private String topicMgrCred;
+       private boolean useAAF;
+       private String  user;
+       private String  encPwd;
        
-       private String getCred( ) {
+       public MrProvConnection() {
                String mechIdProperty = "aaf.TopicMgrUser";
                String pwdProperty = "aaf.TopicMgrPassword";
                DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
-               logger.info( "templog:getCred: 10");
+               user = p.getProperty( mechIdProperty, "noMechId@domain.netset.com" );
+               encPwd = p.getProperty( pwdProperty, "notSet" );
+               useAAF= "true".equalsIgnoreCase(p.getProperty("UseAAF", "false"));
+               topicMgrCred =  getCred();
+               
+       }
+       
+       private String getCred( ) {
 
-               String user = p.getProperty( mechIdProperty, "noMechId@domain.netset.com" );
-               logger.info( "templog:getCred: 20");
 
                String pwd = "";
-               String encPwd = p.getProperty( pwdProperty, "notSet" );
-               logger.info( "templog:getCred: 30");
-
-               AafDecrypt decryptor = new AafDecrypt();
-               logger.info( "templog:getCred: 40");
+               AafDecrypt decryptor = new AafDecrypt();        
                pwd = decryptor.decrypt(encPwd);
-               logger.info( "templog:getCred: 50");
-       
-               return user + ":" + pwd;
-               
-               
-               
+               return user + ":" + pwd;        
        }
        
        
-       public MrProvConnection( ) {
-               topicMgrCred =  getCred();
-
-       }
-       
        public boolean makeTopicConnection( MR_Cluster cluster ) {
                logger.info( "connect to cluster: " + cluster.getDcaeLocationName());
        
@@ -162,8 +156,12 @@ public class MrProvConnection extends BaseLoggingClass{
                try {
                        byte[] postData = postTopic.getBytes();
                        logger.info( "post fields=" + postData.toString() );
-                       uc.setRequestProperty("Authorization", auth);
-                       logger.info( "Authenticating with " + auth );
+                       
+                       // when not using AAF, do not attempt Basic Authentication
+                       if ( useAAF ) {
+                               uc.setRequestProperty("Authorization", auth);
+                               logger.info( "Authenticating with " + auth );
+                       }
                        uc.setRequestMethod("POST");
                        uc.setRequestProperty("Content-Type", "application/json");
                        uc.setRequestProperty( "charset", "utf-8");
index e1ea955..18fdeba 100644 (file)
@@ -47,13 +47,14 @@ public class MrTopicConnection extends BaseLoggingClass  {
        
        private  String mmProvCred; 
        private String unit_test;
-       
+       private boolean useAAF;
 
 
        public MrTopicConnection(String user, String pwd ) {
                mmProvCred = new String( user + ":" + pwd );
                DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
         unit_test = p.getProperty( "UnitTest", "No" );
+       useAAF= "true".equalsIgnoreCase(p.getProperty("UseAAF", "false"));
        }
        
        public boolean makeTopicConnection( MR_Cluster cluster, String topic, String overrideFqdn ) {
@@ -126,8 +127,10 @@ public class MrTopicConnection extends BaseLoggingClass  {
                try {
                        byte[] postData = postMessage.getBytes();
                        logger.info( "post fields=" + postMessage );
-                       uc.setRequestProperty("Authorization", auth);
-                       logger.info( "Authenticating with " + auth );
+                       if ( useAAF ) {
+                               uc.setRequestProperty("Authorization", auth);
+                               logger.info( "Authenticating with " + auth );
+                       }
                        uc.setRequestMethod("POST");
                        uc.setRequestProperty("Content-Type", "application/json");
                        uc.setRequestProperty( "charset", "utf-8");
index 8185083..a6827a9 100644 (file)
@@ -31,7 +31,6 @@ public class MR_Cluster extends DmaapObject {
 
        private String dcaeLocationName;
        private String fqdn;
-       private String[] hosts;
        private DmaapTimestamp lastMod;
        private String  topicProtocol;
        private String  topicPort;
@@ -47,7 +46,6 @@ public class MR_Cluster extends DmaapObject {
        public MR_Cluster() {
                this.topicProtocol = defaultTopicProtocol;
                this.topicPort = defaultTopicPort;
-               this.hosts = new String[3];
                this.lastMod = new DmaapTimestamp();
                this.lastMod.mark();
 
@@ -55,24 +53,7 @@ public class MR_Cluster extends DmaapObject {
                
        }
        
-       // Deprecate this constructor
-       public MR_Cluster( String dLN,
-                                               String f,
-                                               String a,
-                                               String[] h ) {
-               this.dcaeLocationName = dLN;
-               this.fqdn = f;
-               this.hosts = new String[3];
-               this.hosts[0] = h[0];
-               this.hosts[1] = h[1];
-               this.hosts[2] = h[2];
-               this.topicProtocol = defaultTopicProtocol;
-               this.topicPort = defaultTopicPort;
-               this.lastMod = new DmaapTimestamp();
-               this.lastMod.mark();
 
-               debugLogger.debug( "depracated MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
-       }
        
        // new style constructor
        public MR_Cluster( String dLN,
@@ -81,12 +62,19 @@ public class MR_Cluster extends DmaapObject {
                        String port ) {
                this.dcaeLocationName = dLN;
                this.fqdn = f;
-               this.hosts = new String[3];
-               this.hosts[0] = fqdn;
-               this.hosts[1] = fqdn;
-               this.hosts[2] = fqdn;
-               this.topicProtocol = prot;
-               this.topicPort = port;
+
+               if ( prot == null || prot.isEmpty() ) {
+                       this.topicProtocol = defaultTopicProtocol;
+               } else {
+                       this.topicProtocol = prot;
+               }
+               if ( port == null || port.isEmpty() ) {
+                       this.topicPort = defaultTopicPort;
+               } else {
+                       this.topicPort = port;
+               }
+               
+               
                this.lastMod = new DmaapTimestamp();
                this.lastMod.mark();
                
@@ -108,13 +96,6 @@ public class MR_Cluster extends DmaapObject {
                this.fqdn = fqdn;
        }
 
-       public String[] getHosts() {
-               return hosts;
-       }
-
-       public void setHosts(String[] hosts) {
-               this.hosts = hosts;
-       }
 
        public String getTopicProtocol() {
                return topicProtocol;
index df102e3..ebe7b1e 100644 (file)
@@ -59,8 +59,6 @@ public class MR_ClusterTest {
        public void testMR_ClusterClassConstructor() {
 
                MR_Cluster t = new MR_Cluster( d, fqdn, "http", "3904");
-
-               t.getHosts();
        
                assertTrue( t.getDcaeLocationName() == d  );
                assertTrue( t.getFqdn() == fqdn  );
@@ -70,8 +68,6 @@ public class MR_ClusterTest {
        public void testw3() {
 
                MR_Cluster t = new MR_Cluster();
-               String[] h = { "host1", "host2", "host3" };
-               t.setHosts( h );
        
                assertTrue( t.getDcaeLocationName() == null  );
                assertTrue( t.getFqdn() == null  );
index 4d4c731..2ff17d8 100644 (file)
@@ -111,7 +111,7 @@ public class MR_ClusterResourceTest extends JerseyTest {
                }
 
                // now change a field
-               cluster.setHosts( h );
+
                reqEntity = Entity.entity( cluster, MediaType.APPLICATION_JSON );
 
                // update with incorrect key
index d49958a..5416ded 100644 (file)
@@ -27,7 +27,7 @@
 
 major=1
 minor=0
-patch=4
+patch=5
 base_version=${major}.${minor}.${patch}
 
 # Release must be completed with git revision # in Jenkins