X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fpolicy%2FSpikeEntitySearchProcessor.java;h=98d93d12aad5be64180ef6a7ce0a9dd7ce40cce1;hb=06576aee86306e15f01796b50f323939a6d1b531;hp=7f7bdd95194c3aaf69f5c7bfbc4808edc17266b5;hpb=bf99eb77b31a4cfbc590762cc6ba669820c21439;p=aai%2Fdata-router.git diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessor.java index 7f7bdd9..98d93d1 100644 --- a/src/main/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessor.java +++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessor.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; @@ -26,23 +24,20 @@ import java.io.FileNotFoundException; import java.util.List; import org.apache.camel.Exchange; -import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.onap.aai.datarouter.entity.SpikeEventEntity; -import org.onap.aai.datarouter.entity.SpikeEventVertex; +import org.onap.aai.datarouter.entity.SpikeEventMeta; import org.onap.aai.datarouter.logging.EntityEventPolicyMsgs; public class SpikeEntitySearchProcessor extends AbstractSpikeEntityEventProcessor { public static final String additionalInfo = "Response of SpikeEntityEventPolicy"; - private static final String searchIndexSchema = ""; - + private static final String PROCESS_SPIKE_EVENT = "Process Spike Event"; /** Agent for communicating with the Search Service. */ - public SpikeEntitySearchProcessor(SpikeEventPolicyConfig config) - throws FileNotFoundException { + public SpikeEntitySearchProcessor(SpikeEventPolicyConfig config) throws FileNotFoundException { super(config); } @@ -58,53 +53,33 @@ public class SpikeEntitySearchProcessor extends AbstractSpikeEntityEventProcesso public void process(Exchange exchange) throws Exception { long startTime = System.currentTimeMillis(); - String uebPayload = getExchangeBody(exchange); - if (uebPayload == null) { - return; - } - String action = getSpikeEventAction(exchange, uebPayload); - if (action == null) { - return; - } - SpikeEventVertex eventVertex = populateEventVertex(exchange, uebPayload); - if (eventVertex == null) { - return; - } - String entityType = getEntityType(exchange, eventVertex, uebPayload); - if (entityType == null) { - return; - } - String entityLink = getEntityLink(exchange, eventVertex, uebPayload); - if (entityLink == null) { - return; - } - DynamicJAXBContext oxmJaxbContext = readOxm(exchange, uebPayload); - if (oxmJaxbContext == null) { + SpikeEventMeta meta = processSpikeEvent(exchange); + + if (meta == null) { return; } - String oxmEntityType = getOxmEntityType(entityType); - List searchableAttr = getSearchableAttibutes(oxmJaxbContext, oxmEntityType, entityType, uebPayload, - exchange); + + String oxmEntityType = getOxmEntityType(meta.getSpikeEventVertex().getType()); + List searchableAttr = getSearchableAttibutes(meta.getOxmJaxbContext(), oxmEntityType, + meta.getSpikeEventVertex().getType(), meta.getEventEntity().toString(), exchange); if (searchableAttr == null) { return; } - // log the fact that all data are in good shape - logger.info(EntityEventPolicyMsgs.PROCESS_ENTITY_EVENT_POLICY_NONVERBOSE, action, entityType); - logger.debug(EntityEventPolicyMsgs.PROCESS_ENTITY_EVENT_POLICY_VERBOSE, action, entityType, - uebPayload); SpikeEventEntity spikeEventEntity = new SpikeEventEntity(); - spikeEventEntity.setEntityType(entityType); - spikeEventEntity.setLink(entityLink); - spikeEventEntity = populateSpikeEventEntity(exchange, spikeEventEntity, oxmJaxbContext, - entityType, action, uebPayload, oxmEntityType,searchableAttr); + spikeEventEntity.setEntityType(meta.getSpikeEventVertex().getType()); + spikeEventEntity.setLink(meta.getSpikeEventVertex().getEntityLink()); + spikeEventEntity = populateSpikeEventEntity(exchange, spikeEventEntity, + meta.getOxmJaxbContext(), meta.getSpikeEventVertex().getType(), meta.getBodyOperationType(), + meta.getVertexProperties().toString(), oxmEntityType, searchableAttr); + if (spikeEventEntity == null) { return; } - handleSearchServiceOperation(spikeEventEntity, action, searchIndexName); + handleSearchServiceOperation(spikeEventEntity, meta.getBodyOperationType(), searchIndexName); long stopTime = System.currentTimeMillis(); metricsLogger.info(EntityEventPolicyMsgs.OPERATION_RESULT_NO_ERRORS, PROCESS_SPIKE_EVENT, String.valueOf(stopTime - startTime)); @@ -112,6 +87,7 @@ public class SpikeEntitySearchProcessor extends AbstractSpikeEntityEventProcesso return; } + /* * This is not for this Scope. We get back to it later. (updateCerInEntity) private void * updateSearchEntityWithCrossEntityReference(SpikeEventEntity spikeEventEntity) { try { @@ -139,13 +115,13 @@ public class SpikeEntitySearchProcessor extends AbstractSpikeEntityEventProcesso * "content", sourceObject); * * if (!sourceObject.isEmpty()) { JsonNode node = sourceObject.get(0); final String sourceCer = - * NodeUtils.extractFieldValueFromObject(node, "crossEntityReferenceValues"); String newCer = + * NodeUtils.extractFieldValueFromObject(node, "crossReferenceEntityValues"); String newCer = * spikeEventEntity.getCrossReferenceEntityValues(); boolean hasNewCer = true; if (sourceCer != * null && sourceCer.length() > 0) { // already has CER if (!sourceCer.contains(newCer)) {// don't * re-add newCer = sourceCer + ";" + newCer; } else { hasNewCer = false; } } * * if (hasNewCer) { // Do the PUT with new CER ((ObjectNode) - * node).put("crossEntityReferenceValues", newCer); jsonPayload = + * node).put("crossReferenceEntityValues", newCer); jsonPayload = * NodeUtils.convertObjectToJson(node, false); searchAgent.putDocument(entitySearchIndex, * entityId, jsonPayload, headers); } } } else { *