summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-04-10 08:48:01 +0000
committerGerrit Code Review <gerrit@onap.org>2018-04-10 08:48:01 +0000
commitf115334f0e8711e36dd43bc79335f2c98c77723f (patch)
tree10d7e2f3b4c47d1f92815c503dc7c85e1efb206f /bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp
parentc89d0d7d347c96bcfd84971214ab2e4cfe4546ae (diff)
parent8e3ee2eab19c9b2db2423567418ab28b65ff8aec (diff)
Merge "PnfReadyEventConsumer implementation"
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java
new file mode 100644
index 0000000000..e6019f73f0
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 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.openecomp.mso.bpmn.infrastructure.pnf.dmaap;
+
+import java.io.IOException;
+import java.net.URI;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+
+public class PnfEventReadyConsumer {
+
+ private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId";
+ private HttpClient httpClient;
+
+ private String dmaapHost;
+ private int dmaapPort;
+ private String dmaapProtocol;
+ private String dmaapUriPathPrefix;
+ private String dmaapTopicName;
+ private String consumerId;
+ private String consumerGroup;
+
+ public PnfEventReadyConsumer() {
+ httpClient = HttpClientBuilder.create().build();
+ }
+
+ public void notifyWhenPnfReady(String correlationId)
+ throws IOException {
+ HttpGet getRequest = new HttpGet(buildURI(consumerGroup, consumerId));
+ HttpResponse response = httpClient.execute(getRequest);
+ checkIfResponseIsAccepted(response, correlationId);
+ }
+
+ private boolean checkIfResponseIsAccepted(HttpResponse response, String correlationId) {
+ // TODO parse response if contains proper correlationId
+ return false;
+ }
+
+ private URI buildURI(String consumerGroup, String consumerId) {
+ return UriBuilder.fromUri(dmaapUriPathPrefix)
+ .scheme(dmaapProtocol)
+ .host(dmaapHost)
+ .port(dmaapPort).path(dmaapTopicName)
+ .path(consumerGroup).path(consumerId).build();
+ }
+
+ public void setDmaapHost(String dmaapHost) {
+ this.dmaapHost = dmaapHost;
+ }
+
+ public void setDmaapPort(int dmaapPort) {
+ this.dmaapPort = dmaapPort;
+ }
+
+ public void setDmaapProtocol(String dmaapProtocol) {
+ this.dmaapProtocol = dmaapProtocol;
+ }
+
+ public void setDmaapUriPathPrefix(String dmaapUriPathPrefix) {
+ this.dmaapUriPathPrefix = dmaapUriPathPrefix;
+ }
+
+ public void setDmaapTopicName(String dmaapTopicName) {
+ this.dmaapTopicName = dmaapTopicName;
+ }
+
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+}