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.crud.service;
23 import org.onap.aai.cl.api.Logger;
24 import org.onap.aai.cl.eelf.LoggerFactory;
25 import org.onap.crud.event.GraphEvent;
26 import org.onap.crud.event.envelope.GraphEventEnvelope;
27 import org.onap.crud.logging.CrudServiceMsgs;
30 public class GraphEventUpdater {
32 private static Logger logger = LoggerFactory.getInstance().getLogger(GraphEventUpdater
35 private static Logger auditLogger = LoggerFactory.getInstance()
36 .getAuditLogger(GraphEventUpdater.class.getName());
38 public void update(String eventAsJson) {
41 GraphEventEnvelope graphEventEnvelope = GraphEventEnvelope.fromJson(eventAsJson);
42 GraphEvent graphEvent = graphEventEnvelope.getBody();
43 auditLogger.info(CrudServiceMsgs.ASYNC_RESPONSE_CONSUMER_INFO,
44 "Event received of type: " + graphEvent.getObjectType() + " with key: "
45 + graphEvent.getObjectKey() + " , transaction-id: "
46 + graphEvent.getTransactionId() + " , operation: "
47 + graphEvent.getOperation().toString());
48 logger.info(CrudServiceMsgs.ASYNC_RESPONSE_CONSUMER_INFO,
49 "Event received of type: " + graphEvent.getObjectType() + " with key: "
50 + graphEvent.getObjectKey() + " , transaction-id: "
51 + graphEvent.getTransactionId() + " , operation: "
52 + graphEvent.getOperation().toString());
53 logger.debug(CrudServiceMsgs.ASYNC_RESPONSE_CONSUMER_INFO,
54 "Event received with payload:" + eventAsJson);
56 if (CrudAsyncGraphEventCache.get(graphEvent.getTransactionId()) != null) {
57 CrudAsyncGraphEventCache.get(graphEvent.getTransactionId())
58 .populateGraphEventEnvelope(graphEventEnvelope);
60 logger.error(CrudServiceMsgs.ASYNC_DATA_SERVICE_ERROR,
61 "Request timed out. Not sending response for transaction-id: "
62 + graphEvent.getTransactionId());
65 } catch (Exception e) {
66 logger.error(CrudServiceMsgs.ASYNC_RESPONSE_CONSUMER_ERROR, e.getMessage());