aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsliard <samuel.liard@gmail.com>2021-04-26 13:01:20 +0200
committersliard <samuel.liard@gmail.com>2021-04-30 16:27:56 +0200
commit65aaa3eb6fb0de267819431f7831100ec162de92 (patch)
tree26fbb6f2087822e8b6ce562ddf71fd5291608e04
parente8246bdd3081196ef847674d406470a265c7d5a8 (diff)
Sonar issues review, fix properties constant name.
Issue-ID: DMAAP-1585 Signed-off-by: sliard <samuel.liard@gmail.com> Change-Id: Ic8152c42bb708c825b345dcbd8ac6c240fff66dd
-rw-r--r--src/main/java/org/onap/dmaap/mr/client/DmaapClientConst.java71
-rw-r--r--src/main/java/org/onap/dmaap/mr/client/MRClientFactory.java149
-rw-r--r--src/main/java/org/onap/dmaap/mr/client/impl/MRConsumerImpl.java108
-rw-r--r--src/main/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisher.java91
-rw-r--r--src/main/java/org/onap/dmaap/mr/tools/ValidatorUtil.java154
5 files changed, 271 insertions, 302 deletions
diff --git a/src/main/java/org/onap/dmaap/mr/client/DmaapClientConst.java b/src/main/java/org/onap/dmaap/mr/client/DmaapClientConst.java
new file mode 100644
index 0000000..e1749c2
--- /dev/null
+++ b/src/main/java/org/onap/dmaap/mr/client/DmaapClientConst.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright © 2021 Orange Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *
+ *******************************************************************************/
+
+package org.onap.dmaap.mr.client;
+
+public final class DmaapClientConst {
+
+ private DmaapClientConst() {
+ }
+
+ public static final String ID = "id";
+ public static final String AUTH_KEY = "authKey";
+ public static final String AUTH_DATE = "authDate";
+ public static final String PASSWORD = "password";
+ public static final String USERNAME = "username";
+ public static final String FILTER = "filter";
+ public static final String HOST = "host";
+ public static final String DME2PREFERRED_ROUTER_FILE_PATH = "DME2preferredRouterFilePath";
+ public static final String TOPIC = "topic";
+ public static final String TRANSPORT_TYPE = "TransportType";
+ public static final String MAX_BATCH_SIZE = "maxBatchSize";
+ public static final String MAX_AGE_MS = "maxAgeMs";
+ public static final String MESSAGE_SENT_THREAD_OCCURRENCE_OLD = "MessageSentThreadOccurance";
+ public static final String MESSAGE_SENT_THREAD_OCCURRENCE = "MessageSentThreadOccurrence";
+ public static final String GROUP = "group";
+ public static final String SERVICE_NAME = "ServiceName";
+ public static final String PARTNER = "Partner";
+ public static final String ROUTE_OFFER = "routeOffer";
+ public static final String PROTOCOL = "Protocol";
+ public static final String METHOD_TYPE = "MethodType";
+ public static final String CONTENT_TYPE = "contenttype";
+ public static final String LATITUDE = "Latitude";
+ public static final String LONGITUDE = "Longitude";
+ public static final String AFT_ENVIRONMENT = "AFT_ENVIRONMENT";
+ public static final String VERSION = "Version";
+ public static final String ENVIRONMENT = "Environment";
+ public static final String SUB_CONTEXT_PATH = "SubContextPath";
+ public static final String SESSION_STICKINESS_REQUIRED = "sessionstickinessrequired";
+ public static final String PARTITION = "partition";
+ public static final String COMPRESS = "compress";
+ public static final String TIMEOUT = "timeout";
+ public static final String LIMIT = "limit";
+ public static final String AFT_DME2_EP_READ_TIMEOUT_MS = "AFT_DME2_EP_READ_TIMEOUT_MS";
+ public static final String AFT_DME2_ROUNDTRIP_TIMEOUT_MS = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
+ public static final String AFT_DME2_EP_CONN_TIMEOUT = "AFT_DME2_EP_CONN_TIMEOUT";
+ public static final String AFT_DME2_EXCHANGE_REQUEST_HANDLERS = "AFT_DME2_EXCHANGE_REQUEST_HANDLERS";
+ public static final String AFT_DME2_EXCHANGE_REPLY_HANDLERS = "AFT_DME2_EXCHANGE_REPLY_HANDLERS";
+ public static final String AFT_DME2_REQ_TRACE_ON = "AFT_DME2_REQ_TRACE_ON";
+ public static final String DME2_PER_HANDLER_TIMEOUT_MS = "DME2_PER_HANDLER_TIMEOUT_MS";
+ public static final String DME2_REPLY_HANDLER_TIMEOUT_MS = "DME2_REPLY_HANDLER_TIMEOUT_MS";
+
+}
diff --git a/src/main/java/org/onap/dmaap/mr/client/MRClientFactory.java b/src/main/java/org/onap/dmaap/mr/client/MRClientFactory.java
index 88d3dab..33ab0eb 100644
--- a/src/main/java/org/onap/dmaap/mr/client/MRClientFactory.java
+++ b/src/main/java/org/onap/dmaap/mr/client/MRClientFactory.java
@@ -64,47 +64,6 @@ import org.onap.dmaap.mr.tools.ValidatorUtil;
*/
public class MRClientFactory {
- private static final String ID = "id";
- private static final String AUTH_KEY = "authKey";
- private static final String AUTH_DATE = "authDate";
- private static final String PASSWORD = "password";
- private static final String USERNAME = "username";
- private static final String FILTER = "filter";
- private static final String HOST = "host";
- private static final String DME2PREFERRED_ROUTER_FILE_PATH = "DME2preferredRouterFilePath";
- private static final String TOPIC = "topic";
- private static final String TRANSPORT_TYPE = "TransportType";
- private static final String MAX_BATCH_SIZE = "maxBatchSize";
- private static final String MAX_AGE_MS = "maxAgeMs";
- private static final String MESSAGE_SENT_THREAD_OCCURRENCE_OLD = "MessageSentThreadOccurance";
- private static final String MESSAGE_SENT_THREAD_OCCURRENCE = "MessageSentThreadOccurrence";
- private static final String GROUP = "group";
- private static final String SERVICE_NAME = "ServiceName";
- private static final String PARTNER = "Partner";
- private static final String ROUTE_OFFER = "routeOffer";
- private static final String PROTOCOL = "Protocol";
- private static final String METHOD_TYPE = "MethodType";
- private static final String CONTENT_TYPE = "contenttype";
- private static final String LATITUDE = "Latitude";
- private static final String LONGITUDE = "Longitude";
- private static final String AFT_ENVIRONMENT = "AFT_ENVIRONMENT";
- private static final String VERSION = "Version";
- private static final String ENVIRONMENT = "Environment";
- private static final String SUB_CONTEXT_PATH = "SubContextPath";
- private static final String SESSION_STICKINESS_REQUIRED = "sessionstickinessrequired";
- private static final String PARTITION = "partition";
- private static final String COMPRESS = "compress";
- private static final String TIMEOUT = "timeout";
- private static final String LIMIT = "limit";
- private static final String AFT_DME2_EP_READ_TIMEOUT_MS = "AFT_DME2_EP_READ_TIMEOUT_MS";
- private static final String AFT_DME2_ROUNDTRIP_TIMEOUT_MS = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- private static final String AFT_DME2_EP_CONN_TIMEOUT = "AFT_DME2_EP_CONN_TIMEOUT";
- private static final String AFT_DME2_EXCHANGE_REQUEST_HANDLERS = "AFT_DME2_EXCHANGE_REQUEST_HANDLERS";
- private static final String AFT_DME2_EXCHANGE_REPLY_HANDLERS = "AFT_DME2_EXCHANGE_REPLY_HANDLERS";
- private static final String AFT_DME2_REQ_TRACE_ON = "AFT_DME2_REQ_TRACE_ON";
- private static final String DME2_PER_HANDLER_TIMEOUT_MS = "DME2_PER_HANDLER_TIMEOUT_MS";
- private static final String DME2_REPLY_HANDLER_TIMEOUT_MS = "DME2_REPLY_HANDLER_TIMEOUT_MS";
-
private static MultivaluedMap<String, Object> httpHeadersMap;
public static Map<String, String> DME2HeadersMap;
public static String routeFilePath;
@@ -469,45 +428,45 @@ public class MRClientFactory {
assert props != null;
MRSimplerBatchPublisher pub;
- String messageSentThreadOccurrence = props.getProperty(MESSAGE_SENT_THREAD_OCCURRENCE);
+ String messageSentThreadOccurrence = props.getProperty(DmaapClientConst.MESSAGE_SENT_THREAD_OCCURRENCE);
if (messageSentThreadOccurrence == null || messageSentThreadOccurrence.isEmpty()) {
- messageSentThreadOccurrence = props.getProperty(MESSAGE_SENT_THREAD_OCCURRENCE_OLD);
+ messageSentThreadOccurrence = props.getProperty(DmaapClientConst.MESSAGE_SENT_THREAD_OCCURRENCE_OLD);
}
if (withResponse) {
pub = new MRSimplerBatchPublisher.Builder()
- .againstUrlsOrServiceName(MRConsumerImpl.stringToList(props.getProperty(HOST)), MRConsumerImpl.stringToList(props.getProperty(SERVICE_NAME)), props.getProperty(TRANSPORT_TYPE))
- .onTopic(props.getProperty(TOPIC))
- .batchTo(Integer.parseInt(props.getProperty(MAX_BATCH_SIZE)),
- Integer.parseInt(props.getProperty(MAX_AGE_MS).toString()))
- .compress(Boolean.parseBoolean(props.getProperty(COMPRESS)))
+ .againstUrlsOrServiceName(MRConsumerImpl.stringToList(props.getProperty(DmaapClientConst.HOST)), MRConsumerImpl.stringToList(props.getProperty(DmaapClientConst.SERVICE_NAME)), props.getProperty(DmaapClientConst.TRANSPORT_TYPE))
+ .onTopic(props.getProperty(DmaapClientConst.TOPIC))
+ .batchTo(Integer.parseInt(props.getProperty(DmaapClientConst.MAX_BATCH_SIZE)),
+ Integer.parseInt(props.getProperty(DmaapClientConst.MAX_AGE_MS)))
+ .compress(Boolean.parseBoolean(props.getProperty(DmaapClientConst.COMPRESS)))
.httpThreadTime(Integer.parseInt(messageSentThreadOccurrence))
.withResponse(withResponse).build();
} else {
pub = new MRSimplerBatchPublisher.Builder()
- .againstUrlsOrServiceName(MRConsumerImpl.stringToList(props.getProperty(HOST)), MRConsumerImpl.stringToList(props.getProperty(SERVICE_NAME)), props.getProperty(TRANSPORT_TYPE))
- .onTopic(props.getProperty(TOPIC))
- .batchTo(Integer.parseInt(props.getProperty(MAX_BATCH_SIZE)),
- Integer.parseInt(props.getProperty(MAX_AGE_MS).toString()))
- .compress(Boolean.parseBoolean(props.getProperty(COMPRESS)))
+ .againstUrlsOrServiceName(MRConsumerImpl.stringToList(props.getProperty(DmaapClientConst.HOST)), MRConsumerImpl.stringToList(props.getProperty(DmaapClientConst.SERVICE_NAME)), props.getProperty(DmaapClientConst.TRANSPORT_TYPE))
+ .onTopic(props.getProperty(DmaapClientConst.TOPIC))
+ .batchTo(Integer.parseInt(props.getProperty(DmaapClientConst.MAX_BATCH_SIZE)),
+ Integer.parseInt(props.getProperty(DmaapClientConst.MAX_AGE_MS)))
+ .compress(Boolean.parseBoolean(props.getProperty(DmaapClientConst.COMPRESS)))
.httpThreadTime(Integer.parseInt(messageSentThreadOccurrence)).build();
}
- pub.setHost(props.getProperty(HOST));
- if (props.getProperty(TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.AUTH_KEY.getValue())) {
+ pub.setHost(props.getProperty(DmaapClientConst.HOST));
+ if (props.getProperty(DmaapClientConst.TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.AUTH_KEY.getValue())) {
- pub.setAuthKey(props.getProperty(AUTH_KEY));
- pub.setAuthDate(props.getProperty(AUTH_DATE));
- pub.setUsername(props.getProperty(USERNAME));
- pub.setPassword(props.getProperty(PASSWORD));
+ pub.setAuthKey(props.getProperty(DmaapClientConst.AUTH_KEY));
+ pub.setAuthDate(props.getProperty(DmaapClientConst.AUTH_DATE));
+ pub.setUsername(props.getProperty(DmaapClientConst.USERNAME));
+ pub.setPassword(props.getProperty(DmaapClientConst.PASSWORD));
} else {
- pub.setUsername(props.getProperty(USERNAME));
- pub.setPassword(props.getProperty(PASSWORD));
+ pub.setUsername(props.getProperty(DmaapClientConst.USERNAME));
+ pub.setPassword(props.getProperty(DmaapClientConst.PASSWORD));
}
- pub.setProtocolFlag(props.getProperty(TRANSPORT_TYPE));
+ pub.setProtocolFlag(props.getProperty(DmaapClientConst.TRANSPORT_TYPE));
pub.setProps(props);
prop = new Properties();
- if (props.getProperty(TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.DME2.getValue())) {
- routeFilePath = props.getProperty(DME2PREFERRED_ROUTER_FILE_PATH);
+ if (props.getProperty(DmaapClientConst.TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.DME2.getValue())) {
+ routeFilePath = props.getProperty(DmaapClientConst.DME2PREFERRED_ROUTER_FILE_PATH);
routeReader = new FileReader(new File(routeFilePath));
File fo = new File(routeFilePath);
if (!fo.exists()) {
@@ -621,55 +580,55 @@ public class MRClientFactory {
public static MRConsumer createConsumer(Properties props) throws FileNotFoundException, IOException {
int timeout;
ValidatorUtil.validateSubscriber(props);
- if (props.getProperty(TIMEOUT) != null) {
- timeout = Integer.parseInt(props.getProperty(TIMEOUT));
+ if (props.getProperty(DmaapClientConst.TIMEOUT) != null) {
+ timeout = Integer.parseInt(props.getProperty(DmaapClientConst.TIMEOUT));
} else {
timeout = -1;
}
int limit;
- if (props.getProperty(LIMIT) != null) {
- limit = Integer.parseInt(props.getProperty(LIMIT));
+ if (props.getProperty(DmaapClientConst.LIMIT) != null) {
+ limit = Integer.parseInt(props.getProperty(DmaapClientConst.LIMIT));
} else {
limit = -1;
}
String group;
- if (props.getProperty(GROUP) == null) {
+ if (props.getProperty(DmaapClientConst.GROUP) == null) {
group = UUID.randomUUID().toString();
} else {
- group = props.getProperty(GROUP);
+ group = props.getProperty(DmaapClientConst.GROUP);
}
MRConsumerImpl sub = null;
- if (props.getProperty(TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.AUTH_KEY.getValue())) {
+ if (props.getProperty(DmaapClientConst.TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.AUTH_KEY.getValue())) {
sub = new MRConsumerImpl.MRConsumerImplBuilder()
- .setHostPart(MRConsumerImpl.stringToList(props.getProperty(HOST)))
- .setTopic(props.getProperty(TOPIC)).setConsumerGroup(group)
- .setConsumerId(props.getProperty(ID)).setTimeoutMs(timeout).setLimit(limit)
- .setFilter(props.getProperty(FILTER))
- .setApiKey_username(props.getProperty(AUTH_KEY))
- .setApiSecret_password(props.getProperty(AUTH_DATE)).createMRConsumerImpl();
- sub.setAuthKey(props.getProperty(AUTH_KEY));
- sub.setAuthDate(props.getProperty(AUTH_DATE));
- sub.setUsername(props.getProperty(USERNAME));
- sub.setPassword(props.getProperty(PASSWORD));
+ .setHostPart(MRConsumerImpl.stringToList(props.getProperty(DmaapClientConst.HOST)))
+ .setTopic(props.getProperty(DmaapClientConst.TOPIC)).setConsumerGroup(group)
+ .setConsumerId(props.getProperty(DmaapClientConst.ID)).setTimeoutMs(timeout).setLimit(limit)
+ .setFilter(props.getProperty(DmaapClientConst.FILTER))
+ .setApiKey_username(props.getProperty(DmaapClientConst.AUTH_KEY))
+ .setApiSecret_password(props.getProperty(DmaapClientConst.AUTH_DATE)).createMRConsumerImpl();
+ sub.setAuthKey(props.getProperty(DmaapClientConst.AUTH_KEY));
+ sub.setAuthDate(props.getProperty(DmaapClientConst.AUTH_DATE));
+ sub.setUsername(props.getProperty(DmaapClientConst.USERNAME));
+ sub.setPassword(props.getProperty(DmaapClientConst.PASSWORD));
} else {
sub = new MRConsumerImpl.MRConsumerImplBuilder()
- .setHostPart(MRConsumerImpl.stringToList(props.getProperty(HOST)))
- .setTopic(props.getProperty(TOPIC)).setConsumerGroup(group)
- .setConsumerId(props.getProperty(ID)).setTimeoutMs(timeout).setLimit(limit)
- .setFilter(props.getProperty(FILTER))
- .setApiKey_username(props.getProperty(USERNAME))
- .setApiSecret_password(props.getProperty(PASSWORD)).createMRConsumerImpl();
- sub.setUsername(props.getProperty(USERNAME));
- sub.setPassword(props.getProperty(PASSWORD));
+ .setHostPart(MRConsumerImpl.stringToList(props.getProperty(DmaapClientConst.HOST)))
+ .setTopic(props.getProperty(DmaapClientConst.TOPIC)).setConsumerGroup(group)
+ .setConsumerId(props.getProperty(DmaapClientConst.ID)).setTimeoutMs(timeout).setLimit(limit)
+ .setFilter(props.getProperty(DmaapClientConst.FILTER))
+ .setApiKey_username(props.getProperty(DmaapClientConst.USERNAME))
+ .setApiSecret_password(props.getProperty(DmaapClientConst.PASSWORD)).createMRConsumerImpl();
+ sub.setUsername(props.getProperty(DmaapClientConst.USERNAME));
+ sub.setPassword(props.getProperty(DmaapClientConst.PASSWORD));
}
sub.setProps(props);
- sub.setHost(props.getProperty(HOST));
- sub.setProtocolFlag(props.getProperty(TRANSPORT_TYPE));
- sub.setfFilter(props.getProperty(FILTER));
- if (props.getProperty(TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.DME2.getValue())) {
- MRConsumerImpl.setRouterFilePath(props.getProperty(DME2PREFERRED_ROUTER_FILE_PATH));
- routeFilePath = props.getProperty(DME2PREFERRED_ROUTER_FILE_PATH);
+ sub.setHost(props.getProperty(DmaapClientConst.HOST));
+ sub.setProtocolFlag(props.getProperty(DmaapClientConst.TRANSPORT_TYPE));
+ sub.setfFilter(props.getProperty(DmaapClientConst.FILTER));
+ if (props.getProperty(DmaapClientConst.TRANSPORT_TYPE).equalsIgnoreCase(ProtocolType.DME2.getValue())) {
+ MRConsumerImpl.setRouterFilePath(props.getProperty(DmaapClientConst.DME2PREFERRED_ROUTER_FILE_PATH));
+ routeFilePath = props.getProperty(DmaapClientConst.DME2PREFERRED_ROUTER_FILE_PATH);
routeReader = new FileReader(new File(routeFilePath));
prop = new Properties();
File fo = new File(routeFilePath);
diff --git a/src/main/java/org/onap/dmaap/mr/client/impl/MRConsumerImpl.java b/src/main/java/org/onap/dmaap/mr/client/impl/MRConsumerImpl.java
index 57ae3ee..4d2f9d1 100644
--- a/src/main/java/org/onap/dmaap/mr/client/impl/MRConsumerImpl.java
+++ b/src/main/java/org/onap/dmaap/mr/client/impl/MRConsumerImpl.java
@@ -34,6 +34,7 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
@@ -46,6 +47,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
+import org.onap.dmaap.mr.client.DmaapClientConst;
import org.onap.dmaap.mr.client.HostSelector;
import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.MRConsumer;
@@ -77,29 +79,10 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
private static final String URL_PARAM_FILTER = "filter";
private static final String URL_PARAM_LIMIT = "limit";
private static final String URL_PARAM_TIMEOUT = "timeout";
-
- private static final String USERNAME = "username";
- private static final String SERVICE_NAME = "ServiceName";
- private static final String PARTNER = "Partner";
- private static final String ROUTE_OFFER = "routeOffer";
- private static final String PROTOCOL = "Protocol";
- private static final String METHOD_TYPE = "MethodType";
- private static final String CONTENT_TYPE = "contenttype";
- private static final String LATITUDE = "Latitude";
- private static final String LONGITUDE = "Longitude";
- private static final String AFT_ENVIRONMENT = "AFT_ENVIRONMENT";
- private static final String VERSION = "Version";
- private static final String ENVIRONMENT = "Environment";
- private static final String SUB_CONTEXT_PATH = "SubContextPath";
- private static final String SESSION_STICKINESS_REQUIRED = "sessionstickinessrequired";
- private static final String AFT_DME2_EP_READ_TIMEOUT_MS = "AFT_DME2_EP_READ_TIMEOUT_MS";
- private static final String AFT_DME2_ROUNDTRIP_TIMEOUT_MS = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- private static final String AFT_DME2_EP_CONN_TIMEOUT = "AFT_DME2_EP_CONN_TIMEOUT";
- private static final String AFT_DME2_EXCHANGE_REQUEST_HANDLERS = "AFT_DME2_EXCHANGE_REQUEST_HANDLERS";
- private static final String AFT_DME2_EXCHANGE_REPLY_HANDLERS = "AFT_DME2_EXCHANGE_REPLY_HANDLERS";
- private static final String AFT_DME2_REQ_TRACE_ON = "AFT_DME2_REQ_TRACE_ON";
- private static final String DME2_PER_HANDLER_TIMEOUT_MS = "DME2_PER_HANDLER_TIMEOUT_MS";
- private static final String DME2_REPLY_HANDLER_TIMEOUT_MS = "DME2_REPLY_HANDLER_TIMEOUT_MS";
+
+ private static final String HEADER_DME2_EXCHANGE_REQUEST_HANDLERS = "AFT_DME2_EXCHANGE_REQUEST_HANDLERS";
+ private static final String HEADER_DME2_EXCHANGE_REPLY_HANDLERS = "AFT_DME2_EXCHANGE_REPLY_HANDLERS";
+ private static final String HEADER_DME2_REQ_TRACE_ON = "AFT_DME2_REQ_TRACE_ON";
private final String fTopic;
private final String fGroup;
@@ -242,20 +225,20 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
break;
case AAF_AUTH:
String urlAuthPath = createUrlPath(MRConstants.makeConsumerUrl(fHostSelector.selectBaseHost(), fTopic,
- fGroup, fId, props.getProperty(PROTOCOL)), timeoutMs, limit);
+ fGroup, fId, props.getProperty(DmaapClientConst.PROTOCOL)), timeoutMs, limit);
final JSONObject o = get(urlAuthPath, username, password, protocolFlag);
readJsonData(msgs, o);
break;
case AUTH_KEY:
final String urlKeyPath = createUrlPath(
- MRConstants.makeConsumerUrl(host, fTopic, fGroup, fId, props.getProperty(PROTOCOL)),
+ MRConstants.makeConsumerUrl(host, fTopic, fGroup, fId, props.getProperty(DmaapClientConst.PROTOCOL)),
timeoutMs, limit);
final JSONObject authObject = getAuth(urlKeyPath, authKey, authDate, username, password, protocolFlag);
readJsonData(msgs, authObject);
break;
case HTTPNOAUTH:
final String urlNoAuthPath = createUrlPath(MRConstants.makeConsumerUrl(fHostSelector.selectBaseHost(), fTopic,
- fGroup, fId, props.getProperty(PROTOCOL)), timeoutMs, limit);
+ fGroup, fId, props.getProperty(DmaapClientConst.PROTOCOL)), timeoutMs, limit);
readJsonData(msgs, getNoAuth(urlNoAuthPath));
break;
}
@@ -311,7 +294,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
if (ProtocolType.AAF_AUTH.getValue().equalsIgnoreCase(protocolFlag)) {
final String urlPath = createUrlPath(MRConstants.makeConsumerUrl(fHostSelector.selectBaseHost(), fTopic,
- fGroup, fId, props.getProperty(PROTOCOL)), timeoutMs, limit);
+ fGroup, fId, props.getProperty(DmaapClientConst.PROTOCOL)), timeoutMs, limit);
String response = getResponse(urlPath, username, password, protocolFlag);
final JSONObject o = getResponseDataInJsonWithResponseReturned(response);
@@ -321,7 +304,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
if (ProtocolType.AUTH_KEY.getValue().equalsIgnoreCase(protocolFlag)) {
final String urlPath = createUrlPath(
- MRConstants.makeConsumerUrl(host, fTopic, fGroup, fId, props.getProperty(PROTOCOL)),
+ MRConstants.makeConsumerUrl(host, fTopic, fGroup, fId, props.getProperty(DmaapClientConst.PROTOCOL)),
timeoutMs, limit);
String response = getAuthResponse(urlPath, authKey, authDate, username, password, protocolFlag);
@@ -332,7 +315,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
if (ProtocolType.HTTPNOAUTH.getValue().equalsIgnoreCase(protocolFlag)) {
final String urlPath = createUrlPath(MRConstants.makeConsumerUrl(fHostSelector.selectBaseHost(), fTopic,
- fGroup, fId, props.getProperty(PROTOCOL)), timeoutMs, limit);
+ fGroup, fId, props.getProperty(DmaapClientConst.PROTOCOL)), timeoutMs, limit);
String response = getNoAuthResponse(urlPath, username, password, protocolFlag);
final JSONObject o = getResponseDataInJsonWithResponseReturned(response);
@@ -435,20 +418,20 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
private void dmeConfigure(int timeoutMs, int limit) throws IOException, DME2Exception, URISyntaxException {
this.longPollingMs = timeoutMs;
- String latitude = props.getProperty(LATITUDE);
- String longitude = props.getProperty(LONGITUDE);
- String version = props.getProperty(VERSION);
- String serviceName = props.getProperty(SERVICE_NAME);
- String env = props.getProperty(ENVIRONMENT);
- String partner = props.getProperty(PARTNER);
- String routeOffer = props.getProperty(ROUTE_OFFER);
- String subContextPath = props.getProperty(SUB_CONTEXT_PATH) + fTopic + "/" + fGroup + "/" + fId;
- String protocol = props.getProperty(PROTOCOL);
- String methodType = props.getProperty(METHOD_TYPE);
- String dmeuser = props.getProperty(USERNAME);
- String dmepassword = props.getProperty(USERNAME);
- String contenttype = props.getProperty(CONTENT_TYPE);
- String handlers = props.getProperty(SESSION_STICKINESS_REQUIRED);
+ String latitude = props.getProperty(DmaapClientConst.LATITUDE);
+ String longitude = props.getProperty(DmaapClientConst.LONGITUDE);
+ String version = props.getProperty(DmaapClientConst.VERSION);
+ String serviceName = props.getProperty(DmaapClientConst.SERVICE_NAME);
+ String env = props.getProperty(DmaapClientConst.ENVIRONMENT);
+ String partner = props.getProperty(DmaapClientConst.PARTNER, "");
+ String routeOffer = props.getProperty(DmaapClientConst.ROUTE_OFFER, "");
+ String subContextPath = props.getProperty(DmaapClientConst.SUB_CONTEXT_PATH) + fTopic + "/" + fGroup + "/" + fId;
+ String protocol = props.getProperty(DmaapClientConst.PROTOCOL);
+ String methodType = props.getProperty(DmaapClientConst.METHOD_TYPE);
+ String dmeuser = props.getProperty(DmaapClientConst.USERNAME);
+ String dmepassword = props.getProperty(DmaapClientConst.USERNAME);
+ String contenttype = props.getProperty(DmaapClientConst.CONTENT_TYPE);
+ String handlers = props.getProperty(DmaapClientConst.SESSION_STICKINESS_REQUIRED, "");
/*
* Changes to DME2Client url to use Partner for auto failover between data centers When Partner value is not
@@ -457,18 +440,18 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
String preferredRouteKey = readRoute("preferredRouteKey");
StringBuilder contextUrl = new StringBuilder();
- if (partner != null && !partner.isEmpty() && preferredRouteKey != null && !preferredRouteKey.isEmpty()) {
+ if (!partner.isEmpty() && preferredRouteKey != null && !preferredRouteKey.isEmpty()) {
contextUrl.append(protocol).append("://").append(serviceName).append("?")
.append(URL_PARAM_VERSION).append("=").append(version).append("&")
.append(URL_PARAM_ENV_CONTEXT).append("=").append(env).append("&")
.append(URL_PARAM_PARTNER).append("=").append(partner).append("&")
.append(URL_PARAM_ROUTE_OFFER).append("=").append(preferredRouteKey);
- } else if (partner != null && !partner.isEmpty()) {
+ } else if (!partner.isEmpty()) {
contextUrl.append(protocol).append("://").append(serviceName).append("?")
.append(URL_PARAM_VERSION).append("=").append(version).append("&")
.append(URL_PARAM_ENV_CONTEXT).append("=").append(env).append("&")
.append(URL_PARAM_PARTNER).append("=").append(partner);
- } else if (routeOffer != null && !routeOffer.isEmpty()) {
+ } else if (!routeOffer.isEmpty()) {
contextUrl.append(protocol).append("://").append(serviceName).append("?")
.append(URL_PARAM_VERSION).append("=").append(version).append("&")
.append(URL_PARAM_ENV_CONTEXT).append("=").append(env).append("&")
@@ -484,19 +467,20 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
// Add filter to DME2 Url
if (fFilter != null && fFilter.length() > 0) {
- contextUrl.append("&").append(URL_PARAM_FILTER).append("=").append(URLEncoder.encode(fFilter, "UTF-8"));
+ contextUrl.append("&").append(URL_PARAM_FILTER).append("=")
+ .append(URLEncoder.encode(fFilter, StandardCharsets.UTF_8));
}
url = contextUrl.toString();
DMETimeOuts = new HashMap<>();
- DMETimeOuts.put("AFT_DME2_EP_READ_TIMEOUT_MS", props.getProperty(AFT_DME2_EP_READ_TIMEOUT_MS));
- DMETimeOuts.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", props.getProperty(AFT_DME2_ROUNDTRIP_TIMEOUT_MS));
- DMETimeOuts.put("AFT_DME2_EP_CONN_TIMEOUT", props.getProperty(AFT_DME2_EP_CONN_TIMEOUT));
+ DMETimeOuts.put("AFT_DME2_EP_READ_TIMEOUT_MS", props.getProperty(DmaapClientConst.AFT_DME2_EP_READ_TIMEOUT_MS));
+ DMETimeOuts.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", props.getProperty(DmaapClientConst.AFT_DME2_ROUNDTRIP_TIMEOUT_MS));
+ DMETimeOuts.put("AFT_DME2_EP_CONN_TIMEOUT", props.getProperty(DmaapClientConst.AFT_DME2_EP_CONN_TIMEOUT));
DMETimeOuts.put("Content-Type", contenttype);
System.setProperty("AFT_LATITUDE", latitude);
System.setProperty("AFT_LONGITUDE", longitude);
- System.setProperty("AFT_ENVIRONMENT", props.getProperty(AFT_ENVIRONMENT));
+ System.setProperty("AFT_ENVIRONMENT", props.getProperty(DmaapClientConst.AFT_ENVIRONMENT));
// SSL changes
System.setProperty("AFT_DME2_CLIENT_SSL_INCLUDE_PROTOCOLS", "TLSv1.1,TLSv1.2");
@@ -506,7 +490,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
long dme2PerEndPointTimeoutMs;
try {
- dme2PerEndPointTimeoutMs = Long.parseLong(props.getProperty(DME2_PER_HANDLER_TIMEOUT_MS));
+ dme2PerEndPointTimeoutMs = Long.parseLong(props.getProperty(DmaapClientConst.DME2_PER_HANDLER_TIMEOUT_MS));
// backward compatibility
if (dme2PerEndPointTimeoutMs <= 0) {
dme2PerEndPointTimeoutMs = timeoutMs + DEFAULT_DME2_PER_ENDPOINT_TIMEOUT_MS;
@@ -515,15 +499,15 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
// backward compatibility
dme2PerEndPointTimeoutMs = timeoutMs + DEFAULT_DME2_PER_ENDPOINT_TIMEOUT_MS;
getLog().debug(
- DME2_PER_HANDLER_TIMEOUT_MS + " not set and using default " + DEFAULT_DME2_PER_ENDPOINT_TIMEOUT_MS);
+ DmaapClientConst.DME2_PER_HANDLER_TIMEOUT_MS + " not set and using default " + DEFAULT_DME2_PER_ENDPOINT_TIMEOUT_MS);
}
try {
- dme2ReplyHandlerTimeoutMs = Long.parseLong(props.getProperty(DME2_REPLY_HANDLER_TIMEOUT_MS));
+ dme2ReplyHandlerTimeoutMs = Long.parseLong(props.getProperty(DmaapClientConst.DME2_REPLY_HANDLER_TIMEOUT_MS));
} catch (NumberFormatException nfe) {
try {
- long dme2EpReadTimeoutMs = Long.parseLong(props.getProperty(AFT_DME2_EP_READ_TIMEOUT_MS));
- long dme2EpConnTimeoutMs = Long.parseLong(props.getProperty(AFT_DME2_EP_CONN_TIMEOUT));
+ long dme2EpReadTimeoutMs = Long.parseLong(props.getProperty(DmaapClientConst.AFT_DME2_EP_READ_TIMEOUT_MS));
+ long dme2EpConnTimeoutMs = Long.parseLong(props.getProperty(DmaapClientConst.AFT_DME2_EP_CONN_TIMEOUT));
dme2ReplyHandlerTimeoutMs = timeoutMs + dme2EpReadTimeoutMs + dme2EpConnTimeoutMs;
getLog().debug(
"DME2_REPLY_HANDLER_TIMEOUT_MS not set and using default from timeoutMs, AFT_DME2_EP_READ_TIMEOUT_MS and AFT_DME2_EP_CONN_TIMEOUT "
@@ -548,13 +532,13 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer {
}
sender.setHeaders(DMETimeOuts);
sender.setPayload("");
- if (handlers != null && handlers.equalsIgnoreCase("yes")) {
- sender.addHeader("AFT_DME2_EXCHANGE_REQUEST_HANDLERS",
- props.getProperty(AFT_DME2_EXCHANGE_REQUEST_HANDLERS));
- sender.addHeader("AFT_DME2_EXCHANGE_REPLY_HANDLERS", props.getProperty(AFT_DME2_EXCHANGE_REPLY_HANDLERS));
- sender.addHeader("AFT_DME2_REQ_TRACE_ON", props.getProperty(AFT_DME2_REQ_TRACE_ON));
+ if (handlers.equalsIgnoreCase("yes")) {
+ sender.addHeader(HEADER_DME2_EXCHANGE_REQUEST_HANDLERS,
+ props.getProperty(DmaapClientConst.AFT_DME2_EXCHANGE_REQUEST_HANDLERS));
+ sender.addHeader(HEADER_DME2_EXCHANGE_REPLY_HANDLERS, props.getProperty(DmaapClientConst.AFT_DME2_EXCHANGE_REPLY_HANDLERS));
+ sender.addHeader(HEADER_DME2_REQ_TRACE_ON, props.getProperty(DmaapClientConst.AFT_DME2_REQ_TRACE_ON));
} else {
- sender.addHeader("AFT_DME2_EXCHANGE_REPLY_HANDLERS", "com.att.nsa.mr.dme.client.HeaderReplyHandler");
+ sender.addHeader(HEADER_DME2_EXCHANGE_REPLY_HANDLERS, "com.att.nsa.mr.dme.client.HeaderReplyHandler");
}
}
diff --git a/src/main/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisher.java b/src/main/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisher.java
index 74fec8a..f71960c 100644
--- a/src/main/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisher.java
+++ b/src/main/java/org/onap/dmaap/mr/client/impl/MRSimplerBatchPublisher.java
@@ -49,6 +49,7 @@ import org.apache.http.HttpStatus;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
+import org.onap.dmaap.mr.client.DmaapClientConst;
import org.onap.dmaap.mr.client.HostSelector;
import org.onap.dmaap.mr.client.MRBatchingPublisher;
import org.onap.dmaap.mr.client.ProtocolType;
@@ -59,29 +60,9 @@ import org.slf4j.LoggerFactory;
public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingPublisher {
private static final Logger logger = LoggerFactory.getLogger(MRSimplerBatchPublisher.class);
- private static final String PASSWORD = "password";
- private static final String USERNAME = "username";
- private static final String DME2PREFERRED_ROUTER_FILE_PATH = "DME2preferredRouterFilePath";
- private static final String SERVICE_NAME = "ServiceName";
- private static final String PARTNER = "Partner";
- private static final String ROUTE_OFFER = "routeOffer";
- private static final String PROTOCOL = "Protocol";
- private static final String METHOD_TYPE = "MethodType";
- private static final String CONTENT_TYPE = "contenttype";
- private static final String LATITUDE = "Latitude";
- private static final String LONGITUDE = "Longitude";
- private static final String AFT_ENVIRONMENT = "AFT_ENVIRONMENT";
- private static final String VERSION = "Version";
- private static final String ENVIRONMENT = "Environment";
- private static final String SUB_CONTEXT_PATH = "SubContextPath";
- private static final String SESSION_STICKINESS_REQUIRED = "sessionstickinessrequired";
- private static final String PARTITION = "partition";
- private static final String AFT_DME2_EP_READ_TIMEOUT_MS = "AFT_DME2_EP_READ_TIMEOUT_MS";
- private static final String AFT_DME2_ROUNDTRIP_TIMEOUT_MS = "AFT_DME2_ROUNDTRIP_TIMEOUT_MS";
- private static final String AFT_DME2_EP_CONN_TIMEOUT = "AFT_DME2_EP_CONN_TIMEOUT";
- private static final String AFT_DME2_EXCHANGE_REQUEST_HANDLERS = "AFT_DME2_EXCHANGE_REQUEST_HANDLERS";
- private static final String AFT_DME2_EXCHANGE_REPLY_HANDLERS = "AFT_DME2_EXCHANGE_REPLY_HANDLERS";
- private static final String AFT_DME2_REQ_TRACE_ON = "AFT_DME2_REQ_TRACE_ON";
+ private static final String HEADER_DME2_EXCHANGE_REQUEST_HANDLERS = "AFT_DME2_EXCHANGE_REQUEST_HANDLERS";
+ private static final String HEADER_DME2_EXCHANGE_REPLY_HANDLERS = "AFT_DME2_EXCHANGE_REPLY_HANDLERS";
+ private static final String HEADER_DME2_REQ_TRACE_ON = "AFT_DME2_REQ_TRACE_ON";
private static final String CONTENT_TYPE_TEXT = "text/plain";
@@ -321,14 +302,14 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
host = this.fHostSelector.selectBaseHost();
}
- final String httpurl = MRConstants.makeUrl(host, fTopic, props.getProperty(PROTOCOL),
- props.getProperty(PARTITION));
+ final String httpurl = MRConstants.makeUrl(host, fTopic, props.getProperty(DmaapClientConst.PROTOCOL),
+ props.getProperty(DmaapClientConst.PARTITION));
try {
final ByteArrayOutputStream baseStream = new ByteArrayOutputStream();
OutputStream os = baseStream;
- final String contentType = props.getProperty(CONTENT_TYPE);
+ final String contentType = props.getProperty(DmaapClientConst.CONTENT_TYPE);
if (contentType.equalsIgnoreCase(MRFormat.JSON.toString())) {
JSONArray jsonArray = parseJSON();
os.write(jsonArray.toString().getBytes());
@@ -457,12 +438,12 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
host = this.fHostSelector.selectBaseHost();
- final String httpUrl = MRConstants.makeUrl(host, fTopic, props.getProperty(PROTOCOL),
- props.getProperty(PARTITION));
+ final String httpUrl = MRConstants.makeUrl(host, fTopic, props.getProperty(DmaapClientConst.PROTOCOL),
+ props.getProperty(DmaapClientConst.PARTITION));
OutputStream os = null;
try (ByteArrayOutputStream baseStream = new ByteArrayOutputStream()) {
os = baseStream;
- final String propsContentType = props.getProperty(CONTENT_TYPE);
+ final String propsContentType = props.getProperty(DmaapClientConst.CONTENT_TYPE);
if (propsContentType.equalsIgnoreCase(MRFormat.JSON.toString())) {
JSONArray jsonArray = parseJSON();
os.write(jsonArray.toString().getBytes());
@@ -759,23 +740,23 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
private void configureDME2() throws Exception {
try {
- latitude = props.getProperty(LATITUDE);
- longitude = props.getProperty(LONGITUDE);
- version = props.getProperty(VERSION);
- serviceName = props.getProperty(SERVICE_NAME);
- env = props.getProperty(ENVIRONMENT);
- partner = props.getProperty(PARTNER);
- routeOffer = props.getProperty(ROUTE_OFFER);
- subContextPath = props.getProperty(SUB_CONTEXT_PATH) + fTopic;
+ latitude = props.getProperty(DmaapClientConst.LATITUDE);
+ longitude = props.getProperty(DmaapClientConst.LONGITUDE);
+ version = props.getProperty(DmaapClientConst.VERSION);
+ serviceName = props.getProperty(DmaapClientConst.SERVICE_NAME);
+ env = props.getProperty(DmaapClientConst.ENVIRONMENT);
+ partner = props.getProperty(DmaapClientConst.PARTNER);
+ routeOffer = props.getProperty(DmaapClientConst.ROUTE_OFFER);
+ subContextPath = props.getProperty(DmaapClientConst.SUB_CONTEXT_PATH) + fTopic;
- protocol = props.getProperty(PROTOCOL);
- methodType = props.getProperty(METHOD_TYPE);
- dmeuser = props.getProperty(USERNAME);
- dmepassword = props.getProperty(PASSWORD);
- contentType = props.getProperty(CONTENT_TYPE);
- handlers = props.getProperty(SESSION_STICKINESS_REQUIRED);
+ protocol = props.getProperty(DmaapClientConst.PROTOCOL);
+ methodType = props.getProperty(DmaapClientConst.METHOD_TYPE);
+ dmeuser = props.getProperty(DmaapClientConst.USERNAME);
+ dmepassword = props.getProperty(DmaapClientConst.PASSWORD);
+ contentType = props.getProperty(DmaapClientConst.CONTENT_TYPE);
+ handlers = props.getProperty(DmaapClientConst.SESSION_STICKINESS_REQUIRED);
- MRSimplerBatchPublisher.routerFilePath = props.getProperty(DME2PREFERRED_ROUTER_FILE_PATH);
+ MRSimplerBatchPublisher.routerFilePath = props.getProperty(DmaapClientConst.DME2PREFERRED_ROUTER_FILE_PATH);
/*
* Changes to DME2Client url to use Partner for auto failover
@@ -783,7 +764,7 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
* routeOffer value for auto failover within a cluster
*/
- String partitionKey = props.getProperty(PARTITION);
+ String partitionKey = props.getProperty(DmaapClientConst.PARTITION);
if (partner != null && !partner.isEmpty()) {
url = protocol + "://" + serviceName + "?version=" + version + "&envContext=" + env + "&partner="
@@ -800,13 +781,13 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
}
DMETimeOuts = new HashMap<>();
- DMETimeOuts.put("AFT_DME2_EP_READ_TIMEOUT_MS", props.getProperty(AFT_DME2_EP_READ_TIMEOUT_MS));
- DMETimeOuts.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", props.getProperty(AFT_DME2_ROUNDTRIP_TIMEOUT_MS));
- DMETimeOuts.put("AFT_DME2_EP_CONN_TIMEOUT", props.getProperty(AFT_DME2_EP_CONN_TIMEOUT));
+ DMETimeOuts.put("AFT_DME2_EP_READ_TIMEOUT_MS", props.getProperty(DmaapClientConst.AFT_DME2_EP_READ_TIMEOUT_MS));
+ DMETimeOuts.put("AFT_DME2_ROUNDTRIP_TIMEOUT_MS", props.getProperty(DmaapClientConst.AFT_DME2_ROUNDTRIP_TIMEOUT_MS));
+ DMETimeOuts.put("AFT_DME2_EP_CONN_TIMEOUT", props.getProperty(DmaapClientConst.AFT_DME2_EP_CONN_TIMEOUT));
DMETimeOuts.put("Content-Type", contentType);
System.setProperty("AFT_LATITUDE", latitude);
System.setProperty("AFT_LONGITUDE", longitude);
- System.setProperty("AFT_ENVIRONMENT", props.getProperty(AFT_ENVIRONMENT));
+ System.setProperty("AFT_ENVIRONMENT", props.getProperty(DmaapClientConst.AFT_ENVIRONMENT));
// System.setProperty("DME2.DEBUG", "true");
// SSL changes
@@ -826,13 +807,13 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
sender.setCredentials(dmeuser, dmepassword);
sender.setHeaders(DMETimeOuts);
if ("yes".equalsIgnoreCase(handlers)) {
- sender.addHeader("AFT_DME2_EXCHANGE_REQUEST_HANDLERS",
- props.getProperty(AFT_DME2_EXCHANGE_REQUEST_HANDLERS));
- sender.addHeader("AFT_DME2_EXCHANGE_REPLY_HANDLERS",
- props.getProperty(AFT_DME2_EXCHANGE_REPLY_HANDLERS));
- sender.addHeader("AFT_DME2_REQ_TRACE_ON", props.getProperty(AFT_DME2_REQ_TRACE_ON));
+ sender.addHeader(HEADER_DME2_EXCHANGE_REQUEST_HANDLERS,
+ props.getProperty(DmaapClientConst.AFT_DME2_EXCHANGE_REQUEST_HANDLERS));
+ sender.addHeader(HEADER_DME2_EXCHANGE_REPLY_HANDLERS,
+ props.getProperty(DmaapClientConst.AFT_DME2_EXCHANGE_REPLY_HANDLERS));
+ sender.addHeader(HEADER_DME2_REQ_TRACE_ON, props.getProperty(DmaapClientConst.AFT_DME2_REQ_TRACE_ON));
} else {
- sender.addHeader("AFT_DME2_EXCHANGE_REPLY_HANDLERS", "com.att.nsa.mr.dme.client.HeaderReplyHandler");
+ sender.addHeader(HEADER_DME2_EXCHANGE_REQUEST_HANDLERS, "com.att.nsa.mr.dme.client.HeaderReplyHandler");
}
} catch (DME2Exception x) {
getLog().warn(x.getMessage(), x);
diff --git a/src/main/java/org/onap/dmaap/mr/tools/ValidatorUtil.java b/src/main/java/org/onap/dmaap/mr/tools/ValidatorUtil.java
index d01c34f..c19230f 100644
--- a/src/main/java/org/onap/dmaap/mr/tools/ValidatorUtil.java
+++ b/src/main/java/org/onap/dmaap/mr/tools/ValidatorUtil.java
@@ -25,38 +25,12 @@
package org.onap.dmaap.mr.tools;
import java.util.Properties;
+
+import org.onap.dmaap.mr.client.DmaapClientConst;
import org.onap.dmaap.mr.client.ProtocolType;
public class ValidatorUtil {
- private static final String ID = "id";
- private static final String AUTH_KEY = "authKey";
- private static final String AUTH_DATE = "authDate";
- private static final String PASSWORD = "password";
- private static final String USERNAME = "username";
- private static final String HOST = "host";
- private static final String DME2PREFERRED_ROUTER_FILE_PATH = "DME2preferredRouterFilePath";
- private static final String TOPIC = "topic";
- private static final String TRANSPORT_TYPE = "TransportType";
- private static final String MAX_BATCH_SIZE = "maxBatchSize";
- private static final String MAX_AGE_MS = "maxAgeMs";
- private static final String MESSAGE_SENT_THREAD_OCCURRENCE_OLD = "MessageSentThreadOccurance";
- private static final String MESSAGE_SENT_THREAD_OCCURRENCE = "MessageSentThreadOccurrence";
- private static final String GROUP = "group";
- private static final String SERVICE_NAME = "ServiceName";
- private static final String PARTNER = "Partner";
- private static final String ROUTE_OFFER = "routeOffer";
- private static final String PROTOCOL = "Protocol";
- private static final String METHOD_TYPE = "MethodType";
- private static final String CONTENT_TYPE = "contenttype";
- private static final String LATITUDE = "Latitude";
- private static final String LONGITUDE = "Longitude";
- private static final String AFT_ENVIRONMENT = "AFT_ENVIRONMENT";
- private static final String VERSION = "Version";
- private static final String ENVIRONMENT = "Environment";
- private static final String SUB_CONTEXT_PATH = "SubContextPath";
- private static final String SESSION_STICKINESS_REQUIRED = "sessionstickinessrequired";
-
public static final String IS_NEEDED = " is needed";
private ValidatorUtil() {
@@ -64,153 +38,153 @@ public class ValidatorUtil {
}
public static void validatePublisher(Properties props) {
- String transportType = props.getProperty(TRANSPORT_TYPE);
+ String transportType = props.getProperty(DmaapClientConst.TRANSPORT_TYPE);
if (ProtocolType.DME2.getValue().equalsIgnoreCase(transportType)) {
validateForDME2(props);
} else {
validateForNonDME2(props);
}
- String maxBatchSize = props.getProperty(MAX_BATCH_SIZE, "");
+ String maxBatchSize = props.getProperty(DmaapClientConst.MAX_BATCH_SIZE, "");
if (maxBatchSize.isEmpty()) {
- throw new IllegalArgumentException(MAX_BATCH_SIZE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.MAX_BATCH_SIZE + IS_NEEDED);
}
- String maxAgeMs = props.getProperty(MAX_AGE_MS, "");
+ String maxAgeMs = props.getProperty(DmaapClientConst.MAX_AGE_MS, "");
if (maxAgeMs.isEmpty()) {
- throw new IllegalArgumentException(MAX_AGE_MS + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.MAX_AGE_MS + IS_NEEDED);
}
- String messageSentThreadOccurrence = props.getProperty(MESSAGE_SENT_THREAD_OCCURRENCE);
+ String messageSentThreadOccurrence = props.getProperty(DmaapClientConst.MESSAGE_SENT_THREAD_OCCURRENCE);
if (messageSentThreadOccurrence == null || messageSentThreadOccurrence.isEmpty()) {
- messageSentThreadOccurrence = props.getProperty(MESSAGE_SENT_THREAD_OCCURRENCE_OLD);
+ messageSentThreadOccurrence = props.getProperty(DmaapClientConst.MESSAGE_SENT_THREAD_OCCURRENCE_OLD);
}
if (messageSentThreadOccurrence == null || messageSentThreadOccurrence.isEmpty()) {
- throw new IllegalArgumentException(MESSAGE_SENT_THREAD_OCCURRENCE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.MESSAGE_SENT_THREAD_OCCURRENCE + IS_NEEDED);
}
try {
Integer.parseInt(messageSentThreadOccurrence);
} catch (NumberFormatException e) {
- throw new IllegalArgumentException(MESSAGE_SENT_THREAD_OCCURRENCE + " must be an integer");
+ throw new IllegalArgumentException(DmaapClientConst.MESSAGE_SENT_THREAD_OCCURRENCE + " must be an integer");
}
}
public static void validateSubscriber(Properties props) {
- String transportType = props.getProperty(TRANSPORT_TYPE);
+ String transportType = props.getProperty(DmaapClientConst.TRANSPORT_TYPE);
if (ProtocolType.DME2.getValue().equalsIgnoreCase(transportType)) {
validateForDME2(props);
} else {
validateForNonDME2(props);
}
- String group = props.getProperty(GROUP, "");
+ String group = props.getProperty(DmaapClientConst.GROUP, "");
if (group.isEmpty()) {
- throw new IllegalArgumentException(GROUP + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.GROUP + IS_NEEDED);
}
- String id = props.getProperty(ID, "");
+ String id = props.getProperty(DmaapClientConst.ID, "");
if (id.isEmpty()) {
- throw new IllegalArgumentException("Consumer (" + ID + ")" + IS_NEEDED);
+ throw new IllegalArgumentException("Consumer (" + DmaapClientConst.ID + ")" + IS_NEEDED);
}
}
private static void validateForDME2(Properties props) {
- String serviceName = props.getProperty(SERVICE_NAME, "");
+ String serviceName = props.getProperty(DmaapClientConst.SERVICE_NAME, "");
if (serviceName.isEmpty()) {
- throw new IllegalArgumentException(SERVICE_NAME + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.SERVICE_NAME + IS_NEEDED);
}
- String topic = props.getProperty(TOPIC, "");
+ String topic = props.getProperty(DmaapClientConst.TOPIC, "");
if (topic.isEmpty()) {
- throw new IllegalArgumentException(TOPIC + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.TOPIC + IS_NEEDED);
}
- String username = props.getProperty(USERNAME, "");
+ String username = props.getProperty(DmaapClientConst.USERNAME, "");
if (username.isEmpty()) {
- throw new IllegalArgumentException(USERNAME + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.USERNAME + IS_NEEDED);
}
- String password = props.getProperty(PASSWORD, "");
+ String password = props.getProperty(DmaapClientConst.PASSWORD, "");
if (password.isEmpty()) {
- throw new IllegalArgumentException(PASSWORD + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.PASSWORD + IS_NEEDED);
}
- String dme2preferredRouterFilePath = props.getProperty(DME2PREFERRED_ROUTER_FILE_PATH, "");
+ String dme2preferredRouterFilePath = props.getProperty(DmaapClientConst.DME2PREFERRED_ROUTER_FILE_PATH, "");
if (dme2preferredRouterFilePath.isEmpty()) {
- throw new IllegalArgumentException(DME2PREFERRED_ROUTER_FILE_PATH + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.DME2PREFERRED_ROUTER_FILE_PATH + IS_NEEDED);
}
- String partner = props.getProperty(PARTNER, "");
- String routeOffer = props.getProperty(ROUTE_OFFER, "");
+ String partner = props.getProperty(DmaapClientConst.PARTNER, "");
+ String routeOffer = props.getProperty(DmaapClientConst.ROUTE_OFFER, "");
if (partner.isEmpty() && routeOffer.isEmpty()) {
- throw new IllegalArgumentException(PARTNER + " or " + ROUTE_OFFER + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.PARTNER + " or " + DmaapClientConst.ROUTE_OFFER + IS_NEEDED);
}
- String protocol = props.getProperty(PROTOCOL, "");
+ String protocol = props.getProperty(DmaapClientConst.PROTOCOL, "");
if (protocol.isEmpty()) {
- throw new IllegalArgumentException(PROTOCOL + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.PROTOCOL + IS_NEEDED);
}
- String methodType = props.getProperty(METHOD_TYPE, "");
+ String methodType = props.getProperty(DmaapClientConst.METHOD_TYPE, "");
if (methodType.isEmpty()) {
- throw new IllegalArgumentException(METHOD_TYPE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.METHOD_TYPE + IS_NEEDED);
}
- String contentType = props.getProperty(CONTENT_TYPE, "");
+ String contentType = props.getProperty(DmaapClientConst.CONTENT_TYPE, "");
if (contentType.isEmpty()) {
- throw new IllegalArgumentException(CONTENT_TYPE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.CONTENT_TYPE + IS_NEEDED);
}
- String latitude = props.getProperty(LATITUDE, "");
+ String latitude = props.getProperty(DmaapClientConst.LATITUDE, "");
if (latitude.isEmpty()) {
- throw new IllegalArgumentException(LATITUDE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.LATITUDE + IS_NEEDED);
}
- String longitude = props.getProperty(LONGITUDE, "");
+ String longitude = props.getProperty(DmaapClientConst.LONGITUDE, "");
if (longitude.isEmpty()) {
- throw new IllegalArgumentException(LONGITUDE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.LONGITUDE + IS_NEEDED);
}
- String aftEnv = props.getProperty(AFT_ENVIRONMENT, "");
+ String aftEnv = props.getProperty(DmaapClientConst.AFT_ENVIRONMENT, "");
if (aftEnv.isEmpty()) {
- throw new IllegalArgumentException(AFT_ENVIRONMENT + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.AFT_ENVIRONMENT + IS_NEEDED);
}
- String version = props.getProperty(VERSION, "");
+ String version = props.getProperty(DmaapClientConst.VERSION, "");
if (version.isEmpty()) {
- throw new IllegalArgumentException(VERSION + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.VERSION + IS_NEEDED);
}
- String environment = props.getProperty(ENVIRONMENT, "");
+ String environment = props.getProperty(DmaapClientConst.ENVIRONMENT, "");
if (environment.isEmpty()) {
- throw new IllegalArgumentException(ENVIRONMENT + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.ENVIRONMENT + IS_NEEDED);
}
- String subContextPath = props.getProperty(SUB_CONTEXT_PATH, "");
+ String subContextPath = props.getProperty(DmaapClientConst.SUB_CONTEXT_PATH, "");
if (subContextPath.isEmpty()) {
- throw new IllegalArgumentException(SUB_CONTEXT_PATH + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.SUB_CONTEXT_PATH + IS_NEEDED);
}
- String sessionstickinessrequired = props.getProperty(SESSION_STICKINESS_REQUIRED, "");
+ String sessionstickinessrequired = props.getProperty(DmaapClientConst.SESSION_STICKINESS_REQUIRED, "");
if (sessionstickinessrequired.isEmpty()) {
- throw new IllegalArgumentException(SESSION_STICKINESS_REQUIRED + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.SESSION_STICKINESS_REQUIRED + IS_NEEDED);
}
}
private static void validateForNonDME2(Properties props) {
- String host = props.getProperty(HOST, "");
+ String host = props.getProperty(DmaapClientConst.HOST, "");
if (host.isEmpty()) {
- throw new IllegalArgumentException(HOST + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.HOST + IS_NEEDED);
}
- String topic = props.getProperty(TOPIC, "");
+ String topic = props.getProperty(DmaapClientConst.TOPIC, "");
if (topic.isEmpty()) {
- throw new IllegalArgumentException(TOPIC + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.TOPIC + IS_NEEDED);
}
- String contenttype = props.getProperty(CONTENT_TYPE, "");
+ String contenttype = props.getProperty(DmaapClientConst.CONTENT_TYPE, "");
if (contenttype.isEmpty()) {
- throw new IllegalArgumentException(CONTENT_TYPE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.CONTENT_TYPE + IS_NEEDED);
}
- String transportType = props.getProperty(TRANSPORT_TYPE);
+ String transportType = props.getProperty(DmaapClientConst.TRANSPORT_TYPE);
if (!ProtocolType.HTTPNOAUTH.getValue().equalsIgnoreCase(transportType)) {
- String username = props.getProperty(USERNAME, "");
+ String username = props.getProperty(DmaapClientConst.USERNAME, "");
if (username.isEmpty()) {
- throw new IllegalArgumentException(USERNAME + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.USERNAME + IS_NEEDED);
}
- String password = props.getProperty(PASSWORD, "");
+ String password = props.getProperty(DmaapClientConst.PASSWORD, "");
if (password.isEmpty()) {
- throw new IllegalArgumentException(PASSWORD + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.PASSWORD + IS_NEEDED);
}
}
if (ProtocolType.AUTH_KEY.getValue().equalsIgnoreCase(transportType)) {
- String authKey = props.getProperty(AUTH_KEY, "");
+ String authKey = props.getProperty(DmaapClientConst.AUTH_KEY, "");
if (authKey.isEmpty()) {
- throw new IllegalArgumentException(AUTH_KEY + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.AUTH_KEY + IS_NEEDED);
}
- String authDate = props.getProperty(AUTH_DATE, "");
+ String authDate = props.getProperty(DmaapClientConst.AUTH_DATE, "");
if (authDate.isEmpty()) {
- throw new IllegalArgumentException(AUTH_DATE + IS_NEEDED);
+ throw new IllegalArgumentException(DmaapClientConst.AUTH_DATE + IS_NEEDED);
}
}
}