-/*\r
- * ===============================LICENSE_START======================================\r
- * dcae-analytics\r
- * ================================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============================LICENSE_END===========================================\r
- */\r
-\r
-package org.openecomp.dcae.apod.analytics.dmaap.domain.config;\r
-\r
-import com.google.common.base.Objects;\r
-import org.openecomp.dcae.apod.analytics.common.exception.DCAEAnalyticsRuntimeException;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import java.util.Locale;\r
-\r
-import static org.openecomp.dcae.apod.analytics.common.utils.HTTPUtils.JSON_APPLICATION_TYPE;\r
-\r
-/**\r
- * <p>\r
- * Contains common parameters for both DMaaP Message Router Publisher and Subscriber Configs\r
- * <p>\r
- * @author Rajiv Singla . Creation Date: 10/12/2016.\r
- */\r
-public abstract class DMaaPMRBaseConfig implements DMaaPMRConfig {\r
-\r
- protected static final Logger LOG = LoggerFactory.getLogger(DMaaPMRBaseConfig.class);\r
-\r
- protected String hostName;\r
- protected Integer portNumber;\r
- protected String topicName;\r
- protected String protocol;\r
- protected String userName;\r
- protected String userPassword;\r
- protected String contentType;\r
-\r
- /**\r
- * Provides host name e.g. mrlocal-mtnjftle01.homer.com\r
- *\r
- * @return host name\r
- */\r
- public String getHostName() {\r
- return hostName;\r
- }\r
-\r
-\r
- /**\r
- * Provides Port Number of DMaaP MR Topic Host. Defaults to 80\r
- *\r
- * @return host port number\r
- */\r
- public Integer getPortNumber() {\r
- return portNumber;\r
- }\r
-\r
- /**\r
- * Provides topic name e.g. com.dcae.dmaap.mtnje2.DcaeTestVES\r
- *\r
- * @return topic name\r
- */\r
- public String getTopicName() {\r
- return topicName;\r
- }\r
-\r
- /**\r
- * Provides protocol type e.g. http or https\r
- *\r
- * @return protocol type\r
- */\r
- public String getProtocol() {\r
- return protocol;\r
- }\r
-\r
- /**\r
- * Provides content type e.g. application/json\r
- *\r
- * @return content type\r
- */\r
- public String getContentType() {\r
- return contentType;\r
- }\r
-\r
-\r
- /**\r
- * Provides User name for the DMaaP MR Topic authentication\r
- *\r
- * @return user name\r
- */\r
- public String getUserName() {\r
- return userName;\r
- }\r
-\r
- /**\r
- * Provides User password for the DMaaP MR Topic authentication\r
- *\r
- * @return user Password\r
- */\r
- public String getUserPassword() {\r
- return userPassword;\r
- }\r
-\r
-\r
- /**\r
- * Trims, adjusts casing and validates user input String for protocol selection\r
- *\r
- * @param protocol - User input for protocol String\r
- * @return - network protocol e.g http or https\r
- */\r
- protected static String normalizeValidateProtocol(final String protocol) {\r
- // validate that only http and https are supported protocols are Supported for DMaaP MR\r
- String normalizedProtocolString = protocol.trim().toLowerCase(Locale.ENGLISH);\r
- if (normalizedProtocolString.isEmpty() ||\r
- !("http".equals(normalizedProtocolString) || "https".equals(normalizedProtocolString))) {\r
-\r
- final String errorMessage =\r
- "Unsupported protocol selection. Only HTTPS and HTTPS are currently supported for DMaaP MR";\r
-\r
- throw new DCAEAnalyticsRuntimeException(errorMessage, LOG, new IllegalArgumentException(errorMessage));\r
- }\r
- return normalizedProtocolString;\r
- }\r
-\r
-\r
- /**\r
- * Trims, adjust casing and validates content type is supported by DMaaP.\r
- *\r
- * NOTE: DMaaP currently only support application/json content type\r
- *\r
- * @param contentType content type that needs to checked for DMaaP MR support\r
- * @return true if content type is supported by DMaaP MR\r
- */\r
- protected static String normalizeValidateContentType(final String contentType) {\r
- // Current DMaaP MR is only supporting "application/json" content type\r
- String normalizedContentType = contentType.trim().toLowerCase(Locale.ENGLISH);\r
- final boolean isSupported = contentType.equals(JSON_APPLICATION_TYPE);\r
- if (!isSupported) {\r
- final String errorMessage =\r
- "Unsupported content type selection. Only application/json is currently supported for DMaaP MR";\r
-\r
- throw new DCAEAnalyticsRuntimeException(errorMessage, LOG, new IllegalArgumentException(errorMessage));\r
- }\r
- return normalizedContentType;\r
- }\r
-\r
-\r
- @Override\r
- public boolean equals(Object o) {\r
- if (this == o) {\r
- return true;\r
- }\r
- if (!(o instanceof DMaaPMRBaseConfig)) {\r
- return false;\r
- }\r
- DMaaPMRBaseConfig that = (DMaaPMRBaseConfig) o;\r
- return Objects.equal(hostName, that.hostName) &&\r
- Objects.equal(portNumber, that.portNumber) &&\r
- Objects.equal(topicName, that.topicName) &&\r
- Objects.equal(protocol, that.protocol) &&\r
- Objects.equal(userName, that.userName) &&\r
- Objects.equal(userPassword, that.userPassword) &&\r
- Objects.equal(contentType, that.contentType);\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return Objects.hashCode(hostName, portNumber, topicName, protocol, userName, userPassword, contentType);\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return Objects.toStringHelper(this)\r
- .add("hostName", hostName)\r
- .add("portNumber", portNumber)\r
- .add("topicName", topicName)\r
- .add("protocol", protocol)\r
- .add("userName", userName)\r
- .add("contentType", contentType)\r
- .toString();\r
- }\r
-}\r
+/*
+ * ===============================LICENSE_START======================================
+ * dcae-analytics
+ * ================================================================================
+ * Copyright © 2017 AT&T 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===========================================
+ */
+
+package org.onap.dcae.apod.analytics.dmaap.domain.config;
+
+import com.google.common.base.Objects;
+import org.onap.dcae.apod.analytics.common.exception.DCAEAnalyticsRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Locale;
+
+import static org.onap.dcae.apod.analytics.common.utils.HTTPUtils.JSON_APPLICATION_TYPE;
+
+/**
+ * <p>
+ * Contains common parameters for both DMaaP Message Router Publisher and Subscriber Configs
+ * <p>
+ * @author Rajiv Singla . Creation Date: 10/12/2016.
+ */
+public abstract class DMaaPMRBaseConfig implements DMaaPMRConfig {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(DMaaPMRBaseConfig.class);
+
+ protected String hostName;
+ protected Integer portNumber;
+ protected String topicName;
+ protected String protocol;
+ protected String userName;
+ protected String userPassword;
+ protected String contentType;
+
+ /**
+ * Provides host name e.g. mrlocal-mtnjftle01.homer.com
+ *
+ * @return host name
+ */
+ public String getHostName() {
+ return hostName;
+ }
+
+
+ /**
+ * Provides Port Number of DMaaP MR Topic Host. Defaults to 80
+ *
+ * @return host port number
+ */
+ public Integer getPortNumber() {
+ return portNumber;
+ }
+
+ /**
+ * Provides topic name e.g. com.dcae.dmaap.mtnje2.DcaeTestVES
+ *
+ * @return topic name
+ */
+ public String getTopicName() {
+ return topicName;
+ }
+
+ /**
+ * Provides protocol type e.g. http or https
+ *
+ * @return protocol type
+ */
+ public String getProtocol() {
+ return protocol;
+ }
+
+ /**
+ * Provides content type e.g. application/json
+ *
+ * @return content type
+ */
+ public String getContentType() {
+ return contentType;
+ }
+
+
+ /**
+ * Provides User name for the DMaaP MR Topic authentication
+ *
+ * @return user name
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+ /**
+ * Provides User password for the DMaaP MR Topic authentication
+ *
+ * @return user Password
+ */
+ public String getUserPassword() {
+ return userPassword;
+ }
+
+
+ /**
+ * Trims, adjusts casing and validates user input String for protocol selection
+ *
+ * @param protocol - User input for protocol String
+ * @return - network protocol e.g http or https
+ */
+ protected static String normalizeValidateProtocol(final String protocol) {
+ // validate that only http and https are supported protocols are Supported for DMaaP MR
+ String normalizedProtocolString = protocol.trim().toLowerCase(Locale.ENGLISH);
+ if (normalizedProtocolString.isEmpty() ||
+ !("http".equals(normalizedProtocolString) || "https".equals(normalizedProtocolString))) {
+
+ final String errorMessage =
+ "Unsupported protocol selection. Only HTTPS and HTTPS are currently supported for DMaaP MR";
+
+ throw new DCAEAnalyticsRuntimeException(errorMessage, LOG, new IllegalArgumentException(errorMessage));
+ }
+ return normalizedProtocolString;
+ }
+
+
+ /**
+ * Trims, adjust casing and validates content type is supported by DMaaP.
+ *
+ * NOTE: DMaaP currently only support application/json content type
+ *
+ * @param contentType content type that needs to checked for DMaaP MR support
+ * @return true if content type is supported by DMaaP MR
+ */
+ protected static String normalizeValidateContentType(final String contentType) {
+ // Current DMaaP MR is only supporting "application/json" content type
+ String normalizedContentType = contentType.trim().toLowerCase(Locale.ENGLISH);
+ final boolean isSupported = contentType.equals(JSON_APPLICATION_TYPE);
+ if (!isSupported) {
+ final String errorMessage =
+ "Unsupported content type selection. Only application/json is currently supported for DMaaP MR";
+
+ throw new DCAEAnalyticsRuntimeException(errorMessage, LOG, new IllegalArgumentException(errorMessage));
+ }
+ return normalizedContentType;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof DMaaPMRBaseConfig)) {
+ return false;
+ }
+ DMaaPMRBaseConfig that = (DMaaPMRBaseConfig) o;
+ return Objects.equal(hostName, that.hostName) &&
+ Objects.equal(portNumber, that.portNumber) &&
+ Objects.equal(topicName, that.topicName) &&
+ Objects.equal(protocol, that.protocol) &&
+ Objects.equal(userName, that.userName) &&
+ Objects.equal(userPassword, that.userPassword) &&
+ Objects.equal(contentType, that.contentType);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(hostName, portNumber, topicName, protocol, userName, userPassword, contentType);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this)
+ .add("hostName", hostName)
+ .add("portNumber", portNumber)
+ .add("topicName", topicName)
+ .add("protocol", protocol)
+ .add("userName", userName)
+ .add("contentType", contentType)
+ .toString();
+ }
+}