summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java29
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumer.java33
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerFactory.java30
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerImpl.java68
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/DmaapHttpClientImpl.java1
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java12
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/producer/ExtendedDmaapProducerHttpClientImpl.java14
7 files changed, 21 insertions, 166 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java
index 2e6aa9e6..20ae8d0b 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java
@@ -19,13 +19,6 @@
*/
package org.onap.dcaegen2.services.service;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.ResponseHandler;
@@ -43,9 +36,16 @@ import org.onap.dcaegen2.services.utils.HttpUtils;
import org.onap.dcaegen2.services.utils.RequestVerbs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.lang.NonNull;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Optional;
+
public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
Logger logger = LoggerFactory.getLogger(AAIExtendedHttpClientImpl.class);
@@ -55,7 +55,7 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
private final String aaiProtocol;
private final Integer aaiHostPortNumber;
- @Autowired
+
public AAIExtendedHttpClientImpl (AAIHttpClientConfiguration aaiHttpClientConfiguration) {
final AAIHttpClient aaiHttpClient = new AAIHttpClientImpl(aaiHttpClientConfiguration);
closeableHttpClient = aaiHttpClient.getAAIHttpClient();
@@ -76,14 +76,11 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
logger.error("Exception while executing HTTP request: {}", e);
}
- if (extendedDetails.isPresent()) {
- return extendedDetails;
- } else {
- return Optional.empty();
- }
+ return extendedDetails;
}
private URI createAAIExtendedURI(final String path, Map<String, String> queryParams) {
+
URI extendedURI = null;
final URIBuilder uriBuilder = new URIBuilder().setScheme(this.aaiProtocol).setHost(this.aaiHost)
@@ -96,8 +93,8 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
}
try {
- logger.info("Building extended URI");
extendedURI = uriBuilder.build();
+ logger.info("Building extended URI: {}", extendedURI);
} catch (URISyntaxException e) {
logger.error("Exception while building extended URI: {}", e);
}
@@ -151,7 +148,7 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient {
}
private Boolean isExtendedURINotNull(URI extendedURI) {
- return extendedURI != null ? true : false;
+ return extendedURI != null;
}
private Optional<StringEntity> createStringEntity(Optional<String> jsonBody) {
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumer.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumer.java
deleted file mode 100644
index 5e9705ae..00000000
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA 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.dcaegen2.services.consumer;
-
-import java.util.Date;
-import org.onap.dcaegen2.services.response.DMaaPConsumerResponse;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
- */
-public interface DMaaPConsumer extends AutoCloseable {
-
- DMaaPConsumerResponse fetchMessages();
-
- Date getSubscriberCreationTime();
-}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerFactory.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerFactory.java
deleted file mode 100644
index 4864d679..00000000
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA 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.dcaegen2.services.consumer;
-
-import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
- */
-public interface DMaaPConsumerFactory {
-
- DMaaPConsumer create(DmaapConsumerConfiguration dmaapConsumerConfiguration);
-}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerImpl.java
deleted file mode 100644
index e9511ce3..00000000
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/consumer/DMaaPConsumerImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA 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.dcaegen2.services.consumer;
-
-import java.net.URI;
-import java.time.Instant;
-import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Date;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.response.DMaaPConsumerResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/17/18
- */
-public class DMaaPConsumerImpl implements DMaaPConsumer {
-
- private static final Logger logger = LoggerFactory.getLogger(DMaaPConsumerImpl.class);
- private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
-
- private final DmaapConsumerConfiguration dmaapConsumerConfiguration;
- private final CloseableHttpClient closeableHttpClient;
- private final URI subscriberUri;
- private final Date subscriberCreationTime;
-
- public DMaaPConsumerImpl(DmaapConsumerConfiguration dmaapConsumerConfiguration,
- CloseableHttpClient closeableHttpClient, URI subscriberUri) {
- this.dmaapConsumerConfiguration = dmaapConsumerConfiguration;
- this.closeableHttpClient = closeableHttpClient;
- this.subscriberUri = subscriberUri;
- this.subscriberCreationTime = Date.from(Instant.from(LocalTime.now()));
- }
-
- @Override
- public DMaaPConsumerResponse fetchMessages() {
- return null;
- }
-
- @Override
- public Date getSubscriberCreationTime() {
- return null;
- }
-
- @Override
- public void close() throws Exception {
-
- }
-}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/DmaapHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/DmaapHttpClientImpl.java
index be4442d7..f2917d02 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/DmaapHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/DmaapHttpClientImpl.java
@@ -67,5 +67,4 @@ public class DmaapHttpClientImpl {
return httpClientBuilder.build();
}
-
}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
index 30d7ad86..5acf2042 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
@@ -50,7 +50,7 @@ public class ExtendedDmaapConsumerHttpClientImpl {
private final String dmaapContentType;
- public ExtendedDmaapConsumerHttpClientImpl(DmaapConsumerConfiguration configuration) {
+ ExtendedDmaapConsumerHttpClientImpl(DmaapConsumerConfiguration configuration) {
this.closeableHttpClient = new DmaapHttpClientImpl(configuration).getHttpClient();
this.dmaapHostName = configuration.dmaapHostName();
this.dmaapProtocol = configuration.dmaapProtocol();
@@ -72,11 +72,7 @@ public class ExtendedDmaapConsumerHttpClientImpl {
logger.error("Exception while executing HTTP request: {}", e);
}
- if (extendedDetails.isPresent()) {
- return extendedDetails;
- } else {
- return Optional.empty();
- }
+ return extendedDetails;
}
private static HttpRequestBase createHttpRequest(URI extendedURI) {
@@ -97,7 +93,7 @@ public class ExtendedDmaapConsumerHttpClientImpl {
final URI extendedURI = createDmaapConsumerExtendedURI();
if ("application/json".equals(dmaapContentType)) {
- request = Optional.of(createHttpRequest(extendedURI));
+ request = Optional.ofNullable(createHttpRequest(extendedURI));
request.get().addHeader("Content-type", dmaapContentType);
}
@@ -118,8 +114,8 @@ public class ExtendedDmaapConsumerHttpClientImpl {
.setPath(createRequestPath());
try {
- logger.info("Building extended URI");
extendedURI = uriBuilder.build();
+ logger.info("Building extended URI: {}", extendedURI);
} catch (URISyntaxException e) {
logger.error("Exception while building extended URI: {}", e);
}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/producer/ExtendedDmaapProducerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/producer/ExtendedDmaapProducerHttpClientImpl.java
index 32972273..9b6c96ff 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/producer/ExtendedDmaapProducerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/producer/ExtendedDmaapProducerHttpClientImpl.java
@@ -58,7 +58,7 @@ public class ExtendedDmaapProducerHttpClientImpl {
this.dmaapContentType = configuration.dmaapContentType();
}
- public Optional<String> getHttpProducerResponse(DmaapPublisherRequestDetails requestDetails) {
+ Optional<String> getHttpProducerResponse(DmaapPublisherRequestDetails requestDetails) {
Optional<String> extendedDetails = Optional.empty();
Optional<HttpRequestBase> request = createRequest(requestDetails);
@@ -69,11 +69,7 @@ public class ExtendedDmaapProducerHttpClientImpl {
logger.error("Exception while executing HTTP request: {}", e);
}
- if (extendedDetails.isPresent()) {
- return extendedDetails;
- } else {
- return Optional.empty();
- }
+ return extendedDetails;
}
private Boolean isExtendedURINotNull(URI extendedURI) {
@@ -102,7 +98,7 @@ public class ExtendedDmaapProducerHttpClientImpl {
final URI extendedURI = createDmaapPublisherExtendedURI(requestDetails);
if ("application/json".equals(dmaapContentType)) {
- request = Optional.of(createRequest(extendedURI, requestDetails));
+ request = Optional.ofNullable(createRequest(extendedURI, requestDetails));
request.get().addHeader("Content-type", dmaapContentType);
}
@@ -119,8 +115,8 @@ public class ExtendedDmaapProducerHttpClientImpl {
.setPath(requestDetails.dmaapAPIPath() + "/" + dmaapTopicName);
try {
- logger.info("Building extended URI");
extendedURI = uriBuilder.build();
+ logger.info("Building extended URI: {}",extendedURI);
} catch (URISyntaxException e) {
logger.error("Exception while building extended URI: {}", e);
}
@@ -142,6 +138,4 @@ public class ExtendedDmaapProducerHttpClientImpl {
post.setEntity(stringEntity.get());
return post;
}
-
-
}