2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.client.sdno.dmaap;
23 import java.io.IOException;
24 import java.util.Optional;
25 import javax.ws.rs.NotSupportedException;
26 import org.openecomp.mso.client.dmaap.DmaapConsumer;
27 import org.openecomp.mso.jsonpath.JsonPathUtil;
29 public class PnfReadyEventConsumer extends DmaapConsumer {
31 private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId";
33 private boolean continuePolling = true;
34 private String correlationId;
36 public PnfReadyEventConsumer(String correlationId) throws IOException {
37 this.correlationId = correlationId;
41 public boolean continuePolling() {
42 return continuePolling;
46 public void processMessage(String message) {
50 public boolean isAccepted(String message) {
51 Optional<String> correlationIdOpt = JsonPathUtil.getInstance().locateResult(message, JSON_PATH_CORRELATION_ID);
52 if (correlationIdOpt.isPresent()) {
53 continuePolling = false;
54 return correlationIdOpt.get().equals(correlationId);
60 public boolean isFailure(String message) {
61 throw new NotSupportedException();
65 public void stopProcessingMessages() {
66 continuePolling = false;
70 public String getRequestId() {
71 throw new NotSupportedException();
75 public String getUserName() {
76 throw new NotSupportedException();
80 public String getPassword() {
81 throw new NotSupportedException();
85 public String getTopic() {
86 throw new NotSupportedException();
90 public Optional<String> getHost() {
91 throw new NotSupportedException();