summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStela Stoykova <Stela.Stoykova@amdocs.com>2019-03-21 11:31:29 -0400
committerStela Stoykova <Stela.Stoykova@amdocs.com>2019-03-26 11:35:47 -0400
commit054076beaac949cc00035f6d6b9374e8ba752db3 (patch)
tree5735401898fb7ecab8a4e2138ca28d5073b336f7 /src
parent4dd96637aea7d42002754b5c9abffca7092dd518 (diff)
Fixed issue with spike events for "relationship"
Change-Id: Ie0db30e34534628f6c8f8d4cd394f8af466e308b Issue-ID: AAI-2271 Signed-off-by: Stela Stoykova <Stela.Stoykova@amdocs.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java78
1 files changed, 30 insertions, 48 deletions
diff --git a/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java
index 9f96a22..4aad6f2 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java
@@ -81,6 +81,8 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
protected static final String BODY_KEY = "body";
protected static final String OPERATION_KEY = "operation";
+ protected static final String EDGE_KEY = "relationship";
+
protected static final String VERTEX_KEY = "vertex";
protected static final String VERTEX_PROPERTIES_KEY = "properties";
protected static final String VERTEX_KEY_KEY = "key";
@@ -743,7 +745,7 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
// drop event
logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, "Ignoring event with sourceName='"
+ sourceName + "' and eventType='" + eventType + "'. Payload=" + eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
+ logger.info(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
"Ignoring event with sourceName='" + sourceName + "' and eventType='" + eventType + "'.");
/*
@@ -765,22 +767,33 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
String action = eventBody.getString(OPERATION_KEY);
if (action == null || !SUPPORTED_ACTIONS.contains(action.toLowerCase())) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
- "Unrecognized action '" + action + "'", eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "Unrecognized action '" + action + "'");
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "Unrecognized action '" + action + "'");
return null;
}
meta.setBodyOperationType(action);
- // Load the event body data, any errors will result in a failure and discard
+
+ /*
+ * Ignore spike events for edges
+ */
+ if (eventBody.has(EDGE_KEY)){
+ logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, "Ignoring event for edge with sourceName='"
+ + sourceName + "' and eventType='" + eventType + "'. Payload=" + eventPayload);
+ logger.info(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
+ "Ignoring event for edge with sourceName='" + sourceName + "' and eventType='" + eventType + "'.");
+ setResponse(exchange, ResponseType.SUCCESS, additionalInfo);
+ return null;
+ }
- JSONObject spikeVertex = eventBody.getJSONObject(VERTEX_KEY);
- if (spikeVertex == null) {
+
+ // Load the event body data, any errors will result in a failure and discard
+ JSONObject spikeVertex = null;
+ try {
+ spikeVertex = eventBody.getJSONObject(VERTEX_KEY);
+ } catch (JSONException exc) {
returnWithError(exchange, eventPayload, "Payload is missing " + VERTEX_KEY);
return null;
- }
+ }
meta.setSpikeVertex(spikeVertex);
@@ -788,12 +801,7 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
try {
spikeEventVertex = initializeSpikeEventVertex(spikeVertex);
} catch (JSONException exc) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
- "Error initializating spike event. Error: " + exc.getMessage(), eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "Error initializating spike event. Error: " + exc.getMessage());
-
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "Error initializating spike event. Error: " + exc.getMessage());
return null;
}
@@ -813,12 +821,7 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
String entityType = spikeEventVertex.getType();
if (entityType == null || entityType.isEmpty()) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
- "Payload header missing entity type", eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "Payload header missing entity type");
-
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "Payload vertex missing entity type");
return null;
}
@@ -830,49 +833,28 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
EntityOxmReferenceHelper.getInstance().getVersionedOxmEntities(Version.valueOf(oxmVersion.toLowerCase()));
if (oxmEntities != null && !oxmEntities.getEntityTypeLookup().containsKey(entityType)) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, "No matching OXM Descriptor for entity-type='" + entityType + "'",
- eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "No matching OXM Descriptor for entity-type='" + entityType + "'");
-
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "No matching OXM Descriptor for entity-type='" + entityType + "'");
return null;
}
String entityKey = spikeEventVertex.getKey();
if (entityKey == null || entityKey.isEmpty()) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, "Payload vertex missing entity key",
- eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "Payload vertex missing entity key");
-
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "Payload vertex missing entity key");
return null;
}
+
String entityLink = spikeEventVertex.getEntityLink();
if (entityLink == null || entityLink.isEmpty()) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
- "Payload header missing entity link", eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "Payload header missing entity link");
-
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "Payload vertex missing entity link");
return null;
}
JSONObject vertexProperties = null;
try {
-
vertexProperties = spikeVertex.getJSONObject(VERTEX_PROPERTIES_KEY);
-
} catch (JSONException exc) {
- logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
- "Payload header missing " + VERTEX_PROPERTIES_KEY, eventPayload);
- logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
- "Payload header missing " + VERTEX_PROPERTIES_KEY);
-
- setResponse(exchange, ResponseType.FAILURE, additionalInfo);
+ returnWithError(exchange, eventPayload, "Payload vertex missing " + VERTEX_PROPERTIES_KEY);
return null;
}