aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java45
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java42
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java76
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java55
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java33
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java45
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java57
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/DmaapClient.java28
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java71
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java170
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java32
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java48
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java50
13 files changed, 0 insertions, 752 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
deleted file mode 100644
index 2be5ebdc5d..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============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.aai;
-
-import java.io.IOException;
-import java.util.Optional;
-import java.util.UUID;
-import org.apache.commons.lang.NotImplementedException;
-import org.onap.aai.domain.yang.Pnf;
-import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection;
-import org.openecomp.mso.client.aai.AAIRestClientImpl;
-import org.springframework.stereotype.Component;
-
-public class AaiConnectionImpl implements AaiConnection {
-
- @Override
- public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
- AAIRestClientImpl restClient = new AAIRestClientImpl();
- return restClient.getPnfByName(correlationId, UUID.randomUUID().toString());
- }
-
- @Override
- public void createEntry(String correlationId, Pnf entry) throws IOException {
- AAIRestClientImpl restClient = new AAIRestClientImpl();
- restClient.createPnf(correlationId, UUID.randomUUID().toString(), entry);
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java
deleted file mode 100644
index 92169b202b..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscription.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============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.delegate;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.openecomp.mso.bpmn.infrastructure.pnf.dmaap.DmaapClient;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class CancelDmaapSubscription implements JavaDelegate {
-
- private DmaapClient dmaapClient;
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- String correlationId = (String) execution.getVariable(ExecutionVariableNames.CORRELATION_ID);
- dmaapClient.unregister(correlationId);
- }
-
- @Autowired
- public void setDmaapClient(DmaapClient dmaapClient) {
- this.dmaapClient = dmaapClient;
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java
deleted file mode 100644
index 0e65dd7441..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * ============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.delegate;
-
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_IP;
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-
-import java.io.IOException;
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
-import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection;
-import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiResponse;
-import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.CheckAaiForCorrelationIdImplementation;
-import org.openecomp.mso.logger.MsoLogger;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Implementation of "Check AAI for correlation_id" task in CreateAndActivatePnfResource.bpmn
- *
- * Inputs:
- * - correlationId - String
- *
- * Outputs:
- * - AAI_CONTAINS_INFO_ABOUT_PNF - local Boolean
- * - aaiContainsInfoAboutIp - local Boolean
- */
-
-public class CheckAaiForCorrelationIdDelegate implements JavaDelegate {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
- private CheckAaiForCorrelationIdImplementation implementation = new CheckAaiForCorrelationIdImplementation();
- private AaiConnection aaiConnection;
-
- @Autowired
- public void setAaiConnection(AaiConnection aaiConnection) {
- this.aaiConnection = aaiConnection;
- }
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- String correlationId = (String) execution.getVariable(CORRELATION_ID);
- if (correlationId == null) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set");
- }
-
- try {
- AaiResponse aaiResponse = implementation.check(correlationId, aaiConnection);
-
- execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, aaiResponse.getContainsInfoAboutPnf());
- execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, aaiResponse.getContainsInfoAboutIp());
- } catch (IOException e) {
- LOGGER.error("IOException",e);
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage());
- }
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java
deleted file mode 100644
index 62b806eae8..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============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.delegate;
-
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.aai.domain.yang.Pnf;
-import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * Implementation of "Create AAI entry with pnf-id = correlation_id" task in CreateAndActivatePnfResource.bpmn
- *
- * Inputs:
- * - correlationId - String
- */
-public class CreateAaiEntryWithPnfIdDelegate implements JavaDelegate {
-
- private AaiConnection aaiConnection;
-
- @Autowired
- public void setAaiConnection(AaiConnection aaiConnection) {
- this.aaiConnection = aaiConnection;
- }
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- String correlationId = (String) execution.getVariable(CORRELATION_ID);
- Pnf pnf = new Pnf();
- pnf.setInMaint(true);
- pnf.setPnfId(correlationId);
- pnf.setPnfName(correlationId);
- aaiConnection.createEntry(correlationId, pnf);
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
deleted file mode 100644
index 361313e932..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * ============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.delegate;
-
-@SuppressWarnings("ALL")
-public class ExecutionVariableNames {
-
- private ExecutionVariableNames() {}
-
- public final static String CORRELATION_ID = "correlationId";
- public final static String AAI_CONTAINS_INFO_ABOUT_PNF = "aaiContainsInfoAboutPnf";
- public final static String AAI_CONTAINS_INFO_ABOUT_IP = "aaiContainsInfoAboutIp";
- public final static String DMAAP_MESSAGE = "dmaapMessage";
- public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification";
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
deleted file mode 100644
index edff36fe68..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============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.delegate;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.openecomp.mso.bpmn.infrastructure.pnf.dmaap.DmaapClient;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public class InformDmaapClient implements JavaDelegate {
-
- private DmaapClient dmaapClient;
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- String correlationId = (String) execution.getVariable(ExecutionVariableNames.CORRELATION_ID);
- dmaapClient.registerForUpdate(correlationId, () -> execution.getProcessEngineServices().getRuntimeService()
- .createMessageCorrelation("WorkflowMessage")
- .processInstanceBusinessKey(execution.getProcessBusinessKey())
- .correlateWithResult());
- }
-
- @Autowired
- public void setDmaapClient(DmaapClient dmaapClient) {
- this.dmaapClient = dmaapClient;
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
deleted file mode 100644
index 268113d28f..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============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.delegate;
-
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class PnfCheckInputs implements JavaDelegate {
-
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
-
- private String defaultTimeout;
-
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- String correlationId = (String) execution.getVariable(CORRELATION_ID);
- if (correlationId == null) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "correlationId variable not defined");
- }
- String timeout = (String) execution.getVariable(TIMEOUT_FOR_NOTIFICATION);
- if (timeout == null) {
- LOGGER.debug("timeoutForPnfEntryNotification variable not found, setting default");
- if (defaultTimeout == null) {
- new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999,
- "default timeoutForPnfEntryNotification value not defined");
- }
- execution.setVariable(TIMEOUT_FOR_NOTIFICATION, defaultTimeout);
- }
- }
-
- public void setDefaultTimeout(String defaultTimeout) {
- this.defaultTimeout = defaultTimeout;
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/DmaapClient.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
deleted file mode 100644
index 12a6c7c51f..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============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;
-
-public interface DmaapClient {
-
- void registerForUpdate(String correlationId, Runnable informConsumer);
-
- Runnable unregister(String correlationId);
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
deleted file mode 100644
index 2853899ae2..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============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 com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Spliterator;
-
-final class JsonUtilForCorrelationId {
-
- private static final String JSON_HEADER = "pnfRegistrationFields";
- private static final String JSON_CORRELATION_ID_FIELD_NAME = "correlationId";
-
- static List<String> parseJsonToGelAllCorrelationId(String json) {
- List<String> list = new ArrayList<>();
- JsonElement je = new JsonParser().parse(json);
- if (je.isJsonObject()) {
- getCorrelationIdFromJsonObject(je.getAsJsonObject()).ifPresent(corr -> list.add(corr));
- } else {
- JsonArray array = je.getAsJsonArray();
- Spliterator<JsonElement> spliterator = array.spliterator();
- spliterator.forEachRemaining(jsonElement -> {
- parseJsonElementToJsonObject(jsonElement)
- .ifPresent(jsonObject -> getCorrelationIdFromJsonObject(jsonObject)
- .ifPresent(correlationId -> list.add(correlationId)));
- });
- }
- return list;
- }
-
- private static Optional<JsonObject> parseJsonElementToJsonObject(JsonElement jsonElement) {
- if (jsonElement.isJsonObject()) {
- return Optional.ofNullable(jsonElement.getAsJsonObject());
- }
- return Optional.ofNullable(new JsonParser().parse(jsonElement.getAsString()).getAsJsonObject());
- }
-
- private static Optional<String> getCorrelationIdFromJsonObject(JsonObject jsonObject) {
- if (jsonObject.has(JSON_HEADER)) {
- JsonObject jo = jsonObject.getAsJsonObject(JSON_HEADER);
- if (jo.has(JSON_CORRELATION_ID_FIELD_NAME)) {
- return Optional.ofNullable(jo.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString());
- }
- }
- return Optional.empty();
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
deleted file mode 100644
index 2b3a60fa20..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*-
- * ============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 java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-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;
-import org.apache.http.util.EntityUtils;
-import org.openecomp.mso.bpmn.core.PropertyConfiguration;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.logger.MsoLogger.Catalog;
-
-public class PnfEventReadyDmaapClient implements DmaapClient {
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(Catalog.GENERAL);
-
- private HttpClient httpClient;
- private String dmaapHost;
- private int dmaapPort;
- private String dmaapProtocol;
- private String dmaapUriPathPrefix;
- private String dmaapTopicName;
- private String consumerId;
- private String consumerGroup;
- private Map<String, Runnable> pnfCorrelationIdToThreadMap;
- private HttpGet getRequest;
- private ScheduledExecutorService executor;
- private int dmaapClientDelayInSeconds;
- private volatile boolean dmaapThreadListenerIsRunning;
-
- public void init() {
- httpClient = HttpClientBuilder.create().build();
- pnfCorrelationIdToThreadMap = new ConcurrentHashMap<>();
- dmaapHost = PropertyConfiguration.getInstance().getProperties(PropertyConfiguration.MSO_BPMN_URN_PROPERTIES)
- .get("mso.dmaap.host");
- dmaapPort = Integer.parseInt(PropertyConfiguration.getInstance()
- .getProperties(PropertyConfiguration.MSO_BPMN_URN_PROPERTIES).get("mso.dmaap.port"));
- executor = null;
- getRequest = new HttpGet(buildURI());
- }
-
- @Override
- public synchronized void registerForUpdate(String correlationId, Runnable informConsumer) {
- LOGGER.debug("registering for pnf ready dmaap event for correlation id: " + correlationId);
- pnfCorrelationIdToThreadMap.put(correlationId, informConsumer);
- if (!dmaapThreadListenerIsRunning) {
- startDmaapThreadListener();
- }
- }
-
- @Override
- public synchronized Runnable unregister(String correlationId) {
- LOGGER.debug("unregistering from pnf ready dmaap event for correlation id: " + correlationId);
- Runnable runnable = pnfCorrelationIdToThreadMap.remove(correlationId);
- if (pnfCorrelationIdToThreadMap.isEmpty()) {
- stopDmaapThreadListener();
- }
- return runnable;
- }
-
- private synchronized void startDmaapThreadListener() {
- if (!dmaapThreadListenerIsRunning) {
- executor = Executors.newScheduledThreadPool(1);
- executor.scheduleWithFixedDelay(new DmaapTopicListenerThread(), 0,
- dmaapClientDelayInSeconds, TimeUnit.SECONDS);
- dmaapThreadListenerIsRunning = true;
- }
- }
-
- private synchronized void stopDmaapThreadListener() {
- if (dmaapThreadListenerIsRunning) {
- executor.shutdownNow();
- dmaapThreadListenerIsRunning = false;
- executor = null;
- }
- }
-
- private URI buildURI() {
- return UriBuilder.fromUri(dmaapUriPathPrefix)
- .scheme(dmaapProtocol)
- .host(dmaapHost)
- .port(dmaapPort).path(dmaapTopicName)
- .path(consumerGroup).path(consumerId).build();
- }
-
- 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;
- }
-
- public void setDmaapClientDelayInSeconds(int dmaapClientDelayInSeconds) {
- this.dmaapClientDelayInSeconds = dmaapClientDelayInSeconds;
- }
-
- class DmaapTopicListenerThread implements Runnable {
-
- @Override
- public void run() {
- try {
- HttpResponse response = httpClient.execute(getRequest);
- getCorrelationIdListFromResponse(response).forEach(this::informAboutPnfReadyIfCorrelationIdFound);
- } catch (IOException e) {
- LOGGER.error("Exception caught during sending rest request to dmaap for listening event topic", e);
- }
- }
-
- private List<String> getCorrelationIdListFromResponse(HttpResponse response) throws IOException {
- if (response.getStatusLine().getStatusCode() == 200) {
- String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
- if (responseString != null) {
- return JsonUtilForCorrelationId.parseJsonToGelAllCorrelationId(responseString);
- }
- }
- return Collections.emptyList();
- }
-
- private synchronized void informAboutPnfReadyIfCorrelationIdFound(String correlationId) {
- Runnable runnable = unregister(correlationId);
- if (runnable != null) {
- LOGGER.debug("pnf ready event got from dmaap for correlationId: " + correlationId);
- runnable.run();
- }
- }
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java
deleted file mode 100644
index 0bb63d5e68..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiConnection.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============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.implementation;
-
-import java.io.IOException;
-import java.util.Optional;
-import org.onap.aai.domain.yang.Pnf;
-
-public interface AaiConnection {
-
- Optional<Pnf> getEntryFor(String correlationId) throws IOException;
-
- void createEntry(String correlationId, Pnf entry) throws IOException;
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java
deleted file mode 100644
index 5fb7a43e00..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============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.implementation;
-
-import java.util.Optional;
-import javax.annotation.Nullable;
-import javax.validation.constraints.NotNull;
-
-public enum AaiResponse {
- NO_ENTRY(false, false),
- ENTRY_NO_IP(true, false),
- ENTRY_WITH_IP(true, true);
-
- private boolean containsInfoAboutPnf;
- private boolean containsInfoAboutIp;
-
- AaiResponse(boolean containsInfoAboutPnf, boolean containsInfoAboutIp) {
- this.containsInfoAboutPnf = containsInfoAboutPnf;
- this.containsInfoAboutIp = containsInfoAboutIp;
- }
-
- public boolean getContainsInfoAboutPnf() {
- return containsInfoAboutPnf;
- }
-
- public boolean getContainsInfoAboutIp() {
- return containsInfoAboutIp;
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java
deleted file mode 100644
index b982a693da..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============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.implementation;
-
-import java.io.IOException;
-import java.util.Optional;
-import org.onap.aai.domain.yang.Pnf;
-
-public class CheckAaiForCorrelationIdImplementation {
-
- public AaiResponse check(String correlationId, AaiConnection aaiConnection) throws IOException {
- Optional<Pnf> pnf = aaiConnection.getEntryFor(correlationId);
- if (!pnf.isPresent()) {
- return AaiResponse.NO_ENTRY;
- }
-
- if(extractIp(pnf.get()).isPresent()) {
- return AaiResponse.ENTRY_WITH_IP;
- } else {
- return AaiResponse.ENTRY_NO_IP;
- }
- }
-
- private Optional<String> extractIp(Pnf pnf) {
- if (pnf.getIpaddressV4Oam() != null) {
- return Optional.of(pnf.getIpaddressV4Oam());
- } else {
- return Optional.ofNullable(pnf.getIpaddressV6Oam());
- }
- }
-
-}