aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java48
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java7
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java28
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java7
5 files changed, 48 insertions, 48 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index dd993bca51..078317885c 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -20,9 +20,8 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
-import java.util.HashMap;
+import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
@@ -35,8 +34,7 @@ public class DmaapClientTestImpl implements DmaapClient {
private Runnable informConsumer;
@Override
- public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
- Optional<HashMap<String, String>> updateInfo) {
+ public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo) {
this.pnfCorrelationId = pnfCorrelationId;
this.informConsumer = informConsumer;
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
index 2ababac7e3..a55f32aaaa 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +21,12 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
+import java.util.Map;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.camunda.bpm.engine.runtime.Execution;
-import org.onap.aai.domain.yang.v13.Metadatum;
import org.onap.so.bpmn.common.recipe.ResourceInput;
import org.onap.so.bpmn.common.resource.ResourceRequestBuilder;
-import org.onap.so.bpmn.core.json.JsonUtils;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +38,7 @@ import java.util.Optional;
@Component
public class InformDmaapClient implements JavaDelegate {
- private Logger logger = LoggerFactory.getLogger(getClass());
+ private static final Logger LOGGER = LoggerFactory.getLogger(InformDmaapClient.class);
private DmaapClient dmaapClient;
@Override
@@ -47,25 +46,34 @@ public class InformDmaapClient implements JavaDelegate {
String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID);
RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService();
String processBusinessKey = execution.getProcessBusinessKey();
- HashMap<String, String> updateInfo = createUpdateInfo(execution);
- updateInfo.put("pnfCorrelationId", pnfCorrelationId);
- dmaapClient
- .registerForUpdate(pnfCorrelationId,
- () -> runtimeService.createMessageCorrelation("WorkflowMessage")
- .processInstanceBusinessKey(processBusinessKey).correlateWithResult(),
- Optional.of(updateInfo));
+ dmaapClient.registerForUpdate(pnfCorrelationId,
+ () -> runtimeService.createMessageCorrelation("WorkflowMessage")
+ .processInstanceBusinessKey(processBusinessKey).correlateWithResult(),
+ createUpdateInfoMap(execution));
}
- private HashMap<String, String> createUpdateInfo(DelegateExecution execution) {
- HashMap<String, String> map = new HashMap();
-
- ResourceInput resourceInputObj = ResourceRequestBuilder
+ private Map<String, String> createUpdateInfoMap(DelegateExecution execution) {
+ Map<String, String> updateInfoMap = new HashMap<>();
+ updateInfoMap.put("pnfCorrelationId",
+ (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID));
+ getResourceInput(execution).ifPresent(resourceInput -> {
+ updateInfoMap.put("globalSubscriberID", resourceInput.getGlobalSubscriberId());
+ updateInfoMap.put("serviceType", resourceInput.getServiceType());
+ updateInfoMap.put("serviceInstanceId", resourceInput.getServiceInstanceId());
+ });
+ return updateInfoMap;
+ }
- .getJsonObject((String) execution.getVariable("resourceInput"), ResourceInput.class);
- map.put("globalSubscriberID", resourceInputObj.getGlobalSubscriberId());
- map.put("serviceType", resourceInputObj.getServiceType());
- map.put("serviceInstanceId", resourceInputObj.getServiceInstanceId());
- return map;
+ private Optional<ResourceInput> getResourceInput(DelegateExecution execution) {
+ ResourceInput resourceInput = null;
+ if (execution.getVariable("resourceInput") != null) {
+ resourceInput = ResourceRequestBuilder.getJsonObject((String) execution.getVariable("resourceInput"),
+ ResourceInput.class);
+ } else {
+ LOGGER.warn("resourceInput value is null for correlation id: {}",
+ execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID));
+ }
+ return Optional.ofNullable(resourceInput);
}
@Autowired
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
index d513684659..bafb749e15 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,13 +21,11 @@
package org.onap.so.bpmn.infrastructure.pnf.dmaap;
-import java.util.HashMap;
-import java.util.Optional;
+import java.util.Map;
public interface DmaapClient {
- void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
- Optional<HashMap<String, String>> updateInfo);
+ void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo);
Runnable unregister(String pnfCorrelationId);
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
index 48061db887..02303a6b23 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
@@ -54,8 +54,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
private int topicListenerDelayInSeconds;
private volatile ScheduledThreadPoolExecutor executor;
private volatile boolean dmaapThreadListenerIsRunning;
-
- public volatile List<HashMap<String, String>> updateInfoMap;
+ private volatile List<Map<String, String>> listOfUpdateInfoMap;
@Autowired
public PnfEventReadyDmaapClient(Environment env) {
@@ -68,18 +67,15 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
.port(env.getProperty("pnf.dmaap.port", Integer.class)).path(env.getProperty("pnf.dmaap.topicName"))
.path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId"))
.build());
- updateInfoMap = new ArrayList<>();
+ listOfUpdateInfoMap = new ArrayList<>();
}
@Override
public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
- Optional<HashMap<String, String>> updateInfo) {
+ Map<String, String> updateInfo) {
logger.debug("registering for pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId);
- HashMap<String, String> map = updateInfo.get();
- if (map != null && map.size() > 0) {
- synchronized (updateInfoMap) {
- updateInfoMap.add(map);
- }
+ synchronized (listOfUpdateInfoMap) {
+ listOfUpdateInfoMap.add(updateInfo);
}
pnfCorrelationIdToThreadMap.put(pnfCorrelationId, informConsumer);
if (!dmaapThreadListenerIsRunning) {
@@ -91,14 +87,14 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
public synchronized Runnable unregister(String pnfCorrelationId) {
logger.debug("unregistering from pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId);
Runnable runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId);
- synchronized (updateInfoMap) {
- for (int i = updateInfoMap.size() - 1; i >= 0; i--) {
- if (!updateInfoMap.get(i).containsKey("pnfCorrelationId"))
+ synchronized (listOfUpdateInfoMap) {
+ for (int i = listOfUpdateInfoMap.size() - 1; i >= 0; i--) {
+ if (!listOfUpdateInfoMap.get(i).containsKey("pnfCorrelationId"))
continue;
- String id = updateInfoMap.get(i).get("pnfCorrelationId");
+ String id = listOfUpdateInfoMap.get(i).get("pnfCorrelationId");
if (id != pnfCorrelationId)
continue;
- updateInfoMap.remove(i);
+ listOfUpdateInfoMap.remove(i);
}
}
if (pnfCorrelationIdToThreadMap.isEmpty()) {
@@ -174,8 +170,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient {
String customerId = null;
String serviceType = null;
String serId = null;
- synchronized (updateInfoMap) {
- for (HashMap<String, String> map : updateInfoMap) {
+ synchronized (listOfUpdateInfoMap) {
+ for (Map<String, String> map : listOfUpdateInfoMap) {
if (!map.containsKey("pnfCorrelationId"))
continue;
if (pnfCorrelationId != map.get("pnfCorrelationId"))
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
index 2634f03d4b..598582bfd8 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Nokia.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +21,9 @@
package org.onap.so.bpmn.infrastructure.pnf.delegate;
+import java.util.Map;
import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient;
-import java.util.HashMap;
import java.util.Objects;
-import java.util.Optional;
public class DmaapClientTestImpl implements DmaapClient {
@@ -31,8 +31,7 @@ public class DmaapClientTestImpl implements DmaapClient {
private Runnable informConsumer;
@Override
- public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer,
- Optional<HashMap<String, String>> updateInfo) {
+ public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, Map<String, String> updateInfo) {
this.pnfCorrelationId = pnfCorrelationId;
this.informConsumer = informConsumer;
}