Update license date and text
[aai/data-router.git] / src / main / java / org / onap / aai / datarouter / policy / EntityEventPolicy.java
index 3ba8547..db68c21 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.onap.aai.datarouter.policy;
 
@@ -130,6 +128,7 @@ public class EntityEventPolicy implements Processor {
     entitySearchIndex        = config.getSearchEntitySearchIndex();
     topographicalSearchIndex = config.getSearchTopographySearchIndex();
     aggregateGenericVnfIndex = config.getSearchAggregationVnfIndex();
+    autosuggestIndex            = config.getSearchEntityAutoSuggestIndex();
        
     // Instantiate the agent that we will use for interacting with the Search Service.
     searchAgent = new SearchServiceAgent(config.getSearchCertName(),
@@ -203,8 +202,8 @@ public class EntityEventPolicy implements Processor {
   }
 
   public void returnWithError(Exchange exchange, String payload, String errorMsg){
-    logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE, errorMsg);
-    logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE, errorMsg, payload);
+    logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE, errorMsg);
+    logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, errorMsg, payload);
     setResponse(exchange, ResponseType.FAILURE, additionalInfo);
   }
   
@@ -243,9 +242,9 @@ public class EntityEventPolicy implements Processor {
     // Get src domain from header; discard event if not originated from same domain
     String payloadSrcDomain = eventHeader.getDomain();
     if (payloadSrcDomain == null || !payloadSrcDomain.equalsIgnoreCase(this.srcDomain)) {
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Unrecognized source domain '" + payloadSrcDomain + "'", uebPayload);
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Unrecognized source domain '" + payloadSrcDomain + "'");
 
       setResponse(exchange, ResponseType.SUCCESS, additionalInfo);
@@ -255,7 +254,7 @@ public class EntityEventPolicy implements Processor {
     DynamicJAXBContext oxmJaxbContext = loadOxmContext(oxmVersion.toLowerCase());
     if (oxmJaxbContext == null) {
       logger.error(EntityEventPolicyMsgs.OXM_VERSION_NOT_SUPPORTED, oxmVersion);
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE, "OXM version mismatch",
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, "OXM version mismatch",
           uebPayload);
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -264,9 +263,9 @@ public class EntityEventPolicy implements Processor {
 
     String action = eventHeader.getAction();
     if (action == null || !SUPPORTED_ACTIONS.contains(action.toLowerCase())) {
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Unrecognized action '" + action + "'", uebPayload);
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Unrecognized action '" + action + "'");
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -275,9 +274,9 @@ public class EntityEventPolicy implements Processor {
 
     String entityType = eventHeader.getEntityType();
     if (entityType == null) {
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Payload header missing entity type", uebPayload);
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Payload header missing entity type");
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -286,9 +285,9 @@ public class EntityEventPolicy implements Processor {
 
     String topEntityType = eventHeader.getTopEntityType();
     if (topEntityType == null) {
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Payload header missing top entity type", uebPayload);
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Payload header top missing entity type");
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -297,9 +296,9 @@ public class EntityEventPolicy implements Processor {
 
     String entityLink = eventHeader.getEntityLink();
     if (entityLink == null) {
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Payload header missing entity link", uebPayload);
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Payload header missing entity link");
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -307,9 +306,9 @@ public class EntityEventPolicy implements Processor {
     }
 
     // log the fact that all data are in good shape
-    logger.info(EntityEventPolicyMsgs.PROCESS_AAI_ENTITY_EVENT_POLICY_NONVERBOSE, action,
+    logger.info(EntityEventPolicyMsgs.PROCESS_ENTITY_EVENT_POLICY_NONVERBOSE, action,
         entityType);
-    logger.debug(EntityEventPolicyMsgs.PROCESS_AAI_ENTITY_EVENT_POLICY_VERBOSE, action, entityType,
+    logger.debug(EntityEventPolicyMsgs.PROCESS_ENTITY_EVENT_POLICY_VERBOSE, action, entityType,
         uebPayload);
 
 
@@ -323,9 +322,9 @@ public class EntityEventPolicy implements Processor {
     List<String> searchableAttr =
         getOxmAttributes(uebPayload, oxmJaxbContext, oxmEntityType, entityType, "searchable");
     if (searchableAttr == null) {
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Searchable attribute not found for payload entity type '" + entityType + "'");
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Searchable attribute not found for payload entity type '" + entityType + "'",
           uebPayload);
 
@@ -337,9 +336,9 @@ public class EntityEventPolicy implements Processor {
         getEntityPrimaryKeyFieldName(oxmJaxbContext, uebPayload, oxmEntityType, entityType);
     String entityPrimaryKeyFieldValue = lookupValueUsingKey(uebPayload, entityPrimaryKeyFieldName);
     if (entityPrimaryKeyFieldValue == null || entityPrimaryKeyFieldValue.isEmpty()) {
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Payload missing primary key attribute");
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Payload missing primary key attribute", uebPayload);
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -358,9 +357,9 @@ public class EntityEventPolicy implements Processor {
     aaiEventEntity.setLink(entityLink);
 
     if (!getSearchTags(aaiEventEntity, searchableAttr, uebPayload, action)) {
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Payload missing searchable attribute for entity type '" + entityType + "'");
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Payload missing searchable attribute for entity type '" + entityType + "'", uebPayload);
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -372,9 +371,9 @@ public class EntityEventPolicy implements Processor {
       aaiEventEntity.deriveFields();
 
     } catch (NoSuchAlgorithmException e) {
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Cannot create unique SHA digest");
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Cannot create unique SHA digest", uebPayload);
 
       setResponse(exchange, ResponseType.FAILURE, additionalInfo);
@@ -814,9 +813,9 @@ public class EntityEventPolicy implements Processor {
     try {
       uebJsonObj = new JSONObject(payload);
     } catch (JSONException e) {
-      logger.debug(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_VERBOSE,
+      logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE,
           "Payload has invalid JSON Format", payload.toString());
-      logger.error(EntityEventPolicyMsgs.DISCARD_AAI_EVENT_NONVERBOSE,
+      logger.error(EntityEventPolicyMsgs.DISCARD_EVENT_NONVERBOSE,
           "Payload has invalid JSON Format");
       return null;
     }