aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-dmaap-client/src/main/java/org/onap
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2019-01-07 13:48:18 +0100
committerelinuxhenrik <henrik.b.andersson@est.tech>2019-01-25 14:04:43 +0100
commit8a84a9d39fe71984bd5d861e8c865e748ca3df30 (patch)
tree76e50367dffde229a5f2bc427f3544bf60002d3a /datafile-dmaap-client/src/main/java/org/onap
parenta224b4adbe65b476cdbd74efb3169aacbf292382 (diff)
Integration with SDK
* New fields added to DmaapPublisherConfiguraion * New fields added to DmaapConsumerConfiguration * Dmaap Consumer web client replaced by SDK's consumer web client * UTs aligned * Disable enforcer plugin in DFC * Update oparent to 1.2.1 Change-Id: I3569180c15227bc2c8df74fd070571b0aa56fa04 Issue-ID: DCAEGEN2-1096 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'datafile-dmaap-client/src/main/java/org/onap')
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java47
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java70
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java33
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java2
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java89
-rw-r--r--datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java5
6 files changed, 4 insertions, 242 deletions
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java
deleted file mode 100644
index 568d4ecc..00000000
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapConsumerConfiguration.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ============LICENSE_START======================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.dcaegen2.collectors.datafile.config;
-
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-import org.springframework.stereotype.Component;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
- */
-@Component
-@Value.Immutable(prehash = true)
-@Value.Style(builder = "new")
-@Gson.TypeAdapters
-public abstract class DmaapConsumerConfiguration implements DmaapCustomConfig {
-
- private static final long serialVersionUID = 1L;
-
- @Value.Parameter
- public abstract String consumerId();
-
- @Value.Parameter
- public abstract String consumerGroup();
-
- @Value.Parameter
- public abstract Integer timeoutMS();
-
- @Value.Parameter
- public abstract Integer messageLimit();
-}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java
deleted file mode 100644
index 0b1d99eb..00000000
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapCustomConfig.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * ============LICENSE_START======================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.dcaegen2.collectors.datafile.config;
-
-import java.io.Serializable;
-
-import org.immutables.value.Value;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/28/18
- */
-public interface DmaapCustomConfig extends Serializable {
-
- @Value.Parameter
- String dmaapHostName();
-
- @Value.Parameter
- Integer dmaapPortNumber();
-
- @Value.Parameter
- String dmaapTopicName();
-
- @Value.Parameter
- String dmaapProtocol();
-
- @Value.Parameter
- String dmaapUserName();
-
- @Value.Parameter
- String dmaapUserPassword();
-
- @Value.Parameter
- String dmaapContentType();
-
-
- interface Builder<T extends DmaapCustomConfig, B extends Builder<T, B>> {
-
- B dmaapHostName(String dmaapHostName);
-
- B dmaapPortNumber(Integer dmaapPortNumber);
-
- B dmaapTopicName(String dmaapTopicName);
-
- B dmaapProtocol(String dmaapProtocol);
-
- B dmaapUserName(String dmaapUserName);
-
- B dmaapUserPassword(String dmaapUserPassword);
-
- B dmaapContentType(String dmaapContentType);
-
- T build();
- }
-}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java
deleted file mode 100644
index 06d20f73..00000000
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/config/DmaapPublisherConfiguration.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ============LICENSE_START======================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.dcaegen2.collectors.datafile.config;
-
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
- */
-@Value.Immutable(prehash = true)
-@Value.Style(builder = "new")
-@Gson.TypeAdapters
-public abstract class DmaapPublisherConfiguration implements DmaapCustomConfig {
-
- private static final long serialVersionUID = 1L;
-}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java
index 7249c083..2e9c8488 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/DmaapReactiveWebClient.java
@@ -18,7 +18,7 @@ package org.onap.dcaegen2.collectors.datafile.service;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapCustomConfig;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapCustomConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java
deleted file mode 100644
index c4bf1611..00000000
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/consumer/DmaapConsumerReactiveHttpClient.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START======================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. 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.dcaegen2.collectors.datafile.service.consumer;
-
-import java.net.URI;
-import java.util.function.Consumer;
-
-import org.onap.dcaegen2.collectors.datafile.config.DmaapConsumerConfiguration;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.reactive.function.client.WebClient;
-import org.springframework.web.util.DefaultUriBuilderFactory;
-
-import reactor.core.publisher.Mono;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 6/26/18
- * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
- */
-public class DmaapConsumerReactiveHttpClient {
-
- private WebClient webClient;
- private final String dmaapHostName;
- private final String dmaapProtocol;
- private final Integer dmaapPortNumber;
- private final String dmaapTopicName;
- private final String consumerGroup;
- private final String consumerId;
- private final String contentType;
-
- /**
- * Constructor of DmaapConsumerReactiveHttpClient.
- *
- * @param consumerConfiguration - DMaaP consumer configuration object
- */
- public DmaapConsumerReactiveHttpClient(DmaapConsumerConfiguration consumerConfiguration) {
- this.dmaapHostName = consumerConfiguration.dmaapHostName();
- this.dmaapProtocol = consumerConfiguration.dmaapProtocol();
- this.dmaapPortNumber = consumerConfiguration.dmaapPortNumber();
- this.dmaapTopicName = consumerConfiguration.dmaapTopicName();
- this.consumerGroup = consumerConfiguration.consumerGroup();
- this.consumerId = consumerConfiguration.consumerId();
- this.contentType = consumerConfiguration.dmaapContentType();
- }
-
- /**
- * Function for calling DMaaP HTTP consumer - consuming messages from Kafka/DMaaP from topic.
- *
- * @return reactive response from DMaaP in string format
- */
- public Mono<String> getDmaapConsumerResponse() {
- return webClient.get().uri(getUri()).headers(getHeaders()).retrieve()
- .onStatus(HttpStatus::is4xxClientError, clientResponse -> Mono.error(new Exception("HTTP 400")))
- .onStatus(HttpStatus::is5xxServerError, clientResponse -> Mono.error(new Exception("HTTP 500")))
- .bodyToMono(String.class);
- }
-
- private Consumer<HttpHeaders> getHeaders() {
- return httpHeaders -> httpHeaders.set(HttpHeaders.CONTENT_TYPE, contentType);
- }
-
- private String createRequestPath() {
- return dmaapTopicName + "/" + consumerGroup + "/" + consumerId;
- }
-
- public DmaapConsumerReactiveHttpClient createDmaapWebClient(WebClient webClient) {
- this.webClient = webClient;
- return this;
- }
-
- URI getUri() {
- return new DefaultUriBuilderFactory().builder().scheme(dmaapProtocol).host(dmaapHostName).port(dmaapPortNumber)
- .path(createRequestPath()).build();
- }
-}
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java
index 0e95b0b0..a4b37c58 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/service/producer/DmaapProducerReactiveHttpClient.java
@@ -36,13 +36,14 @@ import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.ssl.SSLContextBuilder;
-import org.onap.dcaegen2.collectors.datafile.config.DmaapPublisherConfiguration;
+
import org.onap.dcaegen2.collectors.datafile.io.FileSystemResourceWrapper;
import org.onap.dcaegen2.collectors.datafile.io.IFileSystemResource;
import org.onap.dcaegen2.collectors.datafile.model.CommonFunctions;
import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel;
import org.onap.dcaegen2.collectors.datafile.service.HttpUtils;
import org.onap.dcaegen2.collectors.datafile.web.PublishRedirectStrategy;
+import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
@@ -141,7 +142,7 @@ public class DmaapProducerReactiveHttpClient {
private void prepareHead(ConsumerDmaapModel model, HttpPut put) {
put.addHeader(HttpHeaders.CONTENT_TYPE, dmaapContentType);
- JsonElement metaData = new JsonParser().parse(CommonFunctions.createJsonBody(model));
+ JsonElement metaData = new JsonParser().parse(new CommonFunctions().createJsonBody(model));
String name = metaData.getAsJsonObject().remove(NAME_JSON_TAG).getAsString();
metaData.getAsJsonObject().remove(INTERNAL_LOCATION_JSON_TAG);
put.addHeader(X_ATT_DR_META, metaData.toString());