diff options
author | 2019-05-08 18:48:21 +0530 | |
---|---|---|
committer | 2019-05-08 18:48:21 +0530 | |
commit | fb8ad4d9fb5f08ec500fe972398c984247f96517 (patch) | |
tree | bf550c42cbefcf26b53a11d4fb0baa9e6bc7a218 /src/main/java | |
parent | a7df4e77c0439e0cce667982691f87a1205e0b87 (diff) |
Issue-ID: DCAEGEN2-1472 BBS bugfix(User Data as config)
Change-Id: I8a99637db7c41d6eafb58dfe960b6e29aacb71ff
Signed-off-by: s00370346 <swarup.nayak1@huawei.com>
Diffstat (limited to 'src/main/java')
3 files changed, 51 insertions, 3 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()) { |