X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fpolicy%2FEntityEventPolicy.java;h=1d447c91deac99495805a2fc4bb8e7959917bd29;hb=bf99eb77b31a4cfbc590762cc6ba669820c21439;hp=7c7965e5c88756fb49a63a48e7e455b9e61adebb;hpb=7af00564f04e1b8f441536fce5bdf31d59fe722c;p=aai%2Fdata-router.git diff --git a/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java b/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java index 7c7965e..1d447c9 100644 --- a/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java +++ b/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java @@ -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; @@ -83,7 +81,7 @@ public class EntityEventPolicy implements Processor { private final String EVENT_HEADER = "event-header"; private final String ENTITY_HEADER = "entity"; private final String ACTION_CREATE = "create"; - private final String ACTION_DELETE = "delete"; + private final static String ACTION_DELETE = "delete"; private final String ACTION_UPDATE = "update"; private final String PROCESS_AAI_EVENT = "Process AAI Event"; private final String TOPO_LAT = "latitude"; @@ -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 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); @@ -475,7 +474,7 @@ public class EntityEventPolicy implements Processor { "link"); } else if ("customer".equalsIgnoreCase(parentEntityType) && targetEntityInstance.has("service-instance-id")){ - targetEntityUrl += "/" + RouterServiceUtil.getNodeFieldAsText(targetEntityInstance, + targetEntityUrl += RouterServiceUtil.getNodeFieldAsText(targetEntityInstance, "service-instance-id"); } @@ -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; } @@ -902,7 +901,7 @@ public class EntityEventPolicy implements Processor { headers.put(Headers.IF_MATCH, etag); } else { logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE, - entitySearchIndex, entityId); + entitySearchIndex, entityId); } ArrayList sourceObject = new ArrayList<>();