summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dcae/common/EventProcessor.java39
-rw-r--r--src/main/java/org/onap/dcae/controller/AccessController.java1
-rw-r--r--src/main/java/org/onap/dcae/controller/PersistentEventConnection.java14
-rw-r--r--src/test/java/org/onap/dcae/common/EventProcessorTest.java4
4 files changed, 54 insertions, 4 deletions
diff --git a/src/main/java/org/onap/dcae/common/EventProcessor.java b/src/main/java/org/onap/dcae/common/EventProcessor.java
index 259e3b2..1879700 100644
--- a/src/main/java/org/onap/dcae/common/EventProcessor.java
+++ b/src/main/java/org/onap/dcae/common/EventProcessor.java
@@ -85,7 +85,8 @@ public class EventProcessor implements Runnable {
if (ev.getConn().isModifyEvent()){
try {
log.info("Invoking method " + ev.getConn().getModifyMethod() + " isModify " + ev.getConn().isModifyEvent());
- modifiedObj = (JSONObject)(this.getClass().getMethod(ev.getConn().getModifyMethod(), EventData.class).invoke(this, ev));
+ modifiedObj = (JSONObject)(this.getClass().getMethod(ev.getConn().getModifyMethod(),
+ EventData.class, String.class).invoke(this, ev, ev.getConn().getUserData()));
}catch (Exception e) {
log.warn("No such method exist" + e);
}
@@ -118,7 +119,7 @@ public class EventProcessor implements Runnable {
return mergedJSON;
}
- public JSONObject modifyOntEvent(EventData ev) {
+ public JSONObject modifyOntEvent(EventData ev, String userData) {
PersistentEventConnection conn = ev.getConn();
JSONObject json1 = ev.getEventObj();
log.info("modifyOntEvent");
@@ -158,6 +159,28 @@ public class EventProcessor implements Runnable {
JSONObject additionalfields = newJSON.getJSONObject("additionalFields");
String attachment_point = oltName + "-" + olt_slot + "-" + olt_port;
additionalfields.put("attachment-point", attachment_point);
+ if (!userData.isEmpty()) {
+ java.util.Map<String, String> usrDataMap = parseuserDataToDataHashMapping(userData);
+ if (usrDataMap.containsKey("remote_id")) {
+ additionalfields.put("remote-id", usrDataMap.get("remote_id"));
+ }
+
+ if (usrDataMap.containsKey("cvlan")) {
+ additionalfields.put("cvlan", usrDataMap.get("cvlan"));
+ }
+
+ if (usrDataMap.containsKey("svlan")) {
+ additionalfields.put("svlan", usrDataMap.get("svlan"));
+ }
+
+ if (usrDataMap.containsKey("macAddress")) {
+ newJSON.put("macAddress", usrDataMap.get("macAddress"));
+ }
+
+ if (usrDataMap.containsKey("vendorName")) {
+ newJSON.put("vendorName", usrDataMap.get("vendorName"));
+ }
+ }
//additionalfields.put("remote-id", attachment-point);
} catch (Exception e) {
log.info("File reading error " + e);
@@ -167,4 +190,16 @@ public class EventProcessor implements Runnable {
log.info("final obj"+ finalObj.toString());
return finalObj;
}
+
+ public static java.util.Map<String, String> parseuserDataToDataHashMapping(String userData) {
+ java.util.Map<String, String> userDataHash = new HashMap<>();
+ String[] list = userData.split("\\;");
+ for (String aList : list) {
+ String key = aList.split("=")[0];
+ String value = aList.substring(aList.indexOf('=') + 1);
+ userDataHash.put(key, value);
+ log.info("adding key " + key + " value " + value);
+ }
+ return userDataHash;
+ }
}
diff --git a/src/main/java/org/onap/dcae/controller/AccessController.java b/src/main/java/org/onap/dcae/controller/AccessController.java
index bd80d97..b82b757 100644
--- a/src/main/java/org/onap/dcae/controller/AccessController.java
+++ b/src/main/java/org/onap/dcae/controller/AccessController.java
@@ -179,6 +179,7 @@ public class AccessController {
.setEventRuleId(event.get("event_ruleId").toString()).setParentCtrllr(this)
.setModifyEvent(Boolean.parseBoolean(event.get("modifyData").toString()))
.setModifyMethod(event.get("modifyMethod").toString())
+ .setUserData(event.get("userData").toString())
.createPersistentEventConnection();
eventList.put(name, conn);
diff --git a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
index 2fb782f..391da76 100644
--- a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
+++ b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java
@@ -57,7 +57,7 @@ public class PersistentEventConnection implements Runnable {
private static final Logger log = LoggerFactory.getLogger(PersistentEventConnection.class);
private boolean modifyEvent;
private String modifyMethod;
-
+ private String userData;
private RestConfContext ctx;
private AccessController parentCtrllr;
private Map<String, String> eventParaMap;
@@ -75,6 +75,7 @@ public class PersistentEventConnection implements Runnable {
private AccessController parentCtrllr;
private boolean modifyEvent;
private String modifyMethod;
+ private String userData;
public PersistentEventConnectionBuilder setEventName(String event_name) {
this.event_name = event_name;
@@ -130,6 +131,12 @@ public class PersistentEventConnection implements Runnable {
this.modifyMethod = modifyMethod;
return this;
}
+
+ public PersistentEventConnectionBuilder setUserData(String userData) {
+ this.userData = userData;
+ return this;
+ }
+
public PersistentEventConnection createPersistentEventConnection() {
return new PersistentEventConnection(this);
}
@@ -151,6 +158,7 @@ public class PersistentEventConnection implements Runnable {
this.state = EventConnectionState.INIT;
this.modifyEvent = builder.modifyEvent;
this.modifyMethod = builder.modifyMethod;
+ this.userData = builder.userData;
this.ctx = new RestConfContext();
for (String s : builder.parentCtrllr.getCtx().getAttributeKeySet()) {
@@ -283,6 +291,10 @@ public class PersistentEventConnection implements Runnable {
return modifyMethod;
}
+ public String getUserData() {
+ return userData;
+ }
+
public void printEventParamMap() {
log.info("----------------Event Param Map-------------------");
for (String name : eventParaMap.keySet()) {
diff --git a/src/test/java/org/onap/dcae/common/EventProcessorTest.java b/src/test/java/org/onap/dcae/common/EventProcessorTest.java
index 671cad0..eb1037e 100644
--- a/src/test/java/org/onap/dcae/common/EventProcessorTest.java
+++ b/src/test/java/org/onap/dcae/common/EventProcessorTest.java
@@ -94,7 +94,9 @@ public class EventProcessorTest {
PersistentEventConnection p = new PersistentEventConnection.PersistentEventConnectionBuilder().setEventName("")
.setEventDescription("").setEventSseventUrlEmbed(true).setEventSseventsField("").setEventSseventsUrl("")
.setEventSubscriptionTemplate("").setEventUnSubscriptionTemplate("").setEventRuleId("1234646346")
- .setParentCtrllr(acClr).setModifyEvent(true).setModifyMethod("modifyOntEvent").createPersistentEventConnection();
+ .setParentCtrllr(acClr).setModifyEvent(true).setModifyMethod("modifyOntEvent")
+ .setUserData("remote_id=AC9.0234.0337;svlan=1001;macAddress=00:11:22:33:44:55;")
+ .createPersistentEventConnection();
p.getEventParamMapValue("restapiUrl");
p.modifyEventParamMap("restapiUrl", "10.118.191.43:26335");
RestConfCollector.fProcessingInputQueue = new LinkedBlockingQueue<>(4);