Insert subprcess to delete E2E service instance
[so.git] / common / src / main / java / org / openecomp / mso / client / sdno / dmaap / PnfReadyEventConsumer.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.mso.client.sdno.dmaap;
22
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;
28
29 public class PnfReadyEventConsumer extends DmaapConsumer {
30
31     private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId";
32
33     private boolean continuePolling = true;
34     private String correlationId;
35
36     public PnfReadyEventConsumer(String correlationId) throws IOException {
37         this.correlationId = correlationId;
38     }
39
40     @Override
41     public boolean continuePolling() {
42         return continuePolling;
43     }
44
45     @Override
46     public void processMessage(String message) {
47     }
48
49     @Override
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);
55         }
56         return false;
57     }
58
59     @Override
60     public boolean isFailure(String message) {
61         throw new NotSupportedException();
62     }
63
64     @Override
65     public void stopProcessingMessages() {
66         continuePolling = false;
67     }
68
69     @Override
70     public String getRequestId() {
71         throw new NotSupportedException();
72     }
73
74     @Override
75     public String getUserName() {
76         throw new NotSupportedException();
77     }
78
79     @Override
80     public String getPassword() {
81         throw new NotSupportedException();
82     }
83
84     @Override
85     public String getTopic() {
86         throw new NotSupportedException();
87     }
88
89     @Override
90     public Optional<String> getHost() {
91         throw new NotSupportedException();
92     }
93 }