2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.datarouter.policy;
23 import java.io.FileNotFoundException;
24 import java.util.List;
26 import org.apache.camel.Exchange;
27 import org.onap.aai.datarouter.entity.SpikeAggregationEntity;
28 import org.onap.aai.datarouter.entity.SpikeEventMeta;
29 import org.onap.aai.datarouter.logging.EntityEventPolicyMsgs;
31 import com.fasterxml.jackson.databind.JsonNode;
34 public class SpikeAggregateGenericVnfProcessor extends AbstractSpikeEntityEventProcessor {
36 public static final String additionalInfo = "Response of SpikeEntityEventPolicy";
38 public SpikeAggregateGenericVnfProcessor(SpikeEventPolicyConfig config)
39 throws FileNotFoundException {
44 protected void startup() {
45 // Create the indexes in the search service if they do not already exist.
46 searchAgent.createSearchIndex(searchIndexName, searchIndexSchema, createIndexUrl);
47 logger.info(EntityEventPolicyMsgs.ENTITY_EVENT_POLICY_REGISTERED);
51 public void process(Exchange exchange) throws Exception {
53 long startTime = System.currentTimeMillis();
55 SpikeEventMeta meta = processSpikeEvent(exchange);
61 String oxmEntityType = getOxmEntityType(meta.getSpikeEventVertex().getType());
63 List<String> searchableAttr = getSearchableAttibutes(meta.getOxmJaxbContext(), oxmEntityType,
64 meta.getSpikeEventVertex().getType(), meta.getEventEntity().toString(), exchange);
66 if (searchableAttr == null) {
70 JsonNode propertiesNode =
71 mapper.readValue(meta.getVertexProperties().toString(), JsonNode.class);
73 SpikeAggregationEntity spikeAgregationEntity = new SpikeAggregationEntity();
74 spikeAgregationEntity.setLink(meta.getSpikeEventVertex().getEntityLink());
75 spikeAgregationEntity.deriveFields(propertiesNode);
77 handleSearchServiceOperation(spikeAgregationEntity, meta.getBodyOperationType(),
80 long stopTime = System.currentTimeMillis();
81 metricsLogger.info(EntityEventPolicyMsgs.OPERATION_RESULT_NO_ERRORS, PROCESS_SPIKE_EVENT,
82 String.valueOf(stopTime - startTime));
83 setResponse(exchange, ResponseType.SUCCESS, additionalInfo);