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.spike.event.envelope;
23 import com.google.gson.Gson;
24 import com.google.gson.GsonBuilder;
25 import org.onap.aai.spike.event.outgoing.SpikeGraphEvent;
27 public class EventEnvelope {
29 private EventHeader header;
30 private SpikeGraphEvent body;
32 private static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
34 public EventEnvelope(EventHeader eventHeader, SpikeGraphEvent body) {
35 this.header = eventHeader;
40 * Construct the envelope header from the provided event.
42 * @param event the Spike graph event for a vertex or edge operation
44 public EventEnvelope(SpikeGraphEvent event) {
45 this.header = new EventHeader.Builder().requestId(event.getTransactionId()).build();
49 public EventHeader getEventHeader() {
53 public SpikeGraphEvent getBody() {
58 * Serializes this object into a JSON string representation.
60 * @return a JSON format string representation of this object.
62 public String toJson() {
63 return gson.toJson(this);
69 * @see java.lang.Object#toString()
72 public String toString() {