Fix cluster object to use http port
[dmaap/dbcapi.git] / src / main / java / org / onap / dmaap / dbcapi / model / MR_Cluster.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.dmaap
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.dmaap.dbcapi.model;
22
23 import javax.xml.bind.annotation.XmlRootElement;
24
25 import org.onap.dmaap.dbcapi.util.DmaapTimestamp;
26
27
28
29 @XmlRootElement
30 public class MR_Cluster extends DmaapObject {
31
32         private String dcaeLocationName;
33         private String fqdn;
34         private DmaapTimestamp lastMod;
35         private String  topicProtocol;
36         private String  topicPort;
37
38         
39         // TODO: make this a system property
40         private static String defaultTopicProtocol = "https";
41         private static String defaultTopicPort = "3905";
42         
43
44
45
46         public MR_Cluster() {
47                 this.topicProtocol = defaultTopicProtocol;
48                 this.topicPort = defaultTopicPort;
49                 this.lastMod = new DmaapTimestamp();
50                 this.lastMod.mark();
51
52                 debugLogger.debug( "MR_Cluster constructor " + this.lastMod );
53                 
54         }
55         
56
57         
58         // new style constructor
59         public MR_Cluster( String dLN,
60                         String f,
61                         String prot,
62                         String port ) {
63                 this.dcaeLocationName = dLN;
64                 this.fqdn = f;
65
66                 if ( prot == null || prot.isEmpty() ) {
67                         this.topicProtocol = defaultTopicProtocol;
68                 } else {
69                         this.topicProtocol = prot;
70                 }
71                 if ( port == null || port.isEmpty() ) {
72                         this.topicPort = defaultTopicPort;
73                 } else {
74                         this.topicPort = port;
75                 }
76                 
77                 
78                 this.lastMod = new DmaapTimestamp();
79                 this.lastMod.mark();
80                 
81                 debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
82 }
83         public String getDcaeLocationName() {
84                 return dcaeLocationName;
85         }
86
87         public void setDcaeLocationName(String dcaeLocationName) {
88                 this.dcaeLocationName = dcaeLocationName;
89         }
90
91         public String getFqdn() {
92                 return fqdn;
93         }
94
95         public void setFqdn(String fqdn) {
96                 this.fqdn = fqdn;
97         }
98
99
100         public String getTopicProtocol() {
101                 return topicProtocol;
102         }
103
104         public void setTopicProtocol(String topicProtocol) {
105                 this.topicProtocol = topicProtocol;
106         }
107
108         public String getTopicPort() {
109                 return topicPort;
110         }
111
112         public void setTopicPort(String topicPort) {
113                 this.topicPort = topicPort;
114         }
115
116
117
118         public String genTopicURL(String overideFqdn, String topic) {
119
120                 StringBuilder str = new StringBuilder( topicProtocol );
121                 str.append("://")
122                         .append( overideFqdn != null ? overideFqdn : fqdn)
123                         .append(":")
124                         .append(topicPort)
125                         .append("/events/")
126                         .append(topic);
127                 
128                 return str.toString();
129
130
131         }
132
133
134 }